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

RUF012 should allow plain ClassVar #6267

Closed
bluetech opened this issue Aug 2, 2023 · 0 comments · Fixed by #6273
Closed

RUF012 should allow plain ClassVar #6267

bluetech opened this issue Aug 2, 2023 · 0 comments · Fixed by #6273

Comments

@bluetech
Copy link
Contributor

bluetech commented Aug 2, 2023

Running ruff 0.0.282 using ruff --isolated --select=RUF012 on the following file:

from typing import ClassVar

class C:
    f: ClassVar = {0}

gives

x.py:4:19: RUF012 Mutable class attributes should be annotated with `typing.ClassVar`

I think Ruff should not emit RUF012 for this, since if ClassVar is used without the [...] part, the type checkers infer the type, i.e. the [...] part is optional, similar to Final.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant