You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The second parameter (classinfo) of the issubclass built-in function can be a Tuple and, starting from 3.10, it can be a Union Type as well.
The documentation states that in these cases "every entry in classinfo will be checked", but it doesn't explain if the check is AND (all) or OR (any). In contrast, the documentation of isinstance is clear: "return True if object is an instance of *any* of the types".
Here's a possible rewriting that reduces the odds of incorrect interpretations, based on the text of isinstance:
ORIGINAL: "in which case every entry in classinfo will be checked"
PROPOSAL: "in which case return True if class is a subclass of any entry in classinfo"
New changeset 08767c7 by Zack Kneupper in branch 'main': bpo-44135: Refine explanation of how passing tuples to issubclass() behaves (GH-26193) 08767c7
New changeset ab8fed8 by Miss Islington (bot) in branch '3.10': bpo-44135: Refine explanation of how passing tuples to issubclass() behaves (GH-26193) ab8fed8
New changeset 5f66ad0 by Łukasz Langa in branch '3.9': bpo-44135: Refine explanation of how passing tuples to issubclass() behaves (GH-26193) (GH-28094) 5f66ad0
Activity
joaozinho commentedon May 14, 2021
The second parameter (classinfo) of the issubclass built-in function can be a Tuple and, starting from 3.10, it can be a Union Type as well.
The documentation states that in these cases "every entry in classinfo will be checked", but it doesn't explain if the check is AND (all) or OR (any). In contrast, the documentation of isinstance is clear: "return True if object is an instance of *any* of the types".
Here's a possible rewriting that reduces the odds of incorrect interpretations, based on the text of isinstance:
ORIGINAL: "in which case every entry in classinfo will be checked"
PROPOSAL: "in which case return True if class is a subclass of any entry in classinfo"
4 remaining items
ambv commentedon Aug 31, 2021
New changeset 08767c7 by Zack Kneupper in branch 'main':
bpo-44135: Refine explanation of how passing tuples to issubclass() behaves (GH-26193)
08767c7
miss-islington commentedon Aug 31, 2021
New changeset ab8fed8 by Miss Islington (bot) in branch '3.10':
bpo-44135: Refine explanation of how passing tuples to issubclass() behaves (GH-26193)
ab8fed8
ambv commentedon Aug 31, 2021
New changeset 5f66ad0 by Łukasz Langa in branch '3.9':
bpo-44135: Refine explanation of how passing tuples to issubclass() behaves (GH-26193) (GH-28094)
5f66ad0
ambv commentedon Aug 31, 2021
New changeset 9a7ec2f by Ken Jin in branch 'main':
bpo-44135: [docs] Fix inline markup (GH-28095)
9a7ec2f
miss-islington commentedon Aug 31, 2021
New changeset 8711b3d by Miss Islington (bot) in branch '3.10':
bpo-44135: [docs] Fix inline markup (GH-28095)
8711b3d