Skip to content

Bind type variables in ParamSpec callable aliases - #22443

Open
mengqing88 wants to merge 1 commit into
python:masterfrom
mengqing88:fix/param-spec-alias-callable
Open

mengqing88 wants to merge 1 commit into
python:masterfrom
mengqing88:fix/param-spec-alias-callable

Conversation

@mengqing88

Copy link
Copy Markdown

Fixes #22399

When a generic alias over Callable is instantiated with a concrete parameter list or ellipsis in its ParamSpec slot, analyze the expanded callable so free type variables bind to the returned callable instead of being reported as unbound in the enclosing scope. Ordinary aliases and alias-definition analysis retain their existing behavior.

Tests:

  • 683 related type-check tests passed, 2 skipped
  • PEP 695 reproduction passed with Python 3.12 target
  • Ruff, Black, and git diff checks passed

@mengqing88
mengqing88 force-pushed the fix/param-spec-alias-callable branch from d776ccd to 6215214 Compare November 11, 2026 15:43
@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Type variable reported unbound when only a ParamSpec alias's return type uses it and its ParamSpec slot is not a ParamSpec

1 participant