Skip to content

fix callable enum narrowing - #21946

Merged
ilevkivskyi merged 1 commit into
python:masterfrom
EmmanuelNiyonshuti:callable-enums
Sep 8, 2026
Merged

fix callable enum narrowing#21946
ilevkivskyi merged 1 commit into
python:masterfrom
EmmanuelNiyonshuti:callable-enums

Conversation

@EmmanuelNiyonshuti

@EmmanuelNiyonshuti EmmanuelNiyonshuti commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Fixes ##17222

Narrowing an enum to a literal(with == or match) gives a LiteralType, which was not being checked when type checking a call. This PR add a LiteralType branch to check_call that will delegate to its fallback instance.

@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

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

scipy (https://github.com/scipy/scipy)
- scipy/conftest.py:678: error: "Literal['skip']" not callable  [misc]
+ scipy/conftest.py:678: error: "str" not callable  [operator]
- scipy/conftest.py:678: error: "Literal['xfail']" not callable  [misc]

@ilevkivskyi
ilevkivskyi merged commit cb02891 into python:master Sep 8, 2026
25 checks passed
@EmmanuelNiyonshuti
EmmanuelNiyonshuti deleted the callable-enums branch September 9, 2026 04:38
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.

3 participants