-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update
mutable-argument-default
(B006
) to use `extend-immutable-c…
- Loading branch information
Showing
8 changed files
with
101 additions
and
15 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
crates/ruff/resources/test/fixtures/flake8_bugbear/B006_extended.py
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import custom | ||
from custom import ImmutableTypeB | ||
|
||
|
||
def okay(foo: ImmutableTypeB = []): | ||
... | ||
|
||
|
||
def okay(foo: custom.ImmutableTypeA = []): | ||
... | ||
|
||
|
||
def okay(foo: custom.ImmutableTypeB = []): | ||
... | ||
|
||
|
||
def error_due_to_missing_import(foo: ImmutableTypeA = []): | ||
... |
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
22 changes: 22 additions & 0 deletions
22
.../snapshots/ruff__rules__flake8_bugbear__tests__extend_immutable_calls_arg_annotation.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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
source: crates/ruff/src/rules/flake8_bugbear/mod.rs | ||
--- | ||
B006_extended.py:17:55: B006 [*] Do not use mutable data structures for argument defaults | ||
| | ||
17 | def error_due_to_missing_import(foo: ImmutableTypeA = []): | ||
| ^^ B006 | ||
18 | ... | ||
| | ||
= help: Replace with `None`; initialize within function | ||
|
||
ℹ Possible fix | ||
14 14 | ... | ||
15 15 | | ||
16 16 | | ||
17 |-def error_due_to_missing_import(foo: ImmutableTypeA = []): | ||
17 |+def error_due_to_missing_import(foo: ImmutableTypeA = None): | ||
18 |+ if foo is None: | ||
19 |+ foo = [] | ||
18 20 | ... | ||
|
||
|
File renamed without changes.
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