Skip to content

Commit ee89476

Browse files
committed
Merge branch 'release/4.29.2' into master
2 parents b3bcf60 + e42d7dc commit ee89476

File tree

6 files changed

+55
-3
lines changed

6 files changed

+55
-3
lines changed

docs/main/changelog.rst

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

10+
4.29.2
11+
------
12+
- Fix wiring to not crash on missing signatures.
13+
See issue: `#420 <https://github.com/ets-labs/python-dependency-injector/issues/420>`_.
14+
Thanks to `@Balthus1989 <https://github.com/Balthus1989>`_ for reporting the issue.
15+
1016
4.29.1
1117
------
1218
- Fix recursive copying issue in ``Delegate`` provider.

requirements-dev.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@ pyyaml
1010
httpx
1111
fastapi
1212
pydantic
13+
numpy
14+
scipy
1315

1416
-r requirements-ext.txt

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.29.1'
3+
__version__ = '4.29.2'
44
"""Version number.
55
66
:type: str

src/dependency_injector/wiring.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ def is_excluded(self, instance: object) -> bool:
298298
return True
299299
elif self._is_starlette_request_cls(instance):
300300
return True
301+
elif self._is_builtin(instance):
302+
return True
301303
else:
302304
return False
303305

@@ -309,6 +311,9 @@ def _is_starlette_request_cls(self, instance: object) -> bool:
309311
and isinstance(instance, type) \
310312
and issubclass(instance, starlette.requests.Request)
311313

314+
def _is_builtin(self, instance: object) -> bool:
315+
return inspect.isbuiltin(instance)
316+
312317

313318
def wire( # noqa: C901
314319
container: Container,
@@ -476,7 +481,7 @@ def _unpatch_attribute(patched: PatchedAttribute) -> None:
476481
setattr(patched.member, patched.name, patched.marker)
477482

478483

479-
def _fetch_reference_injections(
484+
def _fetch_reference_injections( # noqa: C901
480485
fn: Callable[..., Any],
481486
) -> Tuple[Dict[str, Any], Dict[str, Any]]:
482487
# Hotfix, see:
@@ -488,7 +493,15 @@ def _fetch_reference_injections(
488493
)):
489494
fn = fn.__init__
490495

491-
signature = inspect.signature(fn)
496+
try:
497+
signature = inspect.signature(fn)
498+
except ValueError as exception:
499+
if 'no signature found' in str(exception):
500+
return {}, {}
501+
elif 'not supported by signature' in str(exception):
502+
return {}, {}
503+
else:
504+
raise exception
492505

493506
injections = {}
494507
closing = {}
@@ -874,9 +887,13 @@ def exec_module(self, module):
874887
super().exec_module(module)
875888
loader.wire_module(module)
876889

890+
class ExtensionFileLoader(importlib.machinery.ExtensionFileLoader):
891+
...
892+
877893
loader_details = [
878894
(SourcelessFileLoader, importlib.machinery.BYTECODE_SUFFIXES),
879895
(SourceFileLoader, importlib.machinery.SOURCE_SUFFIXES),
896+
(ExtensionFileLoader, importlib.machinery.EXTENSION_SUFFIXES),
880897
]
881898

882899
self._path_hook = importlib.machinery.FileFinder.path_hook(*loader_details)

tests/unit/samples/wiringsamples/module.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Test module for wiring."""
22

33
from decimal import Decimal
4+
import sys
45
from typing import Callable
56

67
from dependency_injector import providers
@@ -128,3 +129,16 @@ def test_class_decorator(service: Service = Provide[Container.service]):
128129

129130
def test_container(container: Container = Provide[Container]):
130131
return container.service()
132+
133+
134+
# Import tests
135+
136+
if 'pypy' not in sys.version.lower():
137+
import numpy # noqa
138+
from numpy import * # noqa
139+
140+
import scipy # noqa
141+
from scipy import * # noqa
142+
143+
import builtins # noqa
144+
from builtins import * # noqa

tox.ini

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ deps=
88
typing_extensions
99
httpx
1010
fastapi
11+
numpy
12+
scipy
1113
extras=
1214
yaml
1315
pydantic
@@ -62,6 +64,17 @@ extras=
6264
commands=
6365
python -m unittest discover -s tests/unit -p test_*_py2_py3.py
6466

67+
[testenv:pypy3]
68+
deps=
69+
httpx
70+
fastapi
71+
extras=
72+
yaml
73+
flask
74+
commands=
75+
python -m unittest discover -s tests/unit -p test_*_py2_py3.py
76+
77+
6578
[testenv:pylint]
6679
deps=
6780
pylint

0 commit comments

Comments
 (0)