Closed
Description
The following code:
from typing import Sequence
def f(b: bool) -> Sequence[int]:
return (5,) if b else ()
produces the following output:
$ python3 Test.py
$ mypy Test.py
Test.py:4: error: Incompatible return value type (got "object", expected "Sequence[int]")
Found 1 error in 1 file (checked 1 source file)
$ mypy --version
mypy 0.740
$ python3 --version
Python 3.6.8
This looks like a false positive to me.
It seems that ()
should be compatible with any non-empty Tuple[...]
or Sequence[...]
. The same goes to []
.
Metadata
Metadata
Assignees
Labels
No labels