python-injection 0.25.7__tar.gz → 0.25.7.post0__tar.gz

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.
Files changed (34) hide show
  1. python_injection-0.25.7.post0/PKG-INFO +94 -0
  2. python_injection-0.25.7.post0/docs/index.md +63 -0
  3. {python_injection-0.25.7 → python_injection-0.25.7.post0}/pyproject.toml +7 -6
  4. python_injection-0.25.7/PKG-INFO +0 -115
  5. python_injection-0.25.7/README.md +0 -85
  6. {python_injection-0.25.7 → python_injection-0.25.7.post0}/.gitignore +0 -0
  7. {python_injection-0.25.7 → python_injection-0.25.7.post0}/LICENSE +0 -0
  8. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/__init__.py +0 -0
  9. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/__init__.pyi +0 -0
  10. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/_core/__init__.py +0 -0
  11. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/_core/asfunction.py +0 -0
  12. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/_core/common/__init__.py +0 -0
  13. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/_core/common/asynchronous.py +0 -0
  14. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/_core/common/event.py +0 -0
  15. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/_core/common/invertible.py +0 -0
  16. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/_core/common/key.py +0 -0
  17. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/_core/common/lazy.py +0 -0
  18. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/_core/common/threading.py +0 -0
  19. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/_core/common/type.py +0 -0
  20. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/_core/descriptors.py +0 -0
  21. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/_core/injectables.py +0 -0
  22. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/_core/locator.py +0 -0
  23. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/_core/module.py +0 -0
  24. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/_core/scope.py +0 -0
  25. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/_core/slots.py +0 -0
  26. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/entrypoint.py +0 -0
  27. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/exceptions.py +0 -0
  28. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/ext/__init__.py +0 -0
  29. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/ext/fastapi.py +0 -0
  30. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/ext/fastapi.pyi +0 -0
  31. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/loaders.py +0 -0
  32. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/py.typed +0 -0
  33. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/testing/__init__.py +0 -0
  34. {python_injection-0.25.7 → python_injection-0.25.7.post0}/injection/testing/__init__.pyi +0 -0
@@ -0,0 +1,94 @@
1
+ Metadata-Version: 2.4
2
+ Name: python-injection
3
+ Version: 0.25.7.post0
4
+ Summary: Fast and easy dependency injection framework.
5
+ Project-URL: Documentation, https://python-injection.remimd.dev
6
+ Project-URL: Repository, https://github.com/100nm/python-injection
7
+ Author: remimd
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: dependencies,dependency,inject,injection
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Natural Language :: English
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Topic :: Software Development :: Libraries
22
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Classifier: Topic :: Software Development :: Testing
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: <3.15,>=3.12
27
+ Requires-Dist: type-analyzer
28
+ Provides-Extra: async
29
+ Requires-Dist: anyio; extra == 'async'
30
+ Description-Content-Type: text/markdown
31
+
32
+ # python-injection
33
+
34
+ [![PyPI - Version](https://img.shields.io/pypi/v/python-injection.svg?color=546d78&style=for-the-badge)](https://pypi.org/project/python-injection)
35
+ [![PyPI - Downloads](https://img.shields.io/pypi/dm/python-injection.svg?color=546d78&style=for-the-badge)](https://pypistats.org/packages/python-injection)
36
+
37
+ ## Project motivations
38
+
39
+ Dependency injection in Python has long been a source of frustration.
40
+
41
+ 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.
42
+
43
+ The goal is straightforward: make dependency injection so easy that you'll wonder how you ever managed without it.
44
+
45
+ ## Why choose python-injection?
46
+
47
+ - **Type-driven resolution**: Dependencies are automatically resolved using Python's type annotations.
48
+ - **Decorator-based registration**: Register your dependencies with simple, readable decorators.
49
+ - **Flexible lifetimes**: Choose from 4 type of lifetimes to match your needs:
50
+ - **Transient**: A new instance every time
51
+ - **Singleton**: One instance for the entire application
52
+ - **Scoped**: One instance per scope, with context manager support
53
+ - **Constant**: Register pre-existing values
54
+ - **Profile support**: Ability to swap certain dependencies based on a profile.
55
+ - **Pull-based instantiation**: Dependencies are only created when needed, improving startup time and resource usage.
56
+ - **Full sync/async support**: Works seamlessly with both synchronous and asynchronous code.
57
+
58
+ ## Installation
59
+
60
+ Requires Python 3.12 or higher.
61
+ ```bash
62
+ pip install python-injection
63
+ ```
64
+
65
+ ## Quick start
66
+
67
+ Simply apply the decorators and the package takes care of the rest.
68
+ ```python
69
+ from injection import injectable, inject, singleton
70
+
71
+ @singleton
72
+ class Printer:
73
+ def __init__(self):
74
+ self.history = []
75
+
76
+ def print(self, message: str):
77
+ self.history.append(message)
78
+ print(message)
79
+
80
+ @injectable
81
+ class Service:
82
+ def __init__(self, printer: Printer):
83
+ self.printer = printer
84
+
85
+ def hello(self):
86
+ self.printer.print("Hello world!")
87
+
88
+ @inject
89
+ def main(service: Service):
90
+ service.hello()
91
+
92
+ if __name__ == "__main__":
93
+ main()
94
+ ```
@@ -0,0 +1,63 @@
1
+ # python-injection
2
+
3
+ [![PyPI - Version](https://img.shields.io/pypi/v/python-injection.svg?color=546d78&style=for-the-badge)](https://pypi.org/project/python-injection)
4
+ [![PyPI - Downloads](https://img.shields.io/pypi/dm/python-injection.svg?color=546d78&style=for-the-badge)](https://pypistats.org/packages/python-injection)
5
+
6
+ ## Project motivations
7
+
8
+ Dependency injection in Python has long been a source of frustration.
9
+
10
+ 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.
11
+
12
+ The goal is straightforward: make dependency injection so easy that you'll wonder how you ever managed without it.
13
+
14
+ ## Why choose python-injection?
15
+
16
+ - **Type-driven resolution**: Dependencies are automatically resolved using Python's type annotations.
17
+ - **Decorator-based registration**: Register your dependencies with simple, readable decorators.
18
+ - **Flexible lifetimes**: Choose from 4 type of lifetimes to match your needs:
19
+ - **Transient**: A new instance every time
20
+ - **Singleton**: One instance for the entire application
21
+ - **Scoped**: One instance per scope, with context manager support
22
+ - **Constant**: Register pre-existing values
23
+ - **Profile support**: Ability to swap certain dependencies based on a profile.
24
+ - **Pull-based instantiation**: Dependencies are only created when needed, improving startup time and resource usage.
25
+ - **Full sync/async support**: Works seamlessly with both synchronous and asynchronous code.
26
+
27
+ ## Installation
28
+
29
+ Requires Python 3.12 or higher.
30
+ ```bash
31
+ pip install python-injection
32
+ ```
33
+
34
+ ## Quick start
35
+
36
+ Simply apply the decorators and the package takes care of the rest.
37
+ ```python
38
+ from injection import injectable, inject, singleton
39
+
40
+ @singleton
41
+ class Printer:
42
+ def __init__(self):
43
+ self.history = []
44
+
45
+ def print(self, message: str):
46
+ self.history.append(message)
47
+ print(message)
48
+
49
+ @injectable
50
+ class Service:
51
+ def __init__(self, printer: Printer):
52
+ self.printer = printer
53
+
54
+ def hello(self):
55
+ self.printer.print("Hello world!")
56
+
57
+ @inject
58
+ def main(service: Service):
59
+ service.hello()
60
+
61
+ if __name__ == "__main__":
62
+ main()
63
+ ```
@@ -14,10 +14,10 @@ dev = [
14
14
  "pyright",
15
15
  "ruff",
16
16
  ]
17
- doc = [
18
- "fastapi",
17
+ docs = [
18
+ "mkdocs",
19
+ "mkdocs-material",
19
20
  "pydantic-settings",
20
- "typer",
21
21
  "uvloop",
22
22
  ]
23
23
  test = [
@@ -31,11 +31,11 @@ test = [
31
31
 
32
32
  [project]
33
33
  name = "python-injection"
34
- version = "0.25.7"
34
+ version = "0.25.7.post0"
35
35
  description = "Fast and easy dependency injection framework."
36
36
  license = "MIT"
37
37
  license-files = ["LICENSE"]
38
- readme = "README.md"
38
+ readme = "docs/index.md"
39
39
  requires-python = ">=3.12, <3.15"
40
40
  authors = [{ name = "remimd" }]
41
41
  keywords = ["dependencies", "dependency", "inject", "injection"]
@@ -66,6 +66,7 @@ async = [
66
66
  ]
67
67
 
68
68
  [project.urls]
69
+ Documentation = "https://python-injection.remimd.dev"
69
70
  Repository = "https://github.com/100nm/python-injection"
70
71
 
71
72
  [tool.coverage.report]
@@ -135,5 +136,5 @@ ignore = ["N818"]
135
136
  fixable = ["ALL"]
136
137
 
137
138
  [tool.uv]
138
- default-groups = ["bench", "dev", "doc", "test"]
139
+ default-groups = ["bench", "dev", "docs", "test"]
139
140
  package = true
@@ -1,115 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: python-injection
3
- Version: 0.25.7
4
- Summary: Fast and easy dependency injection framework.
5
- Project-URL: Repository, https://github.com/100nm/python-injection
6
- Author: remimd
7
- License-Expression: MIT
8
- License-File: LICENSE
9
- Keywords: dependencies,dependency,inject,injection
10
- Classifier: Development Status :: 4 - Beta
11
- Classifier: Intended Audience :: Developers
12
- Classifier: Natural Language :: English
13
- Classifier: Operating System :: OS Independent
14
- Classifier: Programming Language :: Python
15
- Classifier: Programming Language :: Python :: 3
16
- Classifier: Programming Language :: Python :: 3 :: Only
17
- Classifier: Programming Language :: Python :: 3.12
18
- Classifier: Programming Language :: Python :: 3.13
19
- Classifier: Programming Language :: Python :: 3.14
20
- Classifier: Topic :: Software Development :: Libraries
21
- Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
22
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
- Classifier: Topic :: Software Development :: Testing
24
- Classifier: Typing :: Typed
25
- Requires-Python: <3.15,>=3.12
26
- Requires-Dist: type-analyzer
27
- Provides-Extra: async
28
- Requires-Dist: anyio; extra == 'async'
29
- Description-Content-Type: text/markdown
30
-
31
- # python-injection
32
-
33
- [![CI](https://github.com/100nm/python-injection/actions/workflows/ci.yml/badge.svg)](https://github.com/100nm/python-injection)
34
- [![PyPI - Version](https://img.shields.io/pypi/v/python-injection.svg?color=blue)](https://pypi.org/project/python-injection)
35
- [![PyPI - Downloads](https://img.shields.io/pypi/dm/python-injection.svg?color=blue)](https://pypistats.org/packages/python-injection)
36
- [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
37
-
38
- ## Installation
39
-
40
- ⚠️ _Requires Python 3.12 or higher_
41
-
42
- ```bash
43
- pip install python-injection
44
- ```
45
-
46
- ## Features
47
-
48
- * Automatic dependency resolution based on type hints.
49
- * Support for multiple dependency lifetimes: `transient`, `singleton`, `constant`, and `scoped`.
50
- * Works seamlessly in both `async` and `sync` environments.
51
- * Separation of dependency sets using modules.
52
- * Runtime switching between different sets of dependencies.
53
- * Centralized setup logic using entrypoints.
54
- * Built-in type annotation for easy integration with [`FastAPI`](https://github.com/fastapi/fastapi).
55
- * Lazy dependency resolution for optimized performance.
56
-
57
- ## Motivations
58
-
59
- 1. Easy to use
60
- 2. No impact on class and function definitions
61
- 3. No tedious configuration
62
-
63
- ## Quick start
64
-
65
- Simply apply the decorators and the package takes care of the rest.
66
-
67
- ```python
68
- from injection import injectable, inject, singleton
69
-
70
- @singleton
71
- class Printer:
72
- def __init__(self):
73
- self.history = []
74
-
75
- def print(self, message: str):
76
- self.history.append(message)
77
- print(message)
78
-
79
- @injectable
80
- class Service:
81
- def __init__(self, printer: Printer):
82
- self.printer = printer
83
-
84
- def hello(self):
85
- self.printer.print("Hello world!")
86
-
87
- @inject
88
- def main(service: Service):
89
- service.hello()
90
-
91
- if __name__ == "__main__":
92
- main()
93
- ```
94
-
95
- ## Resources
96
-
97
- > ⚠️ The package isn't threadsafe by default, for better performance in single-threaded applications and those using
98
- > `asyncio`.
99
- >
100
- > Non-threadsafe functions are those that resolve dependencies or define scopes. They all come with an optional
101
- > parameter `threadsafe`.
102
- >
103
- > You can set `PYTHON_INJECTION_THREADSAFE=1` in environment variables to make the package fully threadsafe. The
104
- > environment variable is resolved at the **Python module level**, so be careful if the variable is defined dynamically.
105
-
106
- * [**Basic usage**](https://github.com/100nm/python-injection/tree/prod/documentation/basic-usage.md)
107
- * [**Scoped dependencies**](https://github.com/100nm/python-injection/tree/prod/documentation/scoped-dependencies.md)
108
- * [**Testing**](https://github.com/100nm/python-injection/tree/prod/documentation/testing.md)
109
- * [**Advanced usage**](https://github.com/100nm/python-injection/tree/prod/documentation/advanced-usage.md)
110
- * [**Loaders**](https://github.com/100nm/python-injection/tree/prod/documentation/loaders.md)
111
- * [**Entrypoint**](https://github.com/100nm/python-injection/tree/prod/documentation/entrypoint.md)
112
- * [**Integrations**](https://github.com/100nm/python-injection/tree/prod/documentation/integrations)
113
- * [**FastAPI**](https://github.com/100nm/python-injection/tree/prod/documentation/integrations/fastapi.md)
114
- * [**What if my framework isn't listed?**](https://github.com/100nm/python-injection/tree/prod/documentation/integrations/unlisted-framework.md)
115
- * [**Concrete example**](https://github.com/100nm/python-injection-example)
@@ -1,85 +0,0 @@
1
- # python-injection
2
-
3
- [![CI](https://github.com/100nm/python-injection/actions/workflows/ci.yml/badge.svg)](https://github.com/100nm/python-injection)
4
- [![PyPI - Version](https://img.shields.io/pypi/v/python-injection.svg?color=blue)](https://pypi.org/project/python-injection)
5
- [![PyPI - Downloads](https://img.shields.io/pypi/dm/python-injection.svg?color=blue)](https://pypistats.org/packages/python-injection)
6
- [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
7
-
8
- ## Installation
9
-
10
- ⚠️ _Requires Python 3.12 or higher_
11
-
12
- ```bash
13
- pip install python-injection
14
- ```
15
-
16
- ## Features
17
-
18
- * Automatic dependency resolution based on type hints.
19
- * Support for multiple dependency lifetimes: `transient`, `singleton`, `constant`, and `scoped`.
20
- * Works seamlessly in both `async` and `sync` environments.
21
- * Separation of dependency sets using modules.
22
- * Runtime switching between different sets of dependencies.
23
- * Centralized setup logic using entrypoints.
24
- * Built-in type annotation for easy integration with [`FastAPI`](https://github.com/fastapi/fastapi).
25
- * Lazy dependency resolution for optimized performance.
26
-
27
- ## Motivations
28
-
29
- 1. Easy to use
30
- 2. No impact on class and function definitions
31
- 3. No tedious configuration
32
-
33
- ## Quick start
34
-
35
- Simply apply the decorators and the package takes care of the rest.
36
-
37
- ```python
38
- from injection import injectable, inject, singleton
39
-
40
- @singleton
41
- class Printer:
42
- def __init__(self):
43
- self.history = []
44
-
45
- def print(self, message: str):
46
- self.history.append(message)
47
- print(message)
48
-
49
- @injectable
50
- class Service:
51
- def __init__(self, printer: Printer):
52
- self.printer = printer
53
-
54
- def hello(self):
55
- self.printer.print("Hello world!")
56
-
57
- @inject
58
- def main(service: Service):
59
- service.hello()
60
-
61
- if __name__ == "__main__":
62
- main()
63
- ```
64
-
65
- ## Resources
66
-
67
- > ⚠️ The package isn't threadsafe by default, for better performance in single-threaded applications and those using
68
- > `asyncio`.
69
- >
70
- > Non-threadsafe functions are those that resolve dependencies or define scopes. They all come with an optional
71
- > parameter `threadsafe`.
72
- >
73
- > You can set `PYTHON_INJECTION_THREADSAFE=1` in environment variables to make the package fully threadsafe. The
74
- > environment variable is resolved at the **Python module level**, so be careful if the variable is defined dynamically.
75
-
76
- * [**Basic usage**](https://github.com/100nm/python-injection/tree/prod/documentation/basic-usage.md)
77
- * [**Scoped dependencies**](https://github.com/100nm/python-injection/tree/prod/documentation/scoped-dependencies.md)
78
- * [**Testing**](https://github.com/100nm/python-injection/tree/prod/documentation/testing.md)
79
- * [**Advanced usage**](https://github.com/100nm/python-injection/tree/prod/documentation/advanced-usage.md)
80
- * [**Loaders**](https://github.com/100nm/python-injection/tree/prod/documentation/loaders.md)
81
- * [**Entrypoint**](https://github.com/100nm/python-injection/tree/prod/documentation/entrypoint.md)
82
- * [**Integrations**](https://github.com/100nm/python-injection/tree/prod/documentation/integrations)
83
- * [**FastAPI**](https://github.com/100nm/python-injection/tree/prod/documentation/integrations/fastapi.md)
84
- * [**What if my framework isn't listed?**](https://github.com/100nm/python-injection/tree/prod/documentation/integrations/unlisted-framework.md)
85
- * [**Concrete example**](https://github.com/100nm/python-injection-example)