appctx 0.2.2__tar.gz → 0.3__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.
- {appctx-0.2.2 → appctx-0.3}/PKG-INFO +2 -5
- {appctx-0.2.2 → appctx-0.3}/pyproject.toml +7 -7
- {appctx-0.2.2 → appctx-0.3}/src/appctx/__init__.py +3 -3
- {appctx-0.2.2 → appctx-0.3}/src/appctx/container.py +6 -3
- {appctx-0.2.2 → appctx-0.3}/src/appctx.egg-info/PKG-INFO +2 -5
- appctx-0.3/src/appctx.egg-info/requires.txt +5 -0
- {appctx-0.2.2 → appctx-0.3}/tests/test_post_construct.py +1 -1
- appctx-0.2.2/src/appctx.egg-info/requires.txt +0 -8
- {appctx-0.2.2 → appctx-0.3}/README.md +0 -0
- {appctx-0.2.2 → appctx-0.3}/setup.cfg +0 -0
- {appctx-0.2.2 → appctx-0.3}/src/appctx/decorators.py +0 -0
- {appctx-0.2.2 → appctx-0.3}/src/appctx/py.typed +0 -0
- {appctx-0.2.2 → appctx-0.3}/src/appctx.egg-info/SOURCES.txt +0 -0
- {appctx-0.2.2 → appctx-0.3}/src/appctx.egg-info/dependency_links.txt +0 -0
- {appctx-0.2.2 → appctx-0.3}/src/appctx.egg-info/top_level.txt +0 -0
- {appctx-0.2.2 → appctx-0.3}/tests/test_container.py +0 -0
- {appctx-0.2.2 → appctx-0.3}/tests/test_decorators.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: appctx
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3
|
|
4
4
|
Summary: Spring style dependency injection for python
|
|
5
5
|
Author-email: wssccc <wssccc@qq.com>
|
|
6
6
|
License: MIT
|
|
@@ -20,10 +20,7 @@ Description-Content-Type: text/markdown
|
|
|
20
20
|
Provides-Extra: dev
|
|
21
21
|
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
22
22
|
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
23
|
-
Requires-Dist:
|
|
24
|
-
Requires-Dist: flake8>=5.0; extra == "dev"
|
|
25
|
-
Requires-Dist: mypy>=1.0; extra == "dev"
|
|
26
|
-
Requires-Dist: isort>=5.0; extra == "dev"
|
|
23
|
+
Requires-Dist: ruff>=0.4.0; extra == "dev"
|
|
27
24
|
|
|
28
25
|
# AppCtx
|
|
29
26
|
|
|
@@ -24,10 +24,7 @@ classifiers = [
|
|
|
24
24
|
dev = [
|
|
25
25
|
"pytest>=7.0",
|
|
26
26
|
"pytest-cov>=4.0",
|
|
27
|
-
"
|
|
28
|
-
"flake8>=5.0",
|
|
29
|
-
"mypy>=1.0",
|
|
30
|
-
"isort>=5.0"
|
|
27
|
+
"ruff>=0.4.0"
|
|
31
28
|
]
|
|
32
29
|
|
|
33
30
|
[project.urls]
|
|
@@ -45,9 +42,12 @@ where = ["src"]
|
|
|
45
42
|
[tool.setuptools.package-data]
|
|
46
43
|
appctx = ["py.typed"]
|
|
47
44
|
|
|
48
|
-
[tool.
|
|
45
|
+
[tool.ruff]
|
|
49
46
|
line-length = 88
|
|
50
|
-
target-version =
|
|
47
|
+
target-version = "py38"
|
|
48
|
+
|
|
49
|
+
[tool.ruff.lint]
|
|
50
|
+
select = ["E", "F", "W", "I"]
|
|
51
51
|
|
|
52
52
|
[tool.flake8]
|
|
53
53
|
max-line-length = 88
|
|
@@ -59,7 +59,7 @@ multi_line_output = 3
|
|
|
59
59
|
line_length = 88
|
|
60
60
|
|
|
61
61
|
[tool.mypy]
|
|
62
|
-
python_version = "3.
|
|
62
|
+
python_version = "3.8"
|
|
63
63
|
warn_return_any = true
|
|
64
64
|
warn_unused_configs = true
|
|
65
65
|
disallow_untyped_defs = true
|
|
@@ -5,13 +5,13 @@ This package provides a lightweight dependency injection container
|
|
|
5
5
|
inspired by the Spring Framework for Java.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
-
__version__ = "0.
|
|
8
|
+
__version__ = "0.3"
|
|
9
9
|
__author__ = "wssccc"
|
|
10
10
|
__email__ = "wssccc@qq.com"
|
|
11
11
|
|
|
12
12
|
# Import main API for convenience
|
|
13
|
-
from .container import ApplicationContext
|
|
14
|
-
from .decorators import post_construct
|
|
13
|
+
from appctx.container import ApplicationContext
|
|
14
|
+
from appctx.decorators import post_construct
|
|
15
15
|
|
|
16
16
|
# Create default application context
|
|
17
17
|
_default_context = ApplicationContext()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import inspect
|
|
2
2
|
from collections import defaultdict
|
|
3
|
-
from typing import Any, Dict, List, Type, TypeVar,
|
|
3
|
+
from typing import Any, Dict, List, Optional, Tuple, Type, TypeVar, Union, overload
|
|
4
4
|
|
|
5
5
|
T = TypeVar("T")
|
|
6
6
|
|
|
@@ -36,7 +36,10 @@ class ApplicationContext:
|
|
|
36
36
|
return self.bean_types_map[_type]
|
|
37
37
|
|
|
38
38
|
def _instantiate(self, bean_def: Any) -> bool:
|
|
39
|
-
"""Instantiate a bean definition.
|
|
39
|
+
"""Instantiate a bean definition.
|
|
40
|
+
|
|
41
|
+
Returns True on success, False if dependencies are not ready.
|
|
42
|
+
"""
|
|
40
43
|
is_class = inspect.isclass(bean_def)
|
|
41
44
|
if is_class:
|
|
42
45
|
spec = inspect.getfullargspec(bean_def.__init__)
|
|
@@ -89,7 +92,7 @@ class ApplicationContext:
|
|
|
89
92
|
|
|
90
93
|
def _resolve_dependencies(
|
|
91
94
|
self, spec: inspect.FullArgSpec
|
|
92
|
-
) -> Optional[
|
|
95
|
+
) -> Optional[Tuple[List[Any], Dict[str, Any]]]:
|
|
93
96
|
"""Convert function signature to arguments and keyword arguments.
|
|
94
97
|
|
|
95
98
|
Resolution strategy:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: appctx
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3
|
|
4
4
|
Summary: Spring style dependency injection for python
|
|
5
5
|
Author-email: wssccc <wssccc@qq.com>
|
|
6
6
|
License: MIT
|
|
@@ -20,10 +20,7 @@ Description-Content-Type: text/markdown
|
|
|
20
20
|
Provides-Extra: dev
|
|
21
21
|
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
22
22
|
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
23
|
-
Requires-Dist:
|
|
24
|
-
Requires-Dist: flake8>=5.0; extra == "dev"
|
|
25
|
-
Requires-Dist: mypy>=1.0; extra == "dev"
|
|
26
|
-
Requires-Dist: isort>=5.0; extra == "dev"
|
|
23
|
+
Requires-Dist: ruff>=0.4.0; extra == "dev"
|
|
27
24
|
|
|
28
25
|
# AppCtx
|
|
29
26
|
|
|
@@ -97,7 +97,7 @@ def test_post_construct_with_dependencies():
|
|
|
97
97
|
|
|
98
98
|
def test_post_construct_with_global_decorator():
|
|
99
99
|
"""Test post_construct with the global bean decorator."""
|
|
100
|
-
from appctx import post_construct, refresh
|
|
100
|
+
from appctx import get_bean, post_construct, refresh
|
|
101
101
|
|
|
102
102
|
class GlobalService:
|
|
103
103
|
def __init__(self):
|
|
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
|