stubtest: flag redundant @disjoint_base decorators#19715
Merged
JelleZijlstra merged 4 commits intopython:masterfrom Aug 22, 2025
Merged
stubtest: flag redundant @disjoint_base decorators#19715JelleZijlstra merged 4 commits intopython:masterfrom
JelleZijlstra merged 4 commits intopython:masterfrom
Conversation
AlexWaygood
approved these changes
Aug 22, 2025
Comment on lines
+543
to
+559
| elif stub.is_final: | ||
| yield Error( | ||
| object_path, | ||
| "is marked as @disjoint_base, but also marked as @final; remove @disjoint_base", | ||
| stub, | ||
| runtime, | ||
| stub_desc=repr(stub), | ||
| ) | ||
| elif stub.is_enum and stub.enum_members: | ||
| yield Error( | ||
| object_path, | ||
| "is marked as @disjoint_base, but is an enum with members, which is implicitly final; " | ||
| "remove @disjoint_base", | ||
| stub, | ||
| runtime, | ||
| stub_desc=repr(stub), | ||
| ) |
Member
There was a problem hiding this comment.
these feel like linter issues more than correctness issues (so sort-of outside of stubtest's normal purview?), but it's obviously very easy to check for them here, so I think it makes sense
Member
Author
There was a problem hiding this comment.
Yeah we could also add these checks to flake8-pyi/ruff/whatever.
Comment on lines
-1410
to
+1411
| from typing_extensions import disjoint_base | ||
| if sys.version_info >= (3, 12): | ||
| class BytesEnum(bytes, enum.Enum): | ||
| a = b'foo' | ||
| else: | ||
| @disjoint_base | ||
| class BytesEnum(bytes, enum.Enum): | ||
| a = b'foo' | ||
| class BytesEnum(bytes, enum.Enum): | ||
| a = b'foo' |
Member
There was a problem hiding this comment.
one way to keep the test as it was before would be to just have it be an "abstract enum" that doesn't have any members
Member
Author
There was a problem hiding this comment.
I complicated this test in a previous PR for disjoint_base, so I don't feel bad about going back to the previous less complicated version.
Co-authored-by: Alex Waygood <[email protected]>
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.
No description provided.