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

Inferred subclass override of a ClassVar is also a ClassVar. Fixes #4715. #4718

merged 1 commit into from Apr 12, 2018


None yet
3 participants

carljm commented Mar 11, 2018

Fixes #4715. Notes:

  1. It seems to me that many Vars which have explicit type annotation are currently wrongly marked as is_inferred, thus the fix in This fix doesn't cause any test failures, but it makes me wonder if I missed the intended semantics of is_inferred?
  2. If that fix is correct, it looks likely that the same line should be added in other branches of that method, but that seems out of scope for this PR; the fix is only strictly needed for class attributes in this PR.
  3. I put the fixup in pass 3 because it seemed necessary in order to ensure populated MRO. If that's wrong and this could be set correctly reliably in pass 2, let me know how and I'm happy to update.
  4. The three-layer testcase is needed in order to demonstrate why my first fix attempt here was inadequate. My first try was just to check is_inferred in and not raise the override error for a type-inferred assignment, but the three-layer testcase still fails with that fix; we need to actually update the value of is_classvar on the node so checks work correctly on further subclassing.

Thanks in advance for review!


This comment has been minimized.


carljm commented Apr 11, 2018

Ping? Any concerns here, or anything I can address?


This comment has been minimized.


gvanrossum commented Apr 12, 2018

Maybe Jukka or Ivan can review?


This comment has been minimized.


JukkaL commented Apr 12, 2018

I can take this.


JukkaL approved these changes Apr 12, 2018

LGTM. Thanks for the fix!

@JukkaL JukkaL merged commit c3cb000 into python:master Apr 12, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
continuous-integration/travis-ci/pr The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment