python-injection 0.26.4__py3-none-any.whl → 0.27.0__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 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,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: python-injection
3
- Version: 0.26.4
3
+ Version: 0.27.0
4
4
  Summary: Dead-simple dependency injection framework for Python.
5
5
  Project-URL: Documentation, https://python-injection.remimd.dev
6
6
  Project-URL: Repository, https://github.com/100nm/python-injection
@@ -37,7 +37,7 @@ Description-Content-Type: text/markdown
37
37
 
38
38
  ## Project motivations
39
39
 
40
- Dependency injection in Python has long been a source of frustration.
40
+ Dependency injection in Python has long been a source of frustration.
41
41
 
42
42
  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
43
 
@@ -47,13 +47,13 @@ The goal is straightforward: make dependency injection so easy that you'll wonde
47
47
 
48
48
  - **Type-driven resolution**: Dependencies are automatically resolved using Python's type annotations.
49
49
  - **Decorator-based registration**: Register your dependencies with simple, readable decorators.
50
- - **Flexible lifetimes**: Choose from 4 type of lifetimes to match your needs:
50
+ - **Flexible lifetimes**: Choose from four types of lifetimes to match your needs:
51
51
  - **Transient**: A new instance every time
52
52
  - **Singleton**: One instance for the entire application
53
53
  - **Scoped**: One instance per scope, with context manager support
54
- - **Constant**: Register pre-existing values
54
+ - **Constant**: A value created once and never re-resolved, either pre-existing or computed lazily
55
55
  - **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.
56
+ - **Pull-based instantiation**: Dependencies registered with decorators are only created when needed, improving startup time and resource usage.
57
57
  - **Full sync/async support**: Works seamlessly with both synchronous and asynchronous code.
58
58
 
59
59
  ## 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=gBwEfmR1ZHybD2hdtVr-ji6HZS7gCQvgajoiatmZpeM,7394
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.26.4.dist-info/METADATA,sha256=Ih2Ar0OxlZABkHCW6poo9PzQTBB7dBrnJS6QlCGmnck,3672
28
- python_injection-0.26.4.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
29
- python_injection-0.26.4.dist-info/licenses/LICENSE,sha256=oC77BOa9kaaQni5rW-Z-ytz3E5h4EVg248BHg9UFgyg,1063
30
- python_injection-0.26.4.dist-info/RECORD,,
27
+ python_injection-0.27.0.dist-info/METADATA,sha256=k4HS5jEhEwHJ-E6V0YnE2f_26ViKF8NfdOZSP-1Qwgo,3756
28
+ python_injection-0.27.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
29
+ python_injection-0.27.0.dist-info/licenses/LICENSE,sha256=oC77BOa9kaaQni5rW-Z-ytz3E5h4EVg248BHg9UFgyg,1063
30
+ python_injection-0.27.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.32.4
2
+ Generator: hatchling 1.33.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any