Skip to content

[ty] Validate forwarded tuple unions against unpacked callables - #27518

Draft
charliermarsh wants to merge 1 commit into
charlie/ty-4172-callable-keyword-soundnessfrom
charlie/ty-4172-forwarded-unpack-soundness
Draft

[ty] Validate forwarded tuple unions against unpacked callables#27518
charliermarsh wants to merge 1 commit into
charlie/ty-4172-callable-keyword-soundnessfrom
charlie/ty-4172-forwarded-unpack-soundness

Conversation

@charliermarsh

Copy link
Copy Markdown
Member

Summary

Follow-up to #27517.

Previously, merging forwarded tuple alternatives could hide an incompatible unpacked argument or make an invalid overload appear applicable:

def callback(*args: *tuple[int, str]) -> None: ...

def forward(values: tuple[int, str] | tuple[int, int]) -> None:
    callback(*values)  # error: [invalid-argument-type]

We now retry binding against each expandable forwarded alternative, require every alternative to match a callable or overload, and preserve failing states when later expansion cannot prove the call is valid. Fixed arguments that can shift between tuple positions must satisfy every possible element type, and forwarded finite unions retain their minimum required length.

The existing expansion limit remains conservative; this change does not attempt to preserve successful calls after the limit is reached.

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

astral-sh-bot Bot commented Aug 5, 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 96.97%. The percentage of expected errors that received a diagnostic held steady at 93.24%. The number of fully passing files held steady at 104/133.

@astral-sh-bot

astral-sh-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

Memory usage report

Memory usage unchanged ✅

@astral-sh-bot

astral-sh-bot Bot commented Aug 5, 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)

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.

1 participant