Skip to content

Commit 5a1aef9

Browse files
committed
Merge branch 'release/4.48.2'
2 parents 7df26d1 + 5acddac commit 5a1aef9

File tree

16 files changed

+276
-28
lines changed

16 files changed

+276
-28
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
VERSION := $(shell python setup.py --version)
22

33
export COVERAGE_RCFILE := pyproject.toml
4+
export CIBW_ENVIRONMENT_PASS_LINUX := CFLAGS PIP_CONFIG_SETTINGS DEPENDENCY_INJECTOR_LIMITED_API
5+
export PIP_CONFIG_SETTINGS ?= build_ext=-j4
6+
export DEPENDENCY_INJECTOR_LIMITED_API ?= 1
7+
export CFLAGS ?= -g0
48

59
clean:
610
# Clean sources
@@ -63,3 +67,6 @@ publish:
6367
# Create and upload tag
6468
git tag -a $(VERSION) -m 'version $(VERSION)'
6569
git push --tags
70+
71+
wheels:
72+
cibuildwheel --output-dir wheelhouse

docs/main/changelog.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ that were made in every particular version.
77
From version 0.7.6 *Dependency Injector* framework strictly
88
follows `Semantic versioning`_
99

10+
4.48.2
11+
------
12+
13+
- Add ``warn_unresolved=True`` to ``WiringConfiguration`` and ``container.wire()``
14+
to produce warnings on unresolved string identifiers.
15+
- ABI3 wheels are now built only for CPython version >=3.10 (see issue `#919 <https://github.com/ets-labs/python-dependency-injector/issues/919>`_).
16+
1017
4.48.1
1118
------
1219

docs/providers/singleton.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ factories:
3333
- :ref:`factory-specialize-provided-type`
3434
- :ref:`abstract-factory`
3535

36-
``Singleton`` provider scope is tied to the container. Two different containers will provider
36+
``Singleton`` provider scope is tied to the container. Two different containers will provide
3737
two different singleton objects:
3838

3939
.. literalinclude:: ../../examples/providers/singleton_multiple_containers.py

docs/wiring.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,32 @@ To inject a container use special identifier ``<container>``:
251251
def foo(container: Container = Provide["<container>"]) -> None:
252252
...
253253
254+
Caveats
255+
~~~~~~~
256+
257+
While using string identifiers you may not notice a typo in the identifier until the code is executed.
258+
In order to aid with catching such errors early, you may pass `warn_unresolved=True` to the ``wire`` method and/or :class:`WiringConfiguration`:
259+
260+
.. code-block:: python
261+
:emphasize-lines: 4
262+
263+
class Container(containers.DeclarativeContainer):
264+
wiring_config = containers.WiringConfiguration(
265+
modules=["yourapp.module"],
266+
warn_unresolved=True,
267+
)
268+
269+
Or:
270+
271+
.. code-block:: python
272+
:emphasize-lines: 4
273+
274+
container = Container()
275+
container.wire(
276+
modules=["yourapp.module"],
277+
warn_unresolved=True,
278+
)
279+
254280
255281
Making injections into modules and class attributes
256282
---------------------------------------------------

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["setuptools", "Cython>=3.1.1"]
2+
requires = ["setuptools", "Cython>=3.1.4"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
@@ -54,7 +54,7 @@ classifiers = [
5454
dynamic = ["version"]
5555
dependencies = [
5656
# typing.Annotated since v3.9
57-
# typing.Self since v3.11
57+
# typing.Self and typing.assert_never since v3.11
5858
"typing-extensions; python_version<'3.11'",
5959
]
6060

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cython==3.1.1
1+
cython==3.1.4
22
setuptools
33
pytest
44
pytest-asyncio

setup.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import os
44
import sys
5+
import sysconfig
56

67
from Cython.Build import cythonize
78
from Cython.Compiler import Options
@@ -11,6 +12,8 @@
1112
limited_api = (
1213
os.environ.get("DEPENDENCY_INJECTOR_LIMITED_API") == "1"
1314
and sys.implementation.name == "cpython"
15+
and sys.version_info >= (3, 10)
16+
and not sysconfig.get_config_var("Py_GIL_DISABLED")
1417
)
1518
defined_macros = []
1619
options = {}
@@ -34,8 +37,8 @@
3437

3538
if limited_api:
3639
options.setdefault("bdist_wheel", {})
37-
options["bdist_wheel"]["py_limited_api"] = "cp38"
38-
defined_macros.append(("Py_LIMITED_API", "0x03080000"))
40+
options["bdist_wheel"]["py_limited_api"] = "cp310"
41+
defined_macros.append(("Py_LIMITED_API", "0x030A0000"))
3942

4043
setup(
4144
options=options,

src/dependency_injector/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Top-level package."""
22

3-
__version__ = "4.48.1"
3+
__version__ = "4.48.2"
44
"""Version number.
55
66
:type: str

src/dependency_injector/containers.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class Container:
7272
modules: Optional[Iterable[Any]] = None,
7373
packages: Optional[Iterable[Any]] = None,
7474
from_package: Optional[str] = None,
75+
warn_unresolved: bool = False,
7576
) -> None: ...
7677
def unwire(self) -> None: ...
7778
def init_resources(self, resource_type: Type[Resource[Any]] = Resource) -> Optional[Awaitable[None]]: ...

src/dependency_injector/containers.pyx

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,31 @@ from .wiring import wire, unwire
2020
class WiringConfiguration:
2121
"""Container wiring configuration."""
2222

23-
def __init__(self, modules=None, packages=None, from_package=None, auto_wire=True, keep_cache=False):
23+
def __init__(
24+
self,
25+
modules=None,
26+
packages=None,
27+
from_package=None,
28+
auto_wire=True,
29+
keep_cache=False,
30+
warn_unresolved=False,
31+
):
2432
self.modules = [*modules] if modules else []
2533
self.packages = [*packages] if packages else []
2634
self.from_package = from_package
2735
self.auto_wire = auto_wire
2836
self.keep_cache = keep_cache
37+
self.warn_unresolved = warn_unresolved
2938

3039
def __deepcopy__(self, memo=None):
31-
return self.__class__(self.modules, self.packages, self.from_package, self.auto_wire, self.keep_cache)
40+
return self.__class__(
41+
self.modules,
42+
self.packages,
43+
self.from_package,
44+
self.auto_wire,
45+
self.keep_cache,
46+
self.warn_unresolved,
47+
)
3248

3349

3450
class Container:
@@ -259,7 +275,14 @@ class DynamicContainer(Container):
259275
"""Check if auto wiring is needed."""
260276
return self.wiring_config.auto_wire is True
261277

262-
def wire(self, modules=None, packages=None, from_package=None, keep_cache=None):
278+
def wire(
279+
self,
280+
modules=None,
281+
packages=None,
282+
from_package=None,
283+
keep_cache=None,
284+
warn_unresolved=False,
285+
):
263286
"""Wire container providers with provided packages and modules.
264287
265288
:rtype: None
@@ -298,6 +321,7 @@ class DynamicContainer(Container):
298321
modules=modules,
299322
packages=packages,
300323
keep_cache=keep_cache,
324+
warn_unresolved=warn_unresolved,
301325
)
302326

303327
if modules:

0 commit comments

Comments
 (0)