You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromtyping_extensionsimportTypeGuarddefis_float(a: object) ->TypeGuard[float]: passdefmain(a: object) ->None:
ifis_float(x:=a):
reveal_type(x) # N: Revealed type is 'builtins.float'reveal_type(a) # N: Revealed type is 'builtins.object
Documentation
In #9865, mypy added support for this pattern.
I couldn't find examples of this in https://www.python.org/dev/peps/pep-0647/ or in the docs in #10758.
Question
Is this a unique behavior to mypy? Is it something that is expected of all type checkers that implement type guards?
Assuming this wasn't an experimental behavior that will be dropped, it would be helpful to document this usage pattern.
The text was updated successfully, but these errors were encountered: