-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongtopic-type-narrowingConditional type narrowing / binderConditional type narrowing / binder
Description
The behavior in this example was changed in #18538:
def any():
return 1
def f() -> None:
x = "a"
x = any()
assert isinstance(x, int)
reveal_type(x) # "Never", but used to be unreachable (no message)
In the past, the code after isinstance
was silently unchecked. Now the inferred type is Never
, which will likely generate false positives. Neither behavior is great, but users may consider the switch from false negatives to false positives to be a regression. I'm not sure what we should do here. If we'd allow variables to be redefined freely, there would be no issue.
cc @ilevkivskyi who authored the PR that changed the behavior
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-type-narrowingConditional type narrowing / binderConditional type narrowing / binder