-
Notifications
You must be signed in to change notification settings - Fork 219
Closed
astral-sh/ruff
#22573Labels
runtime semanticsAccurate modeling of how Python's semantics work at runtimeAccurate modeling of how Python's semantics work at runtime
Description
NamedTuple classes (of all kinds) have a __slots__ attribute generated for them at runtime (it's always an empty tuple):
>>> import collections, typing
>>> A = collections.namedtuple("A", ())
>>> B = typing.NamedTuple("B", ())
>>> class C(typing.NamedTuple): ...
...
>>> A.__slots__
()
>>> B.__slots__
()
>>> C.__slots__
()We currently emit a false-positive on the C.__slots__ attribute access above, and after astral-sh/ruff#22327 we will also start emitting false-positive errors on the A.__slots__ and B.__slots__ attribute accesses too. We should fix this by synthesizing the generated __slots__ attribute for these classes.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
runtime semanticsAccurate modeling of how Python's semantics work at runtimeAccurate modeling of how Python's semantics work at runtime