-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Wrong type inferred when "not in" narrowing Any #17841
Copy link
Copy link
Closed
Labels
bugmypy got something wrongmypy got something wrongtopic-type-narrowingConditional type narrowing / binderConditional type narrowing / binder
Description
The revealed type here is str | None, which doesn't make sense:
from typing import Any
def f(x: Any) -> None:
if x is not None and x not in ["x"]:
return
reveal_type(x) # "str | None"The behavior was changed in ed0cd4a. The inferred type before this commit was Any, which seems reasonable.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-type-narrowingConditional type narrowing / binderConditional type narrowing / binder