Closed
Description
This example (straight out of the PEP, in a stub file instead of a source file) doesn't pass mypy's type checking:
from typing import overload
unicode = str
@overload
def utf8(value: None) -> None:
pass
@overload
def utf8(value: bytes) -> bytes:
pass
@overload
def utf8(value: unicode) -> bytes:
pass
/tmp/overloadtest.pyi:6: error: Overloaded function signatures 1 and 2 overlap with incompatible return types
/tmp/overloadtest.pyi:6: error: Overloaded function signatures 1 and 3 overlap with incompatible return types
It looks like None
is being interpreted as something broader, when at least for overload resolution it just means the exact value None and shouldn't overlap with any non-optional type.
Related to #885.
Metadata
Metadata
Assignees
Labels
No labels