-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Closed
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
These line are problematic:
cpython/Lib/test/test_typing.py
Lines 2013 to 2020 in 264f4af
with self.assertRaises(TypeError): | |
self.assertIsInstance(f, Callable[[], None]) | |
with self.assertRaises(TypeError): | |
self.assertIsInstance(f, Callable[[], Any]) | |
with self.assertRaises(TypeError): | |
self.assertNotIsInstance(None, Callable[[], None]) | |
with self.assertRaises(TypeError): | |
self.assertNotIsInstance(None, Callable[[], Any]) |
Why?
self.assertIsInstance
gives the intention that this will returnTrue
self.assertNotIsInstance
gives the intention that this will returnFalse
- Technically
self.assert[Not]IsInstance
can raiseTypeError
on its own (but not in practice)
However, this will always fail with TypeError
.
I propose to use just isintance
instead.
Linked PRs
Metadata
Metadata
Assignees
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error