mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-15 16:27:08 +08:00
unittest: Use a recursive type alias for assertIsInstance (#9770)
This commit is contained in:
@@ -68,10 +68,13 @@ class SkipTest(Exception):
|
||||
|
||||
class _SupportsAbsAndDunderGE(SupportsDunderGE[Any], SupportsAbs[Any], Protocol): ...
|
||||
|
||||
# Keep this alias in sync with builtins._ClassInfo
|
||||
# We can't import it from builtins or pytype crashes,
|
||||
# due to the fact that pytype uses a custom builtins stub rather than typeshed's builtins stub
|
||||
if sys.version_info >= (3, 10):
|
||||
_IsInstanceClassInfo: TypeAlias = type | UnionType | tuple[type | UnionType | tuple[Any, ...], ...]
|
||||
_ClassInfo: TypeAlias = type | UnionType | tuple[_ClassInfo, ...]
|
||||
else:
|
||||
_IsInstanceClassInfo: TypeAlias = type | tuple[type | tuple[Any, ...], ...]
|
||||
_ClassInfo: TypeAlias = type | tuple[_ClassInfo, ...]
|
||||
|
||||
class TestCase:
|
||||
failureException: type[BaseException]
|
||||
@@ -107,8 +110,8 @@ class TestCase:
|
||||
def assertIsNotNone(self, obj: object, msg: Any = None) -> None: ...
|
||||
def assertIn(self, member: Any, container: Iterable[Any] | Container[Any], msg: Any = None) -> None: ...
|
||||
def assertNotIn(self, member: Any, container: Iterable[Any] | Container[Any], msg: Any = None) -> None: ...
|
||||
def assertIsInstance(self, obj: object, cls: _IsInstanceClassInfo, msg: Any = None) -> None: ...
|
||||
def assertNotIsInstance(self, obj: object, cls: _IsInstanceClassInfo, msg: Any = None) -> None: ...
|
||||
def assertIsInstance(self, obj: object, cls: _ClassInfo, msg: Any = None) -> None: ...
|
||||
def assertNotIsInstance(self, obj: object, cls: _ClassInfo, msg: Any = None) -> None: ...
|
||||
@overload
|
||||
def assertGreater(self, a: SupportsDunderGT[_T], b: _T, msg: Any = None) -> None: ...
|
||||
@overload
|
||||
|
||||
Reference in New Issue
Block a user