-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parsing of Walrus Operator #8053
Comments
Where in the mypy code can I loop If I were to try to make a pull request? |
I don't know exactly, but #6899 is the PR where I added (limited) support for the walrus operator, so the bug may be in the code added there. |
It seems that In the following example: x: int
x = True
y: bool
y = 5
z: str
z = True |
Right, |
Which wasn't what I expected. Even with years of python experience. Could the table on https://mypy.readthedocs.io/en/latest/builtin_types.html be updated? I would expect that the definition of bool there would be a subtype of int. |
@rvanlaar Sure, updating the table is good idea. Would like to create a PR (or a separate issue to track it)? |
Closing this issue, continue with issue #8069 to document it. |
Mypy doesn't seem to handle variable type changes that happen with a walrus operator.
What happens here is: the walrus operator makes it a boolean:
while i:= update(i) > 0
.This is what needs to happen to check for
i > 0
andi
still being an int.while (i:= update(i)) > 0
.The following python code doesn't give any errors with mypy 0.750:
The text was updated successfully, but these errors were encountered: