issubtype(C, B) -> bool Return whether C is a class and if it is a subclass of class B. When using a tuple as the second argument issubtype(X, (A, B, ...)), is a shortcut for issubtype(X, A) or issubtype(X, B) or ... (etc.).
(x, # type: Any
t, # type: Union[type, str]
)
| 91 | |
| 92 | |
| 93 | def issubtype(x, # type: Any |
| 94 | t, # type: Union[type, str] |
| 95 | ): |
| 96 | # type: (...) -> bool |
| 97 | """issubtype(C, B) -> bool |
| 98 | |
| 99 | Return whether C is a class and if it is a subclass of class B. |
| 100 | When using a tuple as the second argument issubtype(X, (A, B, ...)), |
| 101 | is a shortcut for issubtype(X, A) or issubtype(X, B) or ... (etc.). |
| 102 | """ |
| 103 | if isinstance(t, str): |
| 104 | return t in (z.__name__ for z in x.__bases__) |
| 105 | if isinstance(x, type) and issubclass(x, t): |
| 106 | return True |
| 107 | return False |
| 108 | |
| 109 | |
| 110 | _Decimal = Union[Decimal, int] |
no outgoing calls
no test coverage detected