KEMBAR78
stubtest: flag redundant @disjoint_base decorators by JelleZijlstra · Pull Request #19715 · python/mypy · GitHub
Skip to content

Conversation

JelleZijlstra
Copy link
Member

No description provided.

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

looks good!

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),
)
Copy link
Member

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

Copy link
Member Author

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.

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'
Copy link
Member

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

Copy link
Member Author

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>
@JelleZijlstra JelleZijlstra merged commit fa7fa7f into python:master Aug 22, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants