镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Transform the inner expression of StarExpr - #22131

Open
Cherith1222 wants to merge 2 commits into
python:masterfrom
Cherith1222:fix/21693-star-expr-transform
Open

Cherith1222 wants to merge 2 commits into
python:masterfrom
Cherith1222:fix/21693-star-expr-transform

Conversation

@Cherith1222

Copy link
Copy Markdown

Summary

Functions that use value-constrained type variables are checked as copies made by TreeTransform. visit_star_expr reused the original inner expression, so in (*result,) the NameExpr still pointed at the original Var. That variable is never inferred, because only the copies are checked. The result was a spurious [has-type] error and an Any tuple. The inner expression is now transformed, and the valid flag is preserved.

Fixes #21693.

Test Plan

Before the change, the new test failed. After it, the new test passed. check-typevar-tuple.test and check-typevar-values.test together: 212 passed. Resource Sentinel, 1 CPU, 2.5 GiB.

Not run: the full mypy suite and mypy_primer.

AI assistance

Drafted with Cursor. The account owner authorized opening this pull request. A human has not reviewed the diff. There is no Co-authored-by, Reviewed-by, or Signed-off-by trailer.

Cherith1222 and others added 2 commits October 6, 2026 11:47
Functions using value-constrained type variables are checked as copies made by TreeTransform. visit_star_expr reused the original inner expression, so in '(*result,)' the NameExpr kept pointing at the original Var, which is never inferred because only the copies are checked. That produced a spurious has-type error and an Any tuple. Transform the inner expression and preserve the 'valid' flag.

Fixes python#21693.

AI-assisted (Cursor). Not yet reviewed by a human.
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

scipy-stubs (https://github.com/scipy/scipy-stubs)
- tests/misc/test_submodules_empty.pyi:3: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

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.

Incorrect has-type on unpacking of known TypeVarTuple type from classmethod from class with contrained generic

2 participants