Skip to content

Cannot annotate attribute which is already annotated in class body #658

Open
@migeed-z

Description

@migeed-z

Describe the Bug

class A:
    _x: int

    def __init__(self, x:int):
        self._x: int = x # E: Cannot annotate attribute `_x`, which is already annotated in the class body 

Pyright doesn't emit that error. The annotations are consistent. Why do we complain?

I can take a look at it.

Sandbox Link

https://pyrefly.org/sandbox/?code=MYGwhgzhAECCBcAoaLoH0Ae9oEsB2ALosqgCYCmAZumvjgWmgBQTkiUA00W+BAlElRDordgDpM2XtAC83IA

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions