-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Hi, I believe RUF008 should not be triggered for ClassVar's. E.g. for the following snippet:
from dataclasses import dataclass
from typing import ClassVar
@dataclass
class Foo:
bar: ClassVar[list[str]] = [] # RUF008 Do not use mutable default values for dataclass attributesThe command you invoked: ruff check path/to/snippet.py
The current Ruff version: ruff 0.0.262
The current Ruff settings: "RUF" enabled.
Actually, apparently there is no other way to initialize a classvar. Cause trying to use field with default_factory raise TypeError:
from dataclasses import dataclass, field
from typing import ClassVar
@dataclass
class Foo:
bar: ClassVar[list[str]] = field(default_factory=list)Same applies to function calls, e.g.:
from dataclasses import dataclass
from typing import ClassVar
import weakref
@dataclass
class Foo:
bar: ClassVar[weakref.WeakValueDictionary[str, object]] = weakref.WeakValueDictionary()Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working