Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[ty] Synthesize NamedTuple __match_args__#25934

Merged
charliermarsh merged 5 commits into
mainfrom
charlie/namedtuple-match-args
Jun 13, 2026
Merged

[ty] Synthesize NamedTuple __match_args__#25934
charliermarsh merged 5 commits into
mainfrom
charlie/namedtuple-match-args

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Jun 12, 2026

Copy link
Copy Markdown
Member

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__.

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 python/typeshed#15906. (I've included a temporary copy of that typeshed change until approved.)

@astral-sh-bot astral-sh-bot Bot added the ty Multi-file analysis & type inference label Jun 12, 2026
@astral-sh-bot

astral-sh-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 94.36%. The percentage of expected errors that received a diagnostic held steady at 88.82%. The number of fully passing files held steady at 93/134.

@astral-sh-bot

astral-sh-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

Memory usage report

Memory usage unchanged ✅

@astral-sh-bot

astral-sh-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

No diagnostic changes detected ✅

Flaky changes detected. This PR summary excludes flaky changes; see the HTML report for details.

Full report with detailed diff (timing results)

@charliermarsh charliermarsh marked this pull request as ready for review June 12, 2026 23:35
@charliermarsh charliermarsh marked this pull request as draft June 13, 2026 00:43
@charliermarsh charliermarsh force-pushed the charlie/namedtuple-match-args branch 3 times, most recently from 7d39b5f to 51db04d Compare June 13, 2026 01:28
@charliermarsh charliermarsh changed the title [ty] Synthesize NamedTuple __match_args__ [ty] Synthesize NamedTuple __match_args__ Jun 13, 2026
@charliermarsh charliermarsh force-pushed the charlie/namedtuple-match-args branch from 51db04d to f1a93a6 Compare June 13, 2026 01:33
@charliermarsh charliermarsh marked this pull request as ready for review June 13, 2026 01:34

@AlexWaygood AlexWaygood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@charliermarsh charliermarsh force-pushed the charlie/namedtuple-match-args branch from f1a93a6 to 317a0b9 Compare June 13, 2026 12:46
@charliermarsh charliermarsh merged commit c8b63fc into main Jun 13, 2026
58 checks passed
@charliermarsh charliermarsh deleted the charlie/namedtuple-match-args branch June 13, 2026 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants