-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
topic-named-tupletopic-runtime-semanticsmypy doesn't model runtime semantics correctlymypy doesn't model runtime semantics correctly
Description
mypy parses NamedTuple class definition in the same way it parses regular class variables:
from typing import NamedTuple
from typing import reveal_type
class A(NamedTuple):
foo: str = "foo"
reveal_type(A.foo)
a = "_" + A.foomypy t.py
t.py:9: note: Revealed type is "builtins.str"
Success: no issues found in 1 source filepython3 t.py
Runtime type is '_tuplegetter'
Traceback (most recent call last):
File "D:\workspace\client\t.py", line 10, in <module>
a = "_" + A.foo
~~~~^~~~~~~
TypeError: can only concatenate str (not "collections._tuplegetter") to strmypy --version && python3 --version
mypy 1.16.1 (compiled: yes)
Python 3.13.5sterliakov
Metadata
Metadata
Assignees
Labels
topic-named-tupletopic-runtime-semanticsmypy doesn't model runtime semantics correctlymypy doesn't model runtime semantics correctly