mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-07-03 20:03:32 +03:00
better subclass check
This commit is contained in:
parent
aa11b0bb82
commit
586ba89047
|
@ -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 isinstance(instance, starlette.requests.Request)
|
and self._is_subclass(instance, starlette.requests.Request)
|
||||||
|
|
||||||
|
def _is_subclass(self, instance: type, cls: type) -> bool:
|
||||||
|
try:
|
||||||
|
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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user