-
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.
Remove special pre-visit for module docstrings (#9261)
This ensures that we visit the module docstring like any other string. Closes #9260.
- Loading branch information
1 parent
506ffad
commit 20def33
Showing
15 changed files
with
299 additions
and
220 deletions.
There are no files selected for viewing
File renamed without changes.
9 changes: 9 additions & 0 deletions
9
crates/ruff_linter/resources/test/fixtures/pycodestyle/E402_1.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,9 @@ | ||
import a | ||
|
||
"""Some other docstring.""" | ||
|
||
import b | ||
|
||
"""Some other docstring.""" | ||
|
||
import c |
File renamed without changes.
5 changes: 5 additions & 0 deletions
5
crates/ruff_linter/resources/test/fixtures/pyflakes/F404_1.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""" | ||
|
||
"""Non-docstring""" | ||
|
||
from __future__ import absolute_import |
36 changes: 17 additions & 19 deletions
36
crates/ruff_linter/resources/test/fixtures/pyupgrade/UP025.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 |
---|---|---|
@@ -1,30 +1,28 @@ | ||
# These should change | ||
x = u"Hello" | ||
u"Hello" | ||
|
||
u'world' | ||
x = u"Hello" # UP025 | ||
|
||
print(u"Hello") | ||
u'world' # UP025 | ||
|
||
print(u'world') | ||
print(u"Hello") # UP025 | ||
|
||
import foo | ||
|
||
foo(u"Hello", U"world", a=u"Hello", b=u"world") | ||
print(u'world') # UP025 | ||
|
||
# These should stay quoted they way they are | ||
import foo | ||
|
||
x = u'hello' | ||
x = u"""hello""" | ||
x = u'''hello''' | ||
x = u'Hello "World"' | ||
foo(u"Hello", U"world", a=u"Hello", b=u"world") # UP025 | ||
|
||
# These should not change | ||
u = "Hello" | ||
# Retain quotes when fixing. | ||
x = u'hello' # UP025 | ||
x = u"""hello""" # UP025 | ||
x = u'''hello''' # UP025 | ||
x = u'Hello "World"' # UP025 | ||
|
||
u = u | ||
u = "Hello" # OK | ||
u = u # OK | ||
|
||
def hello(): | ||
return"Hello" | ||
return"Hello" # OK | ||
|
||
f"foo"u"bar" | ||
f"foo" u"bar" | ||
f"foo"u"bar" # OK | ||
f"foo" u"bar" # OK |
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
22 changes: 22 additions & 0 deletions
22
...c/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402_1.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,22 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pycodestyle/mod.rs | ||
--- | ||
E402_1.py:5:1: E402 Module level import not at top of file | ||
| | ||
3 | """Some other docstring.""" | ||
4 | | ||
5 | import b | ||
| ^^^^^^^^ E402 | ||
6 | | ||
7 | """Some other docstring.""" | ||
| | ||
|
||
E402_1.py:9:1: E402 Module level import not at top of file | ||
| | ||
7 | """Some other docstring.""" | ||
8 | | ||
9 | import c | ||
| ^^^^^^^^ E402 | ||
| | ||
|
||
|
6 changes: 3 additions & 3 deletions
6
...estyle__tests__preview__E402_E402.py.snap → ...tyle__tests__preview__E402_E402_0.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
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
2 changes: 1 addition & 1 deletion
2
...rules__pyflakes__tests__F404_F404.py.snap → ...les__pyflakes__tests__F404_F404_0.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
12 changes: 12 additions & 0 deletions
12
...ter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F404_F404_1.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,12 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pyflakes/mod.rs | ||
--- | ||
F404_1.py:5:1: F404 `from __future__` imports must occur at the beginning of the file | ||
| | ||
3 | """Non-docstring""" | ||
4 | | ||
5 | from __future__ import absolute_import | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F404 | ||
| | ||
|
||
|
Oops, something went wrong.