ruff
c8b63fcf - [ty] Synthesize NamedTuple `__match_args__` (#25934)

Commit
63 days ago
[ty] Synthesize NamedTuple `__match_args__` (#25934) ## Summary Python 3.10 generates `__match_args__` on named tuples so their fields can be used in positional class patterns. We already synthesize other generated named-tuple attributes, but did not expose `__match_args__`. ```python from typing import NamedTuple class Point(NamedTuple): x: int y: str reveal_type(Point.__match_args__) # tuple[Literal["x"], Literal["y"]] ``` The gradual fallback for named tuples with unknown fields comes from `NamedTupleFallback`, as proposed in https://github.com/python/typeshed/pull/15906. (I've included a temporary copy of that typeshed change until approved.)
Author
Parents
Loading