-
-
Notifications
You must be signed in to change notification settings - Fork 34k
Closed as not planned
Closed as not planned
Copy link
Labels
pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtestsTests in the Lib/test dirTests in the Lib/test dir
Description
When statically analyzing and manually reviewing the code, I noticed a potential logic redundancy in /Lib/test/test_typechecks.py as follows:
def testSubclassBehavior(self):
self.assertEqual(issubclass(SubInt, Integer), True)
self.assertEqual(issubclass(SubInt, (Integer,)), True)
self.assertEqual(issubclass(SubInt, SubInt), True)
......
The check 'issubclass(SubInt, Integer)' is always True, as SubInt is explicitly a subtype of Integer. And The check 'issubclass(SubInt, SubInt)' is indeed a self-check, which will always evaluate to True as any class is considered a subclass of itself.
There are several similar subclass self-checking cases in /Lib/test/test_isinstance.py:
self.assertEqual(True, issubclass(Super, Super))
self.assertEqual(True, issubclass(Child, Child))
self.assertEqual(True, issubclass(AbstractSuper, AbstractSuper))
self.assertEqual(True, issubclass(AbstractChild, AbstractChild))
I am not sure whether the code is intentional or it is an issue warranting a refactoring or fixing.
Metadata
Metadata
Assignees
Labels
pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtestsTests in the Lib/test dirTests in the Lib/test dir