Skip to content

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

@4atj

Description

@4atj

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    python compatMypyc doesn't match CPython or documented semantics.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions