Title: issubclass documentation doesn't explain tuple semantic
Type: enhancement Stage: patch review
Components: Documentation Versions: Python 3.11, Python 3.10, Python 3.9
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, joaozinho, kj, zkneupper
Priority: normal Keywords: easy, newcomer friendly, patch

Created on 2021-05-14 18:24 by joaozinho, last changed 2021-05-17 16:59 by zkneupper.

Pull Requests
URL Status Linked Edit
PR 26193 open zkneupper, 2021-05-17 16:59
Messages (2)
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 triager) 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 :).
Date User Action Args
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