Skip to content

Conversation

@Vaishnavi-KN
Copy link

Mypy failed to infer the type of a variable assigned via the walrus operator
when the assignment appeared in an earlier keyword argument and the variable
was used in a later argument in the same call.

This PR evaluates call arguments once, left to right, so binder updates from
walrus assignments are preserved.

Fixes #20411

@github-actions
Copy link
Contributor

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

Copy link
Collaborator

@A5rocks A5rocks left a comment

Choose a reason for hiding this comment

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

For the test case, please:

  • follow test name conventions
  • use the inline comments for output

I also recommend using my repro as a test case, maybe separately.

(For some reason I'm unable to make an inline comment...)

@Vaishnavi-KN
Copy link
Author

I have updated the test to follow naming conventions and inline output comments as suggested.
The remaining workflows appear to be awaiting maintainer approval.

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.

Cannot determine type of walrus operator variable in list comprehension

2 participants