Skip to content

Disallow access to instance variable via class #240

Open
@JukkaL

Description

@JukkaL

Currently an instance variable can be accessed using the class, which is wrong. For example, this code is accepted by the type checker:

class A:
    def f(self) -> None:
        self.x = 1
A.x = 1 # accepted, but should be an error

Class variables need to be assigned in the class body:

class A:
    x = 1
A.x = 1 # ok, and should be ok

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions