Skip to content

[ty] Propagate nested ParamSpec specializations#25766

Draft
dhruvmanila wants to merge 2 commits into
mainfrom
dhruv/propagate-nested-paramspec
Draft

[ty] Propagate nested ParamSpec specializations#25766
dhruvmanila wants to merge 2 commits into
mainfrom
dhruv/propagate-nested-paramspec

Conversation

@dhruvmanila

Copy link
Copy Markdown
Member

Summary

  • defer preferred ParamSpec mappings until after argument inference
  • propagate concrete inner-call ParamSpec specializations through return types to outer generic calls
  • preserve the legacy solver's first-seen behavior for actual ParamSpec arguments

Root cause

The legacy specialization builder keeps the first mapping inferred for a ParamSpec. Bidirectional inference installed the symbolic mapping from the outer call's return context before processing the inner call's arguments, so the later concrete argument-derived mapping was discarded. Adding the contextual mapping last makes it a fallback while allowing the concrete specialization to flow through the inner return type into the outer call.

Validation

Closes astral-sh/ty#3691

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

astral-sh-bot Bot commented Jun 9, 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 92.23%. The percentage of expected errors that received a diagnostic held steady at 87.42%. The number of fully passing files held steady at 92/134.

@astral-sh-bot

astral-sh-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown

Memory usage report

Memory usage unchanged ✅

@astral-sh-bot

astral-sh-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown

ecosystem-analyzer results

Lint rule Added Removed Changed
invalid-argument-type 0 2 0
Total 0 2 0

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

Raw diff:

openlibrary (https://github.com/internetarchive/openlibrary)
- openlibrary/core/bookshelves.py:174:53 error[invalid-argument-type] Argument to bound method `AsyncBridge.wrap` is incorrect: Expected `(**_P@staticmethod) -> Coroutine[Any, Any, None]`, found `def add_solr_works_async(readinglog_items, fields: Iterable[str] | None = None) -> CoroutineType[Any, Any, None]`

zulip (https://github.com/zulip/zulip)
- zerver/management/commands/runtornado.py:100:35 error[invalid-argument-type] Argument to function `sync_to_async` is incorrect: Expected `(**_P@push_async_callback) -> None`, found `def remove_signal_handlers() -> None`

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.

invalid-argument-type false positive: ParamSpec not propagated through composed higher-order functions

1 participant