Skip to content

RUF012 , not detecting the use of ClassVar #15857

@Sxderp

Description

@Sxderp

Description

I'm running on Python3.9. I have the following code and RUFF spits out an error about RUF012. I think it may be related to #6267 and / or #12288 (since, I think, the future import makes all annotations strings?).

Ruff Version: 0.9.3

"""ClassVar example."""

from __future__ import annotations

import typing


class Example():
    """Class that uses ClassVar."""

    options: ClassVar[dict[str, str]] = {}


if typing.TYPE_CHECKING:
    from typing import ClassVar
sample.py:11:41: RUF012 Mutable class attributes should be annotated with `typing.ClassVar`
   |
 9 |     """Class that uses ClassVar."""
10 |
11 |     options: ClassVar[dict[str, str]] = {}
   |                                         ^^ RUF012
   |

Found 1 error.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions