Skip to content

gh-148639: Implement PEP 800 (typing.disjoint_base) - #148640

Merged
JelleZijlstra merged 7 commits into
python:mainfrom
JelleZijlstra:pep800
Apr 18, 2026
Merged

JelleZijlstra merged 7 commits into
python:mainfrom
JelleZijlstra:pep800

Conversation

@JelleZijlstra

@JelleZijlstra JelleZijlstra commented Apr 16, 2026 •

Copy link
Copy Markdown
Member
Comment thread Doc/library/typing.rst Resolved
Comment thread Lib/typing.py Resolved
Comment thread Doc/library/typing.rst Resolved
JelleZijlstra and others added 3 commits April 16, 2026 05:51
Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>

@carljm carljm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

Comment thread Lib/typing.py Outdated
"""This decorator marks a class as a disjoint base.

Child classes of a disjoint base cannot inherit from other disjoint bases that are
not parent classes of the disjoint base.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to say "parent or child" here, not just "parent", similar to the documentation wording.

Comment thread Doc/library/typing.rst Outdated
Type checkers do not allow child classes of a disjoint base ``C`` to
inherit from other disjoint bases that are not parent or child classes of ``C``.

For example:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we either need a double colon here or a .. testcode:: directive, for this example to render properly?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, double colon works

@JelleZijlstra
JelleZijlstra merged commit 92164dc into python:main Apr 18, 2026
47 checks passed
@JelleZijlstra
JelleZijlstra deleted the pep800 branch April 18, 2026 02:20
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
)

Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants