-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongtopic-error-reportingHow we report errorsHow we report errorstopic-named-tuple
Description
Assuming the following file:
$ cat foo.py
from typing import NamedTuple, List, Tuple, Sequence
from typing import NamedTuple, List, Sequence
class NT(NamedTuple):
matched_text: str
matches: Sequence[str] # Sequence will not match List below
matches_origin: int
def f() -> Tuple[str, List[str]]: # List will not match sequence above.
nt = NT("a", ["a", "b"], 1)
return nt[:2]
Got
$ mypy foo.py
foo.py:14: error: Incompatible return value type (got "NT", expected "Tuple[str, List[str]]")
Found 1 error in 1 file (checked 1 source file)
I would have expected (got "Tuple[str, Seq[str]]", expected...)
not got "NT"
)
Looks like the inference is good, if I replace Sequence by List or vice versa, It's all fine, just the error forget about the slicing.
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-error-reportingHow we report errorsHow we report errorstopic-named-tuple