python-injection 0.26.4__py3-none-any.whl → 0.27.0.post0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- injection/loaders.py +8 -0
- {python_injection-0.26.4.dist-info → python_injection-0.27.0.post0.dist-info}/METADATA +10 -6
- {python_injection-0.26.4.dist-info → python_injection-0.27.0.post0.dist-info}/RECORD +5 -5
- {python_injection-0.26.4.dist-info → python_injection-0.27.0.post0.dist-info}/WHEEL +1 -1
- {python_injection-0.26.4.dist-info → python_injection-0.27.0.post0.dist-info}/licenses/LICENSE +0 -0
injection/loaders.py
CHANGED
|
@@ -5,6 +5,7 @@ import sys
|
|
|
5
5
|
from abc import abstractmethod
|
|
6
6
|
from collections.abc import Callable, Iterator, Mapping, Sequence
|
|
7
7
|
from dataclasses import dataclass, field
|
|
8
|
+
from fnmatch import fnmatchcase
|
|
8
9
|
from importlib import import_module
|
|
9
10
|
from importlib.util import find_spec
|
|
10
11
|
from os.path import isfile
|
|
@@ -99,6 +100,13 @@ class PythonModuleLoader:
|
|
|
99
100
|
module = import_module(name) if self.predicate(name) else None
|
|
100
101
|
yield name, module
|
|
101
102
|
|
|
103
|
+
@classmethod
|
|
104
|
+
def fnmatch(cls, *patterns: str) -> Self:
|
|
105
|
+
def predicate(module_name: str) -> bool:
|
|
106
|
+
return any(fnmatchcase(module_name, pattern) for pattern in patterns)
|
|
107
|
+
|
|
108
|
+
return cls(predicate)
|
|
109
|
+
|
|
102
110
|
@classmethod
|
|
103
111
|
def from_keywords(cls, *keywords: str) -> Self:
|
|
104
112
|
"""
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: python-injection
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.27.0.post0
|
|
4
4
|
Summary: Dead-simple dependency injection framework for Python.
|
|
5
5
|
Project-URL: Documentation, https://python-injection.remimd.dev
|
|
6
|
+
Project-URL: Issues, https://github.com/100nm/python-injection/issues
|
|
6
7
|
Project-URL: Repository, https://github.com/100nm/python-injection
|
|
7
8
|
Author: remimd
|
|
8
9
|
License-Expression: MIT
|
|
9
10
|
License-File: LICENSE
|
|
10
|
-
Keywords: dependencies,dependency,inject,injection
|
|
11
|
+
Keywords: anyio,async,asyncio,container,dependencies,dependency,dependency-injection,di,fastapi,inject,injection,injector,inversion-of-control,ioc,ioc-container,scopes,singleton,type-hints
|
|
11
12
|
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Framework :: AnyIO
|
|
14
|
+
Classifier: Framework :: AsyncIO
|
|
15
|
+
Classifier: Framework :: FastAPI
|
|
12
16
|
Classifier: Intended Audience :: Developers
|
|
13
17
|
Classifier: Natural Language :: English
|
|
14
18
|
Classifier: Operating System :: OS Independent
|
|
@@ -37,7 +41,7 @@ Description-Content-Type: text/markdown
|
|
|
37
41
|
|
|
38
42
|
## Project motivations
|
|
39
43
|
|
|
40
|
-
Dependency injection in Python has long been a source of frustration.
|
|
44
|
+
Dependency injection in Python has long been a source of frustration.
|
|
41
45
|
|
|
42
46
|
Existing solutions are often verbose, require extensive boilerplate, or fail to leverage Python's type hints effectively. `python-injection` was created to solve these problems once and for all by providing a simple, elegant, and powerful dependency injection framework that feels natural to Python developers.
|
|
43
47
|
|
|
@@ -47,13 +51,13 @@ The goal is straightforward: make dependency injection so easy that you'll wonde
|
|
|
47
51
|
|
|
48
52
|
- **Type-driven resolution**: Dependencies are automatically resolved using Python's type annotations.
|
|
49
53
|
- **Decorator-based registration**: Register your dependencies with simple, readable decorators.
|
|
50
|
-
- **Flexible lifetimes**: Choose from
|
|
54
|
+
- **Flexible lifetimes**: Choose from four types of lifetimes to match your needs:
|
|
51
55
|
- **Transient**: A new instance every time
|
|
52
56
|
- **Singleton**: One instance for the entire application
|
|
53
57
|
- **Scoped**: One instance per scope, with context manager support
|
|
54
|
-
- **Constant**:
|
|
58
|
+
- **Constant**: A value created once and never re-resolved, either pre-existing or computed lazily
|
|
55
59
|
- **Profile support**: Ability to swap certain dependencies based on a profile.
|
|
56
|
-
- **Pull-based instantiation**: Dependencies are only created when needed, improving startup time and resource usage.
|
|
60
|
+
- **Pull-based instantiation**: Dependencies registered with decorators are only created when needed, improving startup time and resource usage.
|
|
57
61
|
- **Full sync/async support**: Works seamlessly with both synchronous and asynchronous code.
|
|
58
62
|
|
|
59
63
|
## Installation
|
|
@@ -2,7 +2,7 @@ injection/__init__.py,sha256=8nYCdToksoBIRTiJFrEbAUa_g8--dFL--4pfSGlGDP4,1350
|
|
|
2
2
|
injection/__init__.pyi,sha256=XzOmrlk_6HNAiQVU4aUDoy3414enMaKTNPpKpXHLYyI,13659
|
|
3
3
|
injection/entrypoint.py,sha256=-pQuu2pM6CIs-GBNYhlqRe2bPBvShbi_q-AKeOw0Iko,6698
|
|
4
4
|
injection/exceptions.py,sha256=v57yMujiq6H_zwwn30A8UYEZX9R9k-bY8FnsdaimPM4,1025
|
|
5
|
-
injection/loaders.py,sha256=
|
|
5
|
+
injection/loaders.py,sha256=P3O6T_yTDpWF5bSviPZdHkjul07qsf3fhGfwoTtroNY,7652
|
|
6
6
|
injection/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
7
|
injection/_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
injection/_core/asfunction.py,sha256=GY228WHQWvA-9rg3unR8ttyIJlhwxy0bC3LUO5K8Erg,1864
|
|
@@ -24,7 +24,7 @@ injection/ext/fastapi.py,sha256=wpiNyHKEPwQ7sAJt30XpkgiCi4-gfmyqkQWw9BejXwg,1633
|
|
|
24
24
|
injection/ext/fastapi.pyi,sha256=HLs7mfruIEFRrN_Xf8oCvSa4qwHWfwm6HHU_KMedXkE,185
|
|
25
25
|
injection/testing/__init__.py,sha256=ZWMacZuGhK8Edq1L0Ng0PaRlgKXEunyFZkFvx7-IYIQ,935
|
|
26
26
|
injection/testing/__init__.pyi,sha256=ZFQMUZmvBVkV6Ch7jiYE9zeJhnqHAQnt3vWQ1Th0zDk,646
|
|
27
|
-
python_injection-0.
|
|
28
|
-
python_injection-0.
|
|
29
|
-
python_injection-0.
|
|
30
|
-
python_injection-0.
|
|
27
|
+
python_injection-0.27.0.post0.dist-info/METADATA,sha256=ETBEjUpQJuF7aulexoW9IEUnOP2x8nsr994qSUiMywQ,4067
|
|
28
|
+
python_injection-0.27.0.post0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
29
|
+
python_injection-0.27.0.post0.dist-info/licenses/LICENSE,sha256=oC77BOa9kaaQni5rW-Z-ytz3E5h4EVg248BHg9UFgyg,1063
|
|
30
|
+
python_injection-0.27.0.post0.dist-info/RECORD,,
|
{python_injection-0.26.4.dist-info → python_injection-0.27.0.post0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|