Open
Description
Bug Report
Mypy raises false positive errors with anonymous and inline declaration of namedtuple types.
To Reproduce
from collections import namedtuple
dim = namedtuple("Dimension", ["x", "y"])(2, 3)
This should be equivalent to the following, which mypy gets correct:
from collections import namedtuple
Dimension = namedtuple("Dimension", ["x", "y"])
dim = Dimension(2, 3)
(Example taken from here: https://stackoverflow.com/a/26405216)
Expected Behavior
No error raised.
Actual Behavior
$ mypy namedtuple.py
namedtuple.py:3: error: Too many arguments for "tuple" [call-arg]
namedtuple.py:3: error: Argument 1 to "tuple" has incompatible type "int"; expected "Iterable[Any]" [arg-type]
Found 2 errors in 1 file (checked 1 source file)
My Environment
$ mypy --version
mypy 1.7.1 (compiled: yes)
$ python --version
Python 3.11.6