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

Treat non-inplace augmented assignment as a simple assignment #3110

Merged
merged 4 commits into from May 22, 2017

Conversation

Projects
None yet
3 participants
@pkch
Contributor

pkch commented Apr 2, 2017

Fixes #2098

@JukkaL

Looks good, just a few comments about test cases.

@@ -1514,3 +1514,10 @@ class A(): pass
class B(): pass
[out]
main:8: error: Incompatible types in assignment (expression has type "A", variable has type "B")
[case testAugmentedAssignmentIntFloat]
weight0 = 65.5

This comment has been minimized.

@JukkaL

JukkaL Apr 3, 2017

Collaborator

Add reveal_type(weight0) after each assignment.

@JukkaL

JukkaL Apr 3, 2017

Collaborator

Add reveal_type(weight0) after each assignment.

This comment has been minimized.

@pkch

pkch Apr 4, 2017

Contributor

After I did it, I discovered another problem: I didn't update the binder (the last weight0 should go back to float, but it stayed as int in my patch). I have fixed it by using a higher level check_assignment method instead of copying/pasting a line from check_simple_assignment . I think this way, the code has become cleaner overall since I could get rid of a couple lines from the original implementation of visit_operator_assignment_stmt (they are taken care of in the check_assignment call).

@pkch

pkch Apr 4, 2017

Contributor

After I did it, I discovered another problem: I didn't update the binder (the last weight0 should go back to float, but it stayed as int in my patch). I have fixed it by using a higher level check_assignment method instead of copying/pasting a line from check_simple_assignment . I think this way, the code has become cleaner overall since I could get rid of a couple lines from the original implementation of visit_operator_assignment_stmt (they are taken care of in the check_assignment call).

Show outdated Hide outdated test-data/unit/check-statements.test
@gvanrossum

This comment has been minimized.

Show comment
Hide comment
@gvanrossum

gvanrossum May 10, 2017

Member

I'd love to see this merged. Is there more to it than resolving the merge conflict?

Member

gvanrossum commented May 10, 2017

I'd love to see this merged. Is there more to it than resolving the merge conflict?

@pkch

This comment has been minimized.

Show comment
Hide comment
@pkch

pkch May 10, 2017

Contributor

It logically separates augmented assignment into two categories: in-place and not in-place. In the former case, it changes nothing. In the latter case, it makes mypy behave as if augmented assignment was rewritten using a regular assignment.

Contributor

pkch commented May 10, 2017

It logically separates augmented assignment into two categories: in-place and not in-place. In the former case, it changes nothing. In the latter case, it makes mypy behave as if augmented assignment was rewritten using a regular assignment.

pkch added some commits May 10, 2017

@gvanrossum gvanrossum merged commit 266a63f into python:master May 22, 2017

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@gvanrossum

This comment has been minimized.

Show comment
Hide comment
@gvanrossum

gvanrossum May 22, 2017

Member

Thanks!

Member

gvanrossum commented May 22, 2017

Thanks!

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