Open
Description
To Reproduce
from collections.abc import Sequence
from typing import TypeVar
_T = TypeVar("_T")
def foo(seq: Sequence[_T]) -> None:
seq = tuple(map(str, seq))
$ mypy ./mypy_bug.py
mypy_bug.py: note: In function "foo":
mypy_bug.py:7:19: error: Argument 1 to "map" has incompatible type "type[str]"; expected "Callable[[_T], _T]"
[arg-type]
seq = tuple(map(str, seq))
^~~
Found 1 error in 1 file (checked 1 source file)
Interestingly enough, this error does not fire if you assign to something other than seq
:
def foo(seq: Sequence[_T]) -> None:
not_seq = tuple(map(str, seq)) # no problem, no mypy error
- Mypy version used:
mypy 1.9.0 (compiled: yes)
- Mypy command-line flags: None
- Mypy configuration options from
mypy.ini
(and other config files): None - Python version used:
Python 3.12.2