-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
bugmypy got something wrongmypy got something wrong
Description
In a lot of typed languages, the compiler can be told to check if a function is total, handles all cases.
For Example:
def foo(x: Union[int, str]) -> str:
if isinstance(x, int):
return "bar"Is only a partial function. If x is a str, then this function actually returns None.
Thus the output type should really be Union[str, NoneType]
I tested this snippet and mypy doesn't seem to catch this.
I'm not 100% sure, but I think if a function is partial, NoneType is a potential return type.
mausch
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong