Skip to content

Better support for SomeEnum.item == some_literal - #19594

Draft
sterliakov wants to merge 13 commits into
python:masterfrom
sterliakov:bugfix/gh-19576-enum-comparison-overlap
Draft

Better support for SomeEnum.item == some_literal#19594
sterliakov wants to merge 13 commits into
python:masterfrom
sterliakov:bugfix/gh-19576-enum-comparison-overlap

Conversation

@sterliakov

@sterliakovsterliakov commented Aug 4, 2025

Copy link
Copy Markdown
Collaborator

Fixes#19576.
Fixes#16327.
Fixes#17162.
Fixes#19753.

This needs more feedback: is the logic I propose reasonable? Do we want to be stricter and reject such comparisons altogether? Or maybe only reject them if values are incompatible?

@github-actions

This comment has been minimized.

@A5rocksA5rocks left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I was a bit confused about this in the original issue too

Comment threadtest-data/unit/check-enum.test Outdated
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@sterliakov
sterliakov marked this pull request as ready for review August 28, 2025 13:51

@A5rocksA5rocks left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I tried my listed use case against current mypy, which was wrong: #19753

This looks good to me though

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@sterliakov

Copy link
Copy Markdown
CollaboratorAuthor

Draft until I can address #20142 (comment)

@A5rocks

Copy link
Copy Markdown
Collaborator

Probably this has to be recreated to work with new narrowing... and half of the listed issues are closed now!

(not really sure though, I completely forgot what this PR does :/)

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

2 participants

@sterliakov@A5rocks