python-injection 0.14.0__tar.gz → 0.14.0.post0__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {python_injection-0.14.0 → python_injection-0.14.0.post0}/PKG-INFO +4 -1
- {python_injection-0.14.0 → python_injection-0.14.0.post0}/README.md +3 -0
- {python_injection-0.14.0 → python_injection-0.14.0.post0}/injection/__init__.pyi +2 -2
- {python_injection-0.14.0 → python_injection-0.14.0.post0}/injection/_core/hook.py +4 -3
- {python_injection-0.14.0 → python_injection-0.14.0.post0}/injection/_core/module.py +5 -5
- {python_injection-0.14.0 → python_injection-0.14.0.post0}/injection/_core/scope.py +2 -5
- {python_injection-0.14.0 → python_injection-0.14.0.post0}/injection/testing/__init__.py +2 -2
- {python_injection-0.14.0 → python_injection-0.14.0.post0}/injection/testing/__init__.pyi +1 -1
- {python_injection-0.14.0 → python_injection-0.14.0.post0}/injection/utils.py +2 -2
- {python_injection-0.14.0 → python_injection-0.14.0.post0}/pyproject.toml +1 -1
- {python_injection-0.14.0 → python_injection-0.14.0.post0}/.gitignore +0 -0
- {python_injection-0.14.0 → python_injection-0.14.0.post0}/injection/__init__.py +0 -0
- {python_injection-0.14.0 → python_injection-0.14.0.post0}/injection/_core/__init__.py +0 -0
- {python_injection-0.14.0 → python_injection-0.14.0.post0}/injection/_core/common/__init__.py +0 -0
- {python_injection-0.14.0 → python_injection-0.14.0.post0}/injection/_core/common/asynchronous.py +0 -0
- {python_injection-0.14.0 → python_injection-0.14.0.post0}/injection/_core/common/event.py +0 -0
- {python_injection-0.14.0 → python_injection-0.14.0.post0}/injection/_core/common/invertible.py +0 -0
- {python_injection-0.14.0 → python_injection-0.14.0.post0}/injection/_core/common/key.py +0 -0
- {python_injection-0.14.0 → python_injection-0.14.0.post0}/injection/_core/common/lazy.py +0 -0
- {python_injection-0.14.0 → python_injection-0.14.0.post0}/injection/_core/common/type.py +0 -0
- {python_injection-0.14.0 → python_injection-0.14.0.post0}/injection/_core/descriptors.py +0 -0
- {python_injection-0.14.0 → python_injection-0.14.0.post0}/injection/_core/injectables.py +0 -0
- {python_injection-0.14.0 → python_injection-0.14.0.post0}/injection/exceptions.py +0 -0
- {python_injection-0.14.0 → python_injection-0.14.0.post0}/injection/integrations/__init__.py +0 -0
- {python_injection-0.14.0 → python_injection-0.14.0.post0}/injection/integrations/fastapi.py +0 -0
- {python_injection-0.14.0 → python_injection-0.14.0.post0}/injection/py.typed +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: python-injection
|
3
|
-
Version: 0.14.0
|
3
|
+
Version: 0.14.0.post0
|
4
4
|
Summary: Fast and easy dependency injection framework.
|
5
5
|
Project-URL: Repository, https://github.com/100nm/python-injection
|
6
6
|
Author: remimd
|
@@ -78,6 +78,9 @@ if __name__ == "__main__":
|
|
78
78
|
|
79
79
|
## Resources
|
80
80
|
|
81
|
+
> ⚠️ The package isn't threadsafe, for better performance in single-threaded applications and those using `asyncio`.
|
82
|
+
> So remember to use `threading.Lock` if you're writing a multithreaded program.
|
83
|
+
|
81
84
|
* [**Basic usage**](https://github.com/100nm/python-injection/tree/prod/documentation/basic-usage.md)
|
82
85
|
* [**Scoped dependencies**](https://github.com/100nm/python-injection/tree/prod/documentation/scoped-dependencies.md)
|
83
86
|
* [**Testing**](https://github.com/100nm/python-injection/tree/prod/documentation/testing.md)
|
@@ -55,6 +55,9 @@ if __name__ == "__main__":
|
|
55
55
|
|
56
56
|
## Resources
|
57
57
|
|
58
|
+
> ⚠️ The package isn't threadsafe, for better performance in single-threaded applications and those using `asyncio`.
|
59
|
+
> So remember to use `threading.Lock` if you're writing a multithreaded program.
|
60
|
+
|
58
61
|
* [**Basic usage**](https://github.com/100nm/python-injection/tree/prod/documentation/basic-usage.md)
|
59
62
|
* [**Scoped dependencies**](https://github.com/100nm/python-injection/tree/prod/documentation/scoped-dependencies.md)
|
60
63
|
* [**Testing**](https://github.com/100nm/python-injection/tree/prod/documentation/testing.md)
|
@@ -281,7 +281,7 @@ class Module:
|
|
281
281
|
module: Module,
|
282
282
|
*,
|
283
283
|
priority: Priority | PriorityStr = ...,
|
284
|
-
) -> Iterator[
|
284
|
+
) -> Iterator[Self]:
|
285
285
|
"""
|
286
286
|
Context manager or decorator for temporary use of a module.
|
287
287
|
"""
|
@@ -305,7 +305,7 @@ class Module:
|
|
305
305
|
"""
|
306
306
|
|
307
307
|
@contextmanager
|
308
|
-
def load_profile(self, *names: str) -> Iterator[
|
308
|
+
def load_profile(self, *names: str) -> Iterator[Self]: ...
|
309
309
|
async def all_ready(self) -> None: ...
|
310
310
|
def add_logger(self, logger: Logger) -> Self: ...
|
311
311
|
@classmethod
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import itertools
|
2
|
+
from collections import deque
|
2
3
|
from collections.abc import Callable, Generator, Iterator
|
3
4
|
from dataclasses import dataclass, field
|
4
5
|
from inspect import isclass, isgeneratorfunction
|
@@ -13,8 +14,8 @@ type HookFunction[**P, T] = Callable[P, T] | HookGeneratorFunction[P, T]
|
|
13
14
|
|
14
15
|
@dataclass(eq=False, frozen=True, slots=True)
|
15
16
|
class Hook[**P, T]:
|
16
|
-
__functions:
|
17
|
-
default_factory=
|
17
|
+
__functions: deque[HookFunction[P, T]] = field(
|
18
|
+
default_factory=deque,
|
18
19
|
init=False,
|
19
20
|
repr=False,
|
20
21
|
)
|
@@ -35,7 +36,7 @@ class Hook[**P, T]:
|
|
35
36
|
return iter(self.__functions)
|
36
37
|
|
37
38
|
def add(self, *functions: HookFunction[P, T]) -> Self:
|
38
|
-
self.__functions.
|
39
|
+
self.__functions.extendleft(functions)
|
39
40
|
return self
|
40
41
|
|
41
42
|
@classmethod
|
@@ -739,11 +739,11 @@ class Module(Broker, EventListener):
|
|
739
739
|
module: Module,
|
740
740
|
*,
|
741
741
|
priority: Priority | PriorityStr = Priority.get_default(),
|
742
|
-
) -> Iterator[
|
742
|
+
) -> Iterator[Self]:
|
743
743
|
self.use(module, priority=priority)
|
744
744
|
|
745
745
|
try:
|
746
|
-
yield
|
746
|
+
yield self
|
747
747
|
finally:
|
748
748
|
self.stop_using(module)
|
749
749
|
|
@@ -762,7 +762,7 @@ class Module(Broker, EventListener):
|
|
762
762
|
|
763
763
|
return self
|
764
764
|
|
765
|
-
def load_profile(self, *names: str) -> ContextManager[
|
765
|
+
def load_profile(self, *names: str) -> ContextManager[Self]:
|
766
766
|
modules = tuple(self.from_name(name) for name in names)
|
767
767
|
|
768
768
|
for module in modules:
|
@@ -773,8 +773,8 @@ class Module(Broker, EventListener):
|
|
773
773
|
del module, modules
|
774
774
|
|
775
775
|
@contextmanager
|
776
|
-
def cleaner() -> Iterator[
|
777
|
-
yield
|
776
|
+
def cleaner() -> Iterator[Self]:
|
777
|
+
yield self
|
778
778
|
self.unlock().init_modules()
|
779
779
|
|
780
780
|
return cleaner()
|
@@ -121,11 +121,8 @@ def _bind_scope(name: str, scope: Scope, shared: bool) -> Iterator[None]:
|
|
121
121
|
f"Scope `{name}` is already defined in the current context."
|
122
122
|
)
|
123
123
|
|
124
|
-
strategy =
|
125
|
-
|
126
|
-
)
|
127
|
-
|
128
|
-
with strategy:
|
124
|
+
strategy = state.bind_shared_scope if shared else state.bind_contextual_scope
|
125
|
+
with strategy(scope):
|
129
126
|
yield
|
130
127
|
|
131
128
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from typing import ContextManager, Final
|
2
2
|
|
3
|
-
from injection import mod
|
3
|
+
from injection import Module, mod
|
4
4
|
from injection.utils import load_profile
|
5
5
|
|
6
6
|
__all__ = (
|
@@ -23,5 +23,5 @@ test_scoped = mod(_TEST_PROFILE_NAME).scoped
|
|
23
23
|
test_singleton = mod(_TEST_PROFILE_NAME).singleton
|
24
24
|
|
25
25
|
|
26
|
-
def load_test_profile(*names: str) -> ContextManager[
|
26
|
+
def load_test_profile(*names: str) -> ContextManager[Module]:
|
27
27
|
return load_profile(_TEST_PROFILE_NAME, *names)
|
@@ -11,7 +11,7 @@ test_injectable = __MODULE.injectable
|
|
11
11
|
test_scoped = __MODULE.scoped
|
12
12
|
test_singleton = __MODULE.singleton
|
13
13
|
|
14
|
-
def load_test_profile(*names: str) -> ContextManager[
|
14
|
+
def load_test_profile(*names: str) -> ContextManager[Module]:
|
15
15
|
"""
|
16
16
|
Context manager or decorator for temporary use test module.
|
17
17
|
"""
|
@@ -5,13 +5,13 @@ from pkgutil import walk_packages
|
|
5
5
|
from types import ModuleType as PythonModule
|
6
6
|
from typing import ContextManager
|
7
7
|
|
8
|
+
from injection import Module, mod
|
8
9
|
from injection import __name__ as injection_package_name
|
9
|
-
from injection import mod
|
10
10
|
|
11
11
|
__all__ = ("load_modules_with_keywords", "load_packages", "load_profile")
|
12
12
|
|
13
13
|
|
14
|
-
def load_profile(*names: str) -> ContextManager[
|
14
|
+
def load_profile(*names: str) -> ContextManager[Module]:
|
15
15
|
"""
|
16
16
|
Injection module initialization function based on profile name.
|
17
17
|
A profile name is equivalent to an injection module name.
|
File without changes
|
File without changes
|
File without changes
|
{python_injection-0.14.0 → python_injection-0.14.0.post0}/injection/_core/common/__init__.py
RENAMED
File without changes
|
{python_injection-0.14.0 → python_injection-0.14.0.post0}/injection/_core/common/asynchronous.py
RENAMED
File without changes
|
File without changes
|
{python_injection-0.14.0 → python_injection-0.14.0.post0}/injection/_core/common/invertible.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{python_injection-0.14.0 → python_injection-0.14.0.post0}/injection/integrations/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|