KEMBAR78
Fix for type narrowing of negative integer literals by gilesgc · Pull Request #17256 · python/mypy · GitHub
Skip to content

Conversation

gilesgc
Copy link
Contributor

@gilesgc gilesgc commented May 17, 2024

Fixes #10514
Fixes #17118

Negative integer literals were not being correctly handled in the type narrowing process, causing mypy errors such as "Statement is unreachable" despite the checked code being valid. This fix ensures that negative integer literals are properly considered in if-statements.

Fixes type narrowing for negative integer literals
@github-actions
Copy link
Contributor

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

@JelleZijlstra JelleZijlstra merged commit b74829e into python:master May 17, 2024
@JelleZijlstra
Copy link
Member

Great find, thank you!

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.

Missing type narrowing with Literal[-1] Type narrowing broken with negative integer literals

2 participants