Skip to content

Commit

Permalink
Add advice for fixing RUF008 when mutability is not desired (#8853)
Browse files Browse the repository at this point in the history
  • Loading branch information
samueljsb committed Nov 27, 2023
1 parent 0202a49 commit 1f14d9a
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ use crate::rules::ruff::rules::helpers::{
/// changed in one instance, as those changes will unexpectedly affect all
/// other instances.
///
/// When mutable value are intended, they should be annotated with
/// `typing.ClassVar`.
/// When mutable values are intended, they should be annotated with
/// `typing.ClassVar`. When mutability is not required, values should be
/// immutable types, like `tuple` or `frozenset`.
///
/// ## Examples
/// ```python
/// class A:
/// mutable_default: list[int] = []
/// immutable_default: list[int] = []
/// ```
///
/// Use instead:
Expand All @@ -36,6 +38,7 @@ use crate::rules::ruff::rules::helpers::{
///
/// class A:
/// mutable_default: ClassVar[list[int]] = []
/// immutable_default: tuple[int, ...] = ()
/// ```
#[violation]
pub struct MutableClassDefault;
Expand Down

0 comments on commit 1f14d9a

Please sign in to comment.