This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: issubclass documentation doesn't explain tuple semantic
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.11, Python 3.10, Python 3.9
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, joaozinho, kj, lukasz.langa, miss-islington, zkneupper
Priority: normal Keywords: easy, newcomer friendly, patch

Created on 2021-05-14 18:24 by joaozinho, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 26193 merged zkneupper, 2021-05-17 16:59
PR 28091 merged miss-islington, 2021-08-31 13:39
PR 28094 merged lukasz.langa, 2021-08-31 15:07
PR 28095 merged kj, 2021-08-31 15:17
PR 28097 merged miss-islington, 2021-08-31 16:01
Messages (7)
msg393684 - (view) Author: João Henrique Pimentel (joaozinho) Date: 2021-05-14 18:24
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"
msg393712 - (view) Author: Ken Jin (kj) * (Python committer) Date: 2021-05-15 12:24
I agree that this subtlety could be expressed better. Thanks for the catch! Would you like to work on this?

BTW, only Python 3.9 and higher are still receiving bugfixes (including doc fixes). The older versions are either security fixes only or end of life :).
msg400731 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-08-31 13:39
New changeset 08767c73b5bf1f28792d5fef7f41d52822a4989f by Zack Kneupper in branch 'main':
bpo-44135: Refine explanation of how passing tuples to issubclass() behaves (GH-26193)
msg400737 - (view) Author: miss-islington (miss-islington) Date: 2021-08-31 14:23
New changeset ab8fed88fc602282167f6459b43f2cf0c771f60a by Miss Islington (bot) in branch '3.10':
bpo-44135: Refine explanation of how passing tuples to issubclass() behaves (GH-26193)
msg400750 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-08-31 16:00
New changeset 5f66ad09ff2c51521e1512888cac84e0cc0907d4 by Łukasz Langa in branch '3.9':
bpo-44135: Refine explanation of how passing tuples to issubclass() behaves (GH-26193) (GH-28094)
msg400751 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-08-31 16:01
New changeset 9a7ec2fcdee2da9e080ca459d4c240776df72567 by Ken Jin in branch 'main':
bpo-44135: [docs] Fix inline markup (GH-28095)
msg400756 - (view) Author: miss-islington (miss-islington) Date: 2021-08-31 16:25
New changeset 8711b3d0ac89599fcd16edcb107169bb19a00737 by Miss Islington (bot) in branch '3.10':
bpo-44135: [docs] Fix inline markup (GH-28095)
Date User Action Args
2022-04-11 14:59:45adminsetgithub: 88301
2021-08-31 16:54:04lukasz.langasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-08-31 16:25:17miss-islingtonsetmessages: + msg400756
2021-08-31 16:01:25miss-islingtonsetpull_requests: + pull_request26540
2021-08-31 16:01:21lukasz.langasetmessages: + msg400751
2021-08-31 16:00:24lukasz.langasetmessages: + msg400750
2021-08-31 15:17:31kjsetpull_requests: + pull_request26538
2021-08-31 15:07:24lukasz.langasetpull_requests: + pull_request26537
2021-08-31 14:23:38miss-islingtonsetmessages: + msg400737
2021-08-31 13:39:28miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request26534
2021-08-31 13:39:23lukasz.langasetnosy: + lukasz.langa
messages: + msg400731
2021-05-17 16:59:38zkneuppersetkeywords: + patch
nosy: + zkneupper

pull_requests: + pull_request24810
stage: patch review
2021-05-15 12:24:32kjsetversions: - Python 3.6, Python 3.7, Python 3.8
nosy: + kj

messages: + msg393712

keywords: + easy, newcomer friendly
2021-05-14 18:24:27joaozinhocreate