Skip to content

Conversation

@hauntsaninja
Copy link
Collaborator

@hauntsaninja hauntsaninja commented Jan 28, 2026

#20660 is proving a little tricky, so I'm going to try and land some of the diff independently.

I think of this as mostly a cleanup PR, but it does change a few semantics. In particular, the places where we previously added a {} to the list of type maps used to clobber some narrowing

continue
target_type = operand_types[j]
if should_coerce_literals:
# TODO: doing this prevents narrowing a single-member Enum to literal
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This comment was on the wrong coerce_to_literal call

(In general, it's a very minor thing — there are more important other improvements to be made to narrowing — so I moved this text into the relevant test)

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

static-frame (https://github.com/static-frame/static-frame)
+ static_frame/core/type_blocks.py:1633: error: Unused "type: ignore" comment  [unused-ignore]
+ static_frame/core/type_blocks.py:1634: error: Unused "type: ignore" comment  [unused-ignore]
+ static_frame/core/type_blocks.py:1759: error: Unused "type: ignore" comment  [unused-ignore]
+ static_frame/core/type_blocks.py:1760: error: Unused "type: ignore" comment  [unused-ignore]

@hauntsaninja hauntsaninja changed the title Further tweaks and cleanup of narrowing Preserve some lost narrowing, cleanup Jan 29, 2026
@hauntsaninja
Copy link
Collaborator Author

static-frame changes are correct

hauntsaninja added a commit to hauntsaninja/mypy that referenced this pull request Jan 29, 2026
I introduced some more instances of python#12320

Noticed while analysing python#20674
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.

1 participant