mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 01:26:51 +03:00
Refactor + add tests to #569
This commit is contained in:
parent
8fe00bcff0
commit
c2877777af
|
@ -321,13 +321,7 @@ class InspectFilter:
|
|||
def _is_starlette_request_cls(self, instance: object) -> bool:
|
||||
return starlette \
|
||||
and isinstance(instance, type) \
|
||||
and self._safe_is_subclass(instance, starlette.requests.Request)
|
||||
|
||||
def _safe_is_subclass(self, instance: type, cls: type) -> bool:
|
||||
try:
|
||||
return issubclass(instance, cls)
|
||||
except TypeError:
|
||||
return False
|
||||
and _safe_is_subclass(instance, starlette.requests.Request)
|
||||
|
||||
def _is_builtin(self, instance: object) -> bool:
|
||||
return inspect.isbuiltin(instance)
|
||||
|
@ -685,6 +679,13 @@ def _is_declarative_container(instance: Any) -> bool:
|
|||
and getattr(instance, "declarative_parent", None) is None)
|
||||
|
||||
|
||||
def _safe_is_subclass(instance: Any, cls: Type) -> bool:
|
||||
try:
|
||||
return issubclass(instance, cls)
|
||||
except TypeError:
|
||||
return False
|
||||
|
||||
|
||||
class Modifier:
|
||||
|
||||
def modify(
|
||||
|
|
|
@ -5,7 +5,8 @@ import sys
|
|||
if "pypy" not in sys.version.lower():
|
||||
import numpy # noqa
|
||||
from numpy import * # noqa
|
||||
from numpy.typing import * # noqa
|
||||
if sys.version_info >= (3, 7):
|
||||
from numpy.typing import * # noqa
|
||||
|
||||
import scipy # noqa
|
||||
from scipy import * # noqa
|
||||
|
|
Loading…
Reference in New Issue
Block a user