Skip to content

569 fix numpy typing wiring #570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/dependency_injector/wiring.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,13 @@ def _is_werkzeug_local_proxy(self, instance: object) -> bool:
def _is_starlette_request_cls(self, instance: object) -> bool:
return starlette \
and isinstance(instance, type) \
and issubclass(instance, starlette.requests.Request)
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

def _is_builtin(self, instance: object) -> bool:
return inspect.isbuiltin(instance)
Expand Down
1 change: 1 addition & 0 deletions tests/unit/samples/wiring/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
if "pypy" not in sys.version.lower():
import numpy # noqa
from numpy import * # noqa
from numpy.typing import * # noqa

import scipy # noqa
from scipy import * # noqa
Expand Down