-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed as not planned
Labels
bugmypy got something wrongmypy got something wrongtopic-typeguard-typeisTypeGuard / TypeIs / PEP 647 / PEP 742TypeGuard / TypeIs / PEP 647 / PEP 742
Description
Bug Report
Narrowing with a TypeGuard function doesn't work in conjunction with exhaustiveness checking using assert_never().
To Reproduce
https://mypy-play.net/?mypy=latest&python=3.11&gist=b6bc8609a83ff0538459d658c74f23ea
Expected Behavior
In the example, I expected the TypeGuard function to work no differently from the inlined type checks.
Actual Behavior
When using TypeGuard, the variable seems to be properly narrowed (revealed_type() within the branch is identical), but it seems somehow the result isn't recorded identically as the inlined checks. In the function using TypeGuard, the exhaustiveness check is not passing.
Your Environment
- Mypy version used: 1.3.0
- Mypy command-line flags: -
- Mypy configuration options from
mypy.ini(and other config files): - - Python version used: 3.11
eliax1996
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-typeguard-typeisTypeGuard / TypeIs / PEP 647 / PEP 742TypeGuard / TypeIs / PEP 647 / PEP 742