FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix missing error context for unpacking assignment involving star expression by brianschubert · Pull Request #19258 · python/mypy · GitHub

Repository navigation

Fix missing error context for unpacking assignment involving star expression - #19258

Merged
hauntsaninja merged 1 commit into
python:masterfrom
brianschubert:gh-19257-unpack-star-expr-context
Jun 10, 2025
Merged

hauntsaninja merged 1 commit into
python:masterfrom
brianschubert:gh-19257-unpack-star-expr-context

Conversation

Copy link
Copy Markdown
Collaborator

Fixes #19257

Given:

a: int
b: list[str]
(a,) = (*b,)
(a,) = [*b]

Before:

TESTFILES/SCRATCH.py: error: Incompatible types in assignment (expression has type "str", variable has type "int")  [assignment]
Found 1 error in 1 file (checked 1 source file)

After:

main.py:3: error: Incompatible types in assignment (expression has type "str", variable has type "int")  [assignment]
    (a,) = (*b,)
            ^
main.py:4: error: Incompatible types in assignment (expression has type "str", variable has type "int")  [assignment]
    (a,) = [*b]
            ^
Found 2 errors in 1 file (checked 1 source file)

Comment thread mypy/checker.py

github-actions Bot commented Jun 9, 2025

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown

Nice work. I just tested it. Note that it also restores the possiblty to use # type: ignore comment.

a: int
b: list[str]
(a,) = (*b,)  # type: ignore[assignment]
(a,) = [*b]  # type: ignore[assignment]
Before (v1.16.0)
tmp.py: error: Incompatible types in assignment (expression has type "str", variable has type "int")  [assignment]
Found 1 error in 1 file (checked 1 source file)
After
Success: no issues found in 1 source file

hauntsaninja left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Nice, thank you!

hauntsaninja merged commit 8667022 into python:master Jun 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

Missing line number error report

5 participants


Back | FazBrowse Home | New Git URL