Skip to content
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

Can't access ClassVars directly in the class body #972

Closed
4atj opened this issue Feb 7, 2023 · 1 comment
Closed

Can't access ClassVars directly in the class body #972

4atj opened this issue Feb 7, 2023 · 1 comment
Labels
python compat Mypyc doesn't match CPython or documented semantics.

Comments

@4atj
Copy link

4atj commented Feb 7, 2023

This piece of code raises an exception KeyError: 'a'

from typing import ClassVar

class A:
    a: ClassVar[int] = 1
    b: ClassVar[int] = a

Changing a to A.a fixes the issue! But that's not a valid python code.

@hauntsaninja hauntsaninja added the python compat Mypyc doesn't match CPython or documented semantics. label Feb 7, 2023
@ichard26
Copy link
Collaborator

ichard26 commented Feb 8, 2023

Hey thanks for reporting!

This is mostly a duplicate of #862 so I'll be closing this in favour of that. That issue also included one more bug, but it's been fixed so the same underlying issue (class-level scoping is broken) is the same as this one.

@ichard26 ichard26 closed this as not planned Won't fix, can't repro, duplicate, stale Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python compat Mypyc doesn't match CPython or documented semantics.
Projects
None yet
Development

No branches or pull requests

3 participants