Skip to content

Commit e6737cf

Browse files
authored
Remove some type: ignore
1 parent 246ed45 commit e6737cf

4 files changed

Lines changed: 85 additions & 84 deletions

File tree

injection/__init__.pyi

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,25 @@ from ._core.locator import ModeStr
1414
from ._core.module import PriorityStr
1515
from ._core.scope import ScopeKindStr
1616

17-
type _Decorator[T] = Callable[[T], T]
18-
19-
__MODULE: Final[Module] = ...
20-
21-
afind_instance = __MODULE.afind_instance
22-
aget_instance = __MODULE.aget_instance
23-
aget_lazy_instance = __MODULE.aget_lazy_instance
24-
constant = __MODULE.constant
25-
find_instance = __MODULE.find_instance
26-
get_instance = __MODULE.get_instance
27-
get_lazy_instance = __MODULE.get_lazy_instance
28-
inject = __MODULE.inject
29-
injectable = __MODULE.injectable
30-
reserve_scoped_slot = __MODULE.reserve_scoped_slot
31-
scoped = __MODULE.scoped
32-
set_constant = __MODULE.set_constant
33-
should_be_injectable = __MODULE.should_be_injectable
34-
singleton = __MODULE.singleton
17+
class _Decorator(Protocol):
18+
def __call__[T](self, wrapped: T, /) -> T: ...
19+
20+
_default_module: Final[Module] = ...
21+
22+
afind_instance = _default_module.afind_instance
23+
aget_instance = _default_module.aget_instance
24+
aget_lazy_instance = _default_module.aget_lazy_instance
25+
constant = _default_module.constant
26+
find_instance = _default_module.find_instance
27+
get_instance = _default_module.get_instance
28+
get_lazy_instance = _default_module.get_lazy_instance
29+
inject = _default_module.inject
30+
injectable = _default_module.injectable
31+
reserve_scoped_slot = _default_module.reserve_scoped_slot
32+
scoped = _default_module.scoped
33+
set_constant = _default_module.set_constant
34+
should_be_injectable = _default_module.should_be_injectable
35+
singleton = _default_module.singleton
3536

3637
@overload
3738
def asfunction[**P, T](
@@ -173,7 +174,7 @@ class Module:
173174
/,
174175
*,
175176
threadsafe: bool | None = ...,
176-
) -> _Decorator: ... # type: ignore[type-arg]
177+
) -> _Decorator: ...
177178
@overload
178179
def injectable[T](
179180
self,
@@ -201,7 +202,7 @@ class Module:
201202
inject: bool = ...,
202203
on: _TypeInfo[Any] = ...,
203204
mode: Mode | ModeStr = ...,
204-
) -> _Decorator: ... # type: ignore[type-arg]
205+
) -> _Decorator: ...
205206
@overload
206207
def singleton[T](
207208
self,
@@ -227,7 +228,7 @@ class Module:
227228
inject: bool = ...,
228229
on: _TypeInfo[Any] = ...,
229230
mode: Mode | ModeStr = ...,
230-
) -> _Decorator: ... # type: ignore[type-arg]
231+
) -> _Decorator: ...
231232
def scoped(
232233
self,
233234
scope_name: str,
@@ -236,7 +237,7 @@ class Module:
236237
inject: bool = ...,
237238
on: _TypeInfo[Any] = ...,
238239
mode: Mode | ModeStr = ...,
239-
) -> _Decorator: # type: ignore[type-arg]
240+
) -> _Decorator:
240241
"""
241242
Decorator applicable to a class or function or generator function. It is used
242243
to indicate how the scoped instance will be constructed. At injection time, the
@@ -256,7 +257,7 @@ class Module:
256257
self,
257258
wrapped: None = ...,
258259
/,
259-
) -> _Decorator: ... # type: ignore[type-arg]
260+
) -> _Decorator: ...
260261
@overload
261262
def constant[T](
262263
self,
@@ -280,7 +281,7 @@ class Module:
280281
*,
281282
on: _TypeInfo[Any] = ...,
282283
mode: Mode | ModeStr = ...,
283-
) -> _Decorator: ... # type: ignore[type-arg]
284+
) -> _Decorator: ...
284285
def set_constant[T](
285286
self,
286287
instance: T,

injection/_core/asfunction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
class _AsFunctionCallable[**P, T](Protocol):
11-
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> T: ...
11+
def __call__(self, /, *args: P.args, **kwargs: P.kwargs) -> T: ...
1212

1313

1414
type AsFunctionWrappedType[**P, T] = type[_AsFunctionCallable[P, T]]

injection/entrypoint.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
]
2222

2323

24-
class EntrypointDecorator[**P, T1, T2](Protocol):
24+
class _EntrypointDecorator[**P, T1, T2](Protocol):
2525
if TYPE_CHECKING: # pragma: no cover
2626

2727
@overload
@@ -62,7 +62,7 @@ def entrypointmaker[**SMP, **EPP, T1, T2](
6262
/,
6363
*,
6464
profile_loader: ProfileLoader = ...,
65-
) -> EntrypointDecorator[EPP, T1, T2]: ...
65+
) -> _EntrypointDecorator[EPP, T1, T2]: ...
6666

6767
@overload
6868
def entrypointmaker[**SMP, **EPP, T1, T2](
@@ -72,7 +72,7 @@ def entrypointmaker[**SMP, **EPP, T1, T2](
7272
profile_loader: ProfileLoader = ...,
7373
) -> Callable[
7474
[EntrypointSetupMethod[SMP, EPP, T1, T2]],
75-
EntrypointDecorator[EPP, T1, T2],
75+
_EntrypointDecorator[EPP, T1, T2],
7676
]: ...
7777

7878

@@ -84,7 +84,7 @@ def entrypointmaker[**SMP, **EPP, T1, T2](
8484
) -> Any:
8585
def decorator(
8686
wp: EntrypointSetupMethod[SMP, EPP, T1, T2],
87-
) -> EntrypointDecorator[EPP, T1, T2]:
87+
) -> _EntrypointDecorator[EPP, T1, T2]:
8888
return Entrypoint._make_decorator(wp, profile_loader)
8989

9090
return decorator(wrapped) if wrapped else decorator
@@ -173,7 +173,7 @@ def _make_decorator[**_P, _T](
173173
setup_method: EntrypointSetupMethod[_P, P, T, _T],
174174
/,
175175
profile_loader: ProfileLoader | None = None,
176-
) -> EntrypointDecorator[P, T, _T]:
176+
) -> _EntrypointDecorator[P, T, _T]:
177177
profile_loader = profile_loader or ProfileLoader()
178178
setup_method = profile_loader.module.make_injected_function(setup_method)
179179

0 commit comments

Comments
 (0)