anydi 0.27.1__tar.gz → 0.28.0__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.
- {anydi-0.27.1 → anydi-0.28.0}/PKG-INFO +2 -2
- {anydi-0.27.1 → anydi-0.28.0}/anydi/_context.py +16 -0
- {anydi-0.27.1 → anydi-0.28.0}/pyproject.toml +5 -5
- {anydi-0.27.1 → anydi-0.28.0}/LICENSE +0 -0
- {anydi-0.27.1 → anydi-0.28.0}/README.md +0 -0
- {anydi-0.27.1 → anydi-0.28.0}/anydi/__init__.py +0 -0
- {anydi-0.27.1 → anydi-0.28.0}/anydi/_container.py +0 -0
- {anydi-0.27.1 → anydi-0.28.0}/anydi/_logger.py +0 -0
- {anydi-0.27.1 → anydi-0.28.0}/anydi/_module.py +0 -0
- {anydi-0.27.1 → anydi-0.28.0}/anydi/_scanner.py +0 -0
- {anydi-0.27.1 → anydi-0.28.0}/anydi/_types.py +0 -0
- {anydi-0.27.1 → anydi-0.28.0}/anydi/_utils.py +0 -0
- {anydi-0.27.1 → anydi-0.28.0}/anydi/ext/__init__.py +0 -0
- {anydi-0.27.1 → anydi-0.28.0}/anydi/ext/_utils.py +0 -0
- {anydi-0.27.1 → anydi-0.28.0}/anydi/ext/django/__init__.py +0 -0
- {anydi-0.27.1 → anydi-0.28.0}/anydi/ext/django/_container.py +0 -0
- {anydi-0.27.1 → anydi-0.28.0}/anydi/ext/django/_settings.py +0 -0
- {anydi-0.27.1 → anydi-0.28.0}/anydi/ext/django/_utils.py +0 -0
- {anydi-0.27.1 → anydi-0.28.0}/anydi/ext/django/apps.py +0 -0
- {anydi-0.27.1 → anydi-0.28.0}/anydi/ext/django/middleware.py +0 -0
- {anydi-0.27.1 → anydi-0.28.0}/anydi/ext/django/ninja/__init__.py +0 -0
- {anydi-0.27.1 → anydi-0.28.0}/anydi/ext/django/ninja/_operation.py +0 -0
- {anydi-0.27.1 → anydi-0.28.0}/anydi/ext/django/ninja/_signature.py +0 -0
- {anydi-0.27.1 → anydi-0.28.0}/anydi/ext/fastapi.py +0 -0
- {anydi-0.27.1 → anydi-0.28.0}/anydi/ext/faststream.py +0 -0
- {anydi-0.27.1 → anydi-0.28.0}/anydi/ext/pytest_plugin.py +0 -0
- {anydi-0.27.1 → anydi-0.28.0}/anydi/ext/starlette/__init__.py +0 -0
- {anydi-0.27.1 → anydi-0.28.0}/anydi/ext/starlette/middleware.py +0 -0
- {anydi-0.27.1 → anydi-0.28.0}/anydi/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: anydi
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.28.0
|
|
4
4
|
Summary: Dependency Injection library
|
|
5
5
|
Home-page: https://github.com/antonrh/anydi
|
|
6
6
|
License: MIT
|
|
@@ -32,7 +32,7 @@ Provides-Extra: async
|
|
|
32
32
|
Provides-Extra: docs
|
|
33
33
|
Requires-Dist: anyio (>=3.6.2,<4.0.0) ; extra == "async"
|
|
34
34
|
Requires-Dist: mkdocs (>=1.4.2,<2.0.0) ; extra == "docs"
|
|
35
|
-
Requires-Dist: mkdocs-material (>=9.5.
|
|
35
|
+
Requires-Dist: mkdocs-material (>=9.5.29,<10.0.0) ; extra == "docs"
|
|
36
36
|
Requires-Dist: typing-extensions (>=4.12.1,<5.0.0)
|
|
37
37
|
Project-URL: Repository, https://github.com/antonrh/anydi
|
|
38
38
|
Description-Content-Type: text/markdown
|
|
@@ -195,6 +195,14 @@ class ResourceScopedContext(ScopedContext):
|
|
|
195
195
|
"""
|
|
196
196
|
return interface in self._instances
|
|
197
197
|
|
|
198
|
+
def _create_instance(self, provider: Provider) -> Any:
|
|
199
|
+
"""Create an instance using the provider."""
|
|
200
|
+
instance = super()._create_instance(provider)
|
|
201
|
+
# Enter the context manager if the instance is closable.
|
|
202
|
+
if hasattr(instance, "__enter__") and hasattr(instance, "__exit__"):
|
|
203
|
+
self._stack.enter_context(instance)
|
|
204
|
+
return instance
|
|
205
|
+
|
|
198
206
|
def _create_resource(self, provider: Provider) -> Any:
|
|
199
207
|
"""Create a resource using the provider.
|
|
200
208
|
|
|
@@ -208,6 +216,14 @@ class ResourceScopedContext(ScopedContext):
|
|
|
208
216
|
cm = contextlib.contextmanager(provider.obj)(*args, **kwargs)
|
|
209
217
|
return self._stack.enter_context(cm)
|
|
210
218
|
|
|
219
|
+
async def _acreate_instance(self, provider: Provider) -> Any:
|
|
220
|
+
"""Create an instance asynchronously using the provider."""
|
|
221
|
+
instance = await super()._acreate_instance(provider)
|
|
222
|
+
# Enter the context manager if the instance is closable.
|
|
223
|
+
if hasattr(instance, "__aenter__") and hasattr(instance, "__aexit__"):
|
|
224
|
+
await self._async_stack.enter_async_context(instance)
|
|
225
|
+
return instance
|
|
226
|
+
|
|
211
227
|
async def _acreate_resource(self, provider: Provider) -> Any:
|
|
212
228
|
"""Create a resource asynchronously using the provider.
|
|
213
229
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "anydi"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.28.0"
|
|
4
4
|
description = "Dependency Injection library"
|
|
5
5
|
authors = ["Anton Ruhlov <antonruhlov@gmail.com>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -38,15 +38,15 @@ python = "^3.8"
|
|
|
38
38
|
typing-extensions = "^4.12.1"
|
|
39
39
|
anyio = { version = "^3.6.2", optional = true }
|
|
40
40
|
mkdocs = { version = "^1.4.2", optional = true }
|
|
41
|
-
mkdocs-material = { version = "^9.5.
|
|
41
|
+
mkdocs-material = { version = "^9.5.29", optional = true }
|
|
42
42
|
|
|
43
43
|
[tool.poetry.extras]
|
|
44
44
|
docs = ["mkdocs", "mkdocs-material"]
|
|
45
45
|
async = ["anyio"]
|
|
46
46
|
|
|
47
47
|
[tool.poetry.group.dev.dependencies]
|
|
48
|
-
mypy = "^1.11.
|
|
49
|
-
ruff = "^0.
|
|
48
|
+
mypy = "^1.11.1"
|
|
49
|
+
ruff = "^0.6.1"
|
|
50
50
|
pytest = "^8.3.1"
|
|
51
51
|
pytest-cov = "^5.0.0"
|
|
52
52
|
fastapi = "^0.100.0"
|
|
@@ -64,7 +64,7 @@ anydi = "anydi.ext.pytest_plugin"
|
|
|
64
64
|
line-length = 88
|
|
65
65
|
|
|
66
66
|
[tool.ruff.lint]
|
|
67
|
-
select = ["A", "B", "C", "E", "F", "I", "W", "TID252", "T20", "UP"]
|
|
67
|
+
select = ["A", "B", "C", "E", "F", "I", "W", "TID252", "T20", "UP", "FURB"]
|
|
68
68
|
ignore = ["A003", "B008", "B009", "B010", "D104", "D107"]
|
|
69
69
|
|
|
70
70
|
[tool.ruff.lint.isort]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|