Skip to content

Commit b7705fe

Browse files
authored
refactoring: ♻️ Update pyi files
1 parent 86d96c0 commit b7705fe

2 files changed

Lines changed: 42 additions & 42 deletions

File tree

injection/__init__.pyi

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,42 @@ from ._core.common.type import TypeInfo as _TypeInfo
1919
from ._core.module import InjectableFactory as _InjectableFactory
2020
from ._core.module import ModeStr, PriorityStr
2121

22-
_: Module = ...
22+
__module: Module = ...
2323

24-
afind_instance = _.afind_instance
25-
aget_instance = _.aget_instance
26-
aget_lazy_instance = _.aget_lazy_instance
27-
constant = _.constant
28-
find_instance = _.find_instance
29-
get_instance = _.get_instance
30-
get_lazy_instance = _.get_lazy_instance
31-
inject = _.inject
32-
injectable = _.injectable
33-
set_constant = _.set_constant
34-
should_be_injectable = _.should_be_injectable
35-
singleton = _.singleton
36-
37-
del _
24+
afind_instance = __module.afind_instance
25+
aget_instance = __module.aget_instance
26+
aget_lazy_instance = __module.aget_lazy_instance
27+
constant = __module.constant
28+
find_instance = __module.find_instance
29+
get_instance = __module.get_instance
30+
get_lazy_instance = __module.get_lazy_instance
31+
inject = __module.inject
32+
injectable = __module.injectable
33+
set_constant = __module.set_constant
34+
should_be_injectable = __module.should_be_injectable
35+
singleton = __module.singleton
3836

3937
def mod(name: str = ..., /) -> Module:
4038
"""
4139
Short syntax for `Module.from_name`.
4240
"""
41+
@runtime_checkable
42+
class Injectable[T](Protocol):
43+
@property
44+
def is_locked(self) -> bool: ...
45+
def unlock(self) -> None: ...
46+
@abstractmethod
47+
async def aget_instance(self) -> T: ...
48+
@abstractmethod
49+
def get_instance(self) -> T: ...
50+
51+
class LazyInstance[T]:
52+
def __init__(self, cls: _InputType[T], module: Module = ...) -> None: ...
53+
@overload
54+
def __get__(self, instance: object, owner: type | None = ...) -> T: ...
55+
@overload
56+
def __get__(self, instance: None = ..., owner: type | None = ...) -> Self: ...
57+
4358
@final
4459
class Module:
4560
"""
@@ -275,30 +290,13 @@ class Module:
275290
Class method for getting the default module.
276291
"""
277292

278-
@final
279-
class Priority(Enum):
280-
LOW = ...
281-
HIGH = ...
282-
283-
@runtime_checkable
284-
class Injectable[T](Protocol):
285-
@property
286-
def is_locked(self) -> bool: ...
287-
def unlock(self) -> None: ...
288-
@abstractmethod
289-
async def aget_instance(self) -> T: ...
290-
@abstractmethod
291-
def get_instance(self) -> T: ...
292-
293293
@final
294294
class Mode(Enum):
295295
FALLBACK = ...
296296
NORMAL = ...
297297
OVERRIDE = ...
298298

299-
class LazyInstance[T]:
300-
def __init__(self, cls: _InputType[T], module: Module = ...) -> None: ...
301-
@overload
302-
def __get__(self, instance: object, owner: type | None = ...) -> T: ...
303-
@overload
304-
def __get__(self, instance: None = ..., owner: type | None = ...) -> Self: ...
299+
@final
300+
class Priority(Enum):
301+
LOW = ...
302+
HIGH = ...

injection/testing/__init__.pyi

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
from typing import ContextManager
22

3-
import injection as _
3+
from injection import Module
44

5-
set_test_constant = _.set_constant
6-
should_be_test_injectable = _.should_be_injectable
7-
test_constant = _.constant
8-
test_injectable = _.injectable
9-
test_singleton = _.singleton
5+
__module: Module = ...
6+
7+
set_test_constant = __module.set_constant
8+
should_be_test_injectable = __module.should_be_injectable
9+
test_constant = __module.constant
10+
test_injectable = __module.injectable
11+
test_singleton = __module.singleton
1012

1113
def load_test_profile(*names: str) -> ContextManager[None]:
1214
"""

0 commit comments

Comments
 (0)