-
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.
Flag mutable defaults based on mutable annotations
- Loading branch information
1 parent
7c8c1c7
commit ed030d0
Showing
5 changed files
with
112 additions
and
5 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B006_9.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,13 @@ | ||
LIST = [] | ||
|
||
|
||
def foo(a: list = LIST): # B006 | ||
raise NotImplementedError("") | ||
|
||
|
||
def foo(a: list = None): # OK | ||
raise NotImplementedError("") | ||
|
||
|
||
def foo(a: list | None = LIST): # OK | ||
raise NotImplementedError("") |
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
20 changes: 20 additions & 0 deletions
20
...s/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_9.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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs | ||
--- | ||
B006_9.py:4:19: B006 [*] Do not use mutable data structures for argument defaults | ||
| | ||
4 | def foo(a: list = LIST): # B006 | ||
| ^^^^ B006 | ||
5 | raise NotImplementedError("") | ||
| | ||
= help: Replace with `None`; initialize within function | ||
|
||
ℹ Unsafe fix | ||
1 1 | LIST = [] | ||
2 2 | | ||
3 3 | | ||
4 |-def foo(a: list = LIST): # B006 | ||
4 |+def foo(a: list = None): # B006 | ||
5 5 | raise NotImplementedError("") | ||
6 6 | | ||
7 7 | |
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