569 fix numpy typing wiring (#570)

* change erroneous issubclass call to isinstance

* import numpy.typing in tests

* better subclass check

* fix return
This commit is contained in:
Vlad Fisher 2022-03-28 01:11:04 +07:00 committed by GitHub
parent c26b260c73
commit 8fe00bcff0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -321,7 +321,13 @@ class InspectFilter:
def _is_starlette_request_cls(self, instance: object) -> bool: def _is_starlette_request_cls(self, instance: object) -> bool:
return starlette \ return starlette \
and isinstance(instance, type) \ 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: def _is_builtin(self, instance: object) -> bool:
return inspect.isbuiltin(instance) return inspect.isbuiltin(instance)

View File

@ -5,6 +5,7 @@ import sys
if "pypy" not in sys.version.lower(): if "pypy" not in sys.version.lower():
import numpy # noqa import numpy # noqa
from numpy import * # noqa from numpy import * # noqa
from numpy.typing import * # noqa
import scipy # noqa import scipy # noqa
from scipy import * # noqa from scipy import * # noqa