Implement PEP 800 (@disjoint_base)#19678
Merged
JukkaL merged 6 commits intopython:masterfrom Aug 19, 2025
Merged
Conversation
https://peps.python.org/pep-0800/ - Recognize the @disjoint_base decorator - Error if a class definition has incompatible disjoint bases - Recognize that classes with incompatible disjoint bases cannot exist - Check in stubtest that @disjoint_base is correctly applied
JelleZijlstra
commented
Aug 18, 2025
| return analyze_var(name, defn.var, itype, mx) | ||
| typ = function_type(defn, mx.chk.named_type("builtins.function")) | ||
| is_trivial_self = False | ||
| if isinstance(defn, Decorator): |
Member
Author
There was a problem hiding this comment.
This condition can never match because we already check for Decorator a few lines up.
for more information, see https://pre-commit.ci
This comment has been minimized.
This comment has been minimized.
Member
Author
|
Primer analysis:
|
JukkaL
approved these changes
Aug 19, 2025
Collaborator
JukkaL
left a comment
There was a problem hiding this comment.
Thanks for implementing the feature! Looks good, just a few ideas about additional things to test.
|
|
||
| class C1: pass | ||
| class C2(Disjoint1, C1): pass | ||
| class C3(DisjointChild, Disjoint1): pass |
Collaborator
There was a problem hiding this comment.
Some ideas for additional test cases:
- Test reversed order of bases.
- Test with all three
Disjoint*bases. - Test a subclass of
C3/C2.
Member
Author
There was a problem hiding this comment.
Done, also added some more tests.
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: mypy (https://github.com/python/mypy)
+ mypy/checkmember.py:1488: error: Subclass of "FuncBase" and "Decorator" cannot exist: have distinct disjoint bases [unreachable]
+ mypy/checkmember.py:1488: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-unreachable for more info
+ mypy/checkmember.py:1490: error: Statement is unreachable [unreachable]
steam.py (https://github.com/Gobot1234/steam.py)
- steam/chat.py:161: error: Unused "type: ignore" comment [unused-ignore]
|
JukkaL
approved these changes
Aug 19, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://peps.python.org/pep-0800/
__slots__.