-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d3a1e0
commit 37483f3
Showing
5 changed files
with
61 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 24 additions & 22 deletions
46
crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF009_RUF009.py.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,44 @@ | ||
--- | ||
source: crates/ruff/src/rules/ruff/mod.rs | ||
--- | ||
RUF009.py:15:41: RUF009 Do not perform function call `default_function` in dataclass defaults | ||
RUF009.py:16:41: RUF009 Do not perform function call `default_function` in dataclass defaults | ||
| | ||
15 | @dataclass() | ||
16 | class A: | ||
17 | hidden_mutable_default: list[int] = default_function() | ||
16 | @dataclass() | ||
17 | class A: | ||
18 | hidden_mutable_default: list[int] = default_function() | ||
| ^^^^^^^^^^^^^^^^^^ RUF009 | ||
19 | class_variable: typing.ClassVar[list[int]] = default_function() | ||
20 | another_class_var: ClassVar[list[int]] = default_function() | ||
| | ||
|
||
RUF009.py:24:41: RUF009 Do not perform function call `default_function` in dataclass defaults | ||
RUF009.py:27:41: RUF009 Do not perform function call `default_function` in dataclass defaults | ||
| | ||
24 | @dataclass | ||
25 | class B: | ||
26 | hidden_mutable_default: list[int] = default_function() | ||
27 | @dataclass | ||
28 | class B: | ||
29 | hidden_mutable_default: list[int] = default_function() | ||
| ^^^^^^^^^^^^^^^^^^ RUF009 | ||
27 | another_dataclass: A = A() | ||
28 | not_optimal: ImmutableType = ImmutableType(20) | ||
30 | another_dataclass: A = A() | ||
31 | not_optimal: ImmutableType = ImmutableType(20) | ||
| | ||
|
||
RUF009.py:25:28: RUF009 Do not perform function call `A` in dataclass defaults | ||
RUF009.py:28:28: RUF009 Do not perform function call `A` in dataclass defaults | ||
| | ||
25 | class B: | ||
26 | hidden_mutable_default: list[int] = default_function() | ||
27 | another_dataclass: A = A() | ||
28 | class B: | ||
29 | hidden_mutable_default: list[int] = default_function() | ||
30 | another_dataclass: A = A() | ||
| ^^^ RUF009 | ||
28 | not_optimal: ImmutableType = ImmutableType(20) | ||
29 | good_variant: ImmutableType = DEFAULT_IMMUTABLETYPE_FOR_ALL_DATACLASSES | ||
31 | not_optimal: ImmutableType = ImmutableType(20) | ||
32 | good_variant: ImmutableType = DEFAULT_IMMUTABLETYPE_FOR_ALL_DATACLASSES | ||
| | ||
|
||
RUF009.py:26:34: RUF009 Do not perform function call `ImmutableType` in dataclass defaults | ||
RUF009.py:29:34: RUF009 Do not perform function call `ImmutableType` in dataclass defaults | ||
| | ||
26 | hidden_mutable_default: list[int] = default_function() | ||
27 | another_dataclass: A = A() | ||
28 | not_optimal: ImmutableType = ImmutableType(20) | ||
29 | hidden_mutable_default: list[int] = default_function() | ||
30 | another_dataclass: A = A() | ||
31 | not_optimal: ImmutableType = ImmutableType(20) | ||
| ^^^^^^^^^^^^^^^^^ RUF009 | ||
29 | good_variant: ImmutableType = DEFAULT_IMMUTABLETYPE_FOR_ALL_DATACLASSES | ||
30 | okay_variant: A = DEFAULT_A_FOR_ALL_DATACLASSES | ||
32 | good_variant: ImmutableType = DEFAULT_IMMUTABLETYPE_FOR_ALL_DATACLASSES | ||
33 | okay_variant: A = DEFAULT_A_FOR_ALL_DATACLASSES | ||
| | ||
|
||
|