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
Mypy incorrectly complains about the return statement in this program (with --strict-optional):
deff() ->str:
y# Causes f to be deferredx=Noneifint():
x=''ifxisNone:
x=''returnx# Incompatible return value type (got "Optional[Any]", expected "str")y=int()
The expected behavior is clean output.
Note that f is deferred. The problem goes away when f is not deferred.
The text was updated successfully, but these errors were encountered:
Slightly tweaked example illustrates another problem:
deff() ->str:
yx=Noneifint():
x=''ifxisNone:
x=''x[0] # Value of type "None" is not indexable <-- Unexpectedreturnx# Incompatible return value type (got "Optional[Any]", expected "str")y=int()
Previously a partial type could be narrowed down to a bogus
`Optional[Any]` type. Selectively switch narrowing down off
in deferred nodes to work around the issue.
Fixes#4488.
Previously a partial type could be narrowed down to a bogus
`Optional[Any]` type. Selectively switch narrowing down off
in deferred nodes to work around the issue.
Fixes#4488.
Mypy incorrectly complains about the return statement in this program (with
--strict-optional
):The expected behavior is clean output.
Note that
f
is deferred. The problem goes away whenf
is not deferred.The text was updated successfully, but these errors were encountered: