-
Notifications
You must be signed in to change notification settings - Fork 899
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle when pos is equal to line length
- Loading branch information
Showing
7 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B006_6.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,5 @@ | ||
# Docstring followed by whitespace with no newline | ||
# Regression test for https://github.com/astral-sh/ruff/issues/7155 | ||
|
||
def foobar(foor, bar={}): | ||
import os |
5 changes: 5 additions & 0 deletions
5
crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B006_7.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,5 @@ | ||
# Docstring with no newline | ||
|
||
|
||
def foobar(foor, bar={}): | ||
import os |
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
25 changes: 25 additions & 0 deletions
25
...s/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_6.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,25 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs | ||
--- | ||
B006_6.py:4:22: B006 [*] Do not use mutable data structures for argument defaults | ||
| | ||
2 | # Regression test for https://github.com/astral-sh/ruff/issues/7155 | ||
3 | | ||
4 | def foobar(foor, bar={}): | ||
| ^^ B006 | ||
5 | import os | ||
| | ||
= help: Replace with `None`; initialize within function | ||
|
||
ℹ Possible fix | ||
1 1 | # Docstring followed by whitespace with no newline | ||
2 2 | # Regression test for https://github.com/astral-sh/ruff/issues/7155 | ||
3 3 | | ||
4 |-def foobar(foor, bar={}): | ||
5 |- import os | ||
4 |+def foobar(foor, bar=None): | ||
5 |+ import os | ||
6 |+ if bar is None: | ||
7 |+ bar = {} | ||
|
||
|
23 changes: 23 additions & 0 deletions
23
...s/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_7.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,23 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs | ||
--- | ||
B006_7.py:4:22: B006 [*] Do not use mutable data structures for argument defaults | ||
| | ||
4 | def foobar(foor, bar={}): | ||
| ^^ B006 | ||
5 | import os | ||
| | ||
= help: Replace with `None`; initialize within function | ||
|
||
ℹ Possible fix | ||
1 1 | # Docstring with no newline | ||
2 2 | | ||
3 3 | | ||
4 |-def foobar(foor, bar={}): | ||
5 |- import os | ||
4 |+def foobar(foor, bar=None): | ||
5 |+ import os | ||
6 |+ if bar is None: | ||
7 |+ bar = {} | ||
|
||
|