Skip to content

Commit c287777

Browse files
committed
Refactor + add tests to ets-labs#569
1 parent 8fe00bc commit c287777

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/dependency_injector/wiring.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -321,13 +321,7 @@ def _is_werkzeug_local_proxy(self, instance: object) -> bool:
321321
def _is_starlette_request_cls(self, instance: object) -> bool:
322322
return starlette \
323323
and isinstance(instance, type) \
324-
and self._safe_is_subclass(instance, starlette.requests.Request)
325-
326-
def _safe_is_subclass(self, instance: type, cls: type) -> bool:
327-
try:
328-
return issubclass(instance, cls)
329-
except TypeError:
330-
return False
324+
and _safe_is_subclass(instance, starlette.requests.Request)
331325

332326
def _is_builtin(self, instance: object) -> bool:
333327
return inspect.isbuiltin(instance)
@@ -685,6 +679,13 @@ def _is_declarative_container(instance: Any) -> bool:
685679
and getattr(instance, "declarative_parent", None) is None)
686680

687681

682+
def _safe_is_subclass(instance: Any, cls: Type) -> bool:
683+
try:
684+
return issubclass(instance, cls)
685+
except TypeError:
686+
return False
687+
688+
688689
class Modifier:
689690

690691
def modify(

tests/unit/samples/wiring/imports.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
if "pypy" not in sys.version.lower():
66
import numpy # noqa
77
from numpy import * # noqa
8-
from numpy.typing import * # noqa
8+
if sys.version_info >= (3, 7):
9+
from numpy.typing import * # noqa
910

1011
import scipy # noqa
1112
from scipy import * # noqa

0 commit comments

Comments
 (0)