-
-
Notifications
You must be signed in to change notification settings - Fork 3k
stubtest: flag redundant @disjoint_base decorators #19715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stubtest: flag redundant @disjoint_base decorators #19715
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good!
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), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we could also add these checks to flake8-pyi/ruff/whatever.
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' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <Alex.Waygood@Gmail.com>
No description provided.