-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
F401 - Recommend adding unused import bindings to __all__
#11314
Merged
Merged
Changes from 45 commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
fe7016e
Revert "patch to remove the unfinished dunder_all mutation"
plredmond 41584e1
charlie patch w/proto dunder_all finder
plredmond 61cca6c
find_dunder_all_expr implemented
plredmond 453c905
pass ExprList to fix_by_reexporting
plredmond 628053e
slight cleanup of branch arms readability
plredmond 59d96ae
rename F401_25__all fixture test to F401_25__all_nonempty
plredmond 5b1f3e5
remove unnecessary pattern match
plredmond 1d16c8b
new field in ImportBinding which is the name of the binding
plredmond ff5f82f
change fix_bind_reexporting call add_to_dunder_all with the list of b…
plredmond 93f0bc3
uncomment and review test cases for F401_25 fixture test
plredmond 07bd559
add edit to insert binding names into __all__
plredmond 4c38950
fixture tests to more thoroughly explore the cases of the "add to __a…
plredmond f5370cb
cargo clippy edits -- map..or to map_or and single-pattern match to i…
plredmond db7cbb5
include the binding name in UnusedImport; when it is not the suffix o…
plredmond 1ad23f8
accept fixture test changes that show the binding when it differs fro…
plredmond 2a72d34
accept stylist argument to place correct quotes around binders added …
plredmond 494e56d
use Expr instead of ExprList to convey dunder_all value to the edit-p…
plredmond a54ea9d
clippy again
plredmond 99fd1f6
change make_redundant_alias to take an iter of Cow to simplify caller
plredmond c8dc342
rewrite add_to_dunder_all and its tests
plredmond 188a232
shakes fist at cloud and yells, "Clippy!!!"
plredmond 877800e
change message for redundant-aliases
plredmond d5978f9
use binding method instead of accessing the field
plredmond 86f30e7
use filter_map followed by last to obtain the first __all__ binding
plredmond 7f092bf
update fixture test to reflect that we add to the first binding of __…
plredmond 1d0f3ca
fixture test to demonstrate how we treat __all__ followed by a condit…
plredmond 3e284b6
do not offer a fix to add to __all__ when there is more than one __al…
plredmond 7f3335d
delete F401_29 fixture test
plredmond 097ce55
rename F401_30 fixture test to F401_29
plredmond 5beb13f
add unused-import case to F401_29 fixture test
plredmond 92a7a43
change `find_dunder_all_expr` to `find_dunder_all_exprs` and track th…
plredmond 190d191
change find_dunder_all_exprs to return /all/ such exprs regardless of…
plredmond 6035e1d
change fix-title for redundant alias case to format itself and return…
plredmond c81506a
use if-let instead of match with empty branch per alex
plredmond bb545a2
Update crates/ruff_linter/src/fix/edits.rs
plredmond 1cbf320
wording improvement per alex
plredmond 64c17e2
replace into::Into with Cow::from to make conversion explicit
plredmond a747897
improve the wording of "add unused import to __all__" message per alex
plredmond edc88f3
reformat a function -- noop w.r.t. the tests
plredmond 117a1f0
remove a now unnecessary branch, which also makes the overall PR diff…
plredmond 1b167e6
call .end() directly instead of going through .range or .range(); rem…
plredmond 26d4714
readd erroneously removed newlines to fixture snaps
plredmond 5dbdcfe
ruff format the fixture __init__.py files
plredmond 64fa9af
cargo insta review -- accept whitespace changes (see `git diff -w`)
plredmond 527d395
clippy fix -- replace closure with static reference to method
plredmond 548180b
collect only 2 `__all__` definitions and then stop pulling the iterator
plredmond 01e974f
Revert "collect only 2 `__all__` definitions and then stop pulling th…
plredmond 0696df5
remove the qualified-name field from UnusedImport in favor of the bin…
plredmond dde9756
Revert "remove the qualified-name field from UnusedImport in favor of…
plredmond File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions
11
crates/ruff_linter/resources/test/fixtures/pyflakes/F401_26__all_empty/__init__.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,11 @@ | ||
"""__init__.py with empty __all__ | ||
""" | ||
|
||
|
||
from . import unused # F401: add to __all__ | ||
|
||
|
||
from . import renamed as bees # F401: add to __all__ | ||
|
||
|
||
__all__ = [] |
1 change: 1 addition & 0 deletions
1
crates/ruff_linter/resources/test/fixtures/pyflakes/F401_26__all_empty/renamed.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 @@ | ||
# empty module imported by __init__.py for test fixture |
1 change: 1 addition & 0 deletions
1
crates/ruff_linter/resources/test/fixtures/pyflakes/F401_26__all_empty/unused.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 @@ | ||
# empty module imported by __init__.py for test fixture |
11 changes: 11 additions & 0 deletions
11
crates/ruff_linter/resources/test/fixtures/pyflakes/F401_27__all_mistyped/__init__.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,11 @@ | ||
"""__init__.py with mis-typed __all__ | ||
""" | ||
|
||
|
||
from . import unused # F401: recommend add to all w/o fix | ||
|
||
|
||
from . import renamed as bees # F401: recommend add to all w/o fix | ||
|
||
|
||
__all__ = None |
1 change: 1 addition & 0 deletions
1
crates/ruff_linter/resources/test/fixtures/pyflakes/F401_27__all_mistyped/renamed.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 @@ | ||
# empty module imported by __init__.py for test fixture |
1 change: 1 addition & 0 deletions
1
crates/ruff_linter/resources/test/fixtures/pyflakes/F401_27__all_mistyped/unused.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 @@ | ||
# empty module imported by __init__.py for test fixture |
8 changes: 8 additions & 0 deletions
8
crates/ruff_linter/resources/test/fixtures/pyflakes/F401_28__all_multiple/__init__.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,8 @@ | ||
"""__init__.py with multiple imports added to all in one edit | ||
""" | ||
|
||
|
||
from . import unused, renamed as bees # F401: add to __all__ | ||
|
||
|
||
__all__ = []; |
1 change: 1 addition & 0 deletions
1
crates/ruff_linter/resources/test/fixtures/pyflakes/F401_28__all_multiple/renamed.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 @@ | ||
# empty module imported by __init__.py for test fixture |
1 change: 1 addition & 0 deletions
1
crates/ruff_linter/resources/test/fixtures/pyflakes/F401_28__all_multiple/unused.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 @@ | ||
# empty module imported by __init__.py for test fixture |
16 changes: 16 additions & 0 deletions
16
crates/ruff_linter/resources/test/fixtures/pyflakes/F401_29__all_conditional/__init__.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,16 @@ | ||
"""__init__.py with __all__ populated by conditional plus-eq | ||
|
||
multiple __all__ so cannot offer a fix to add to them | ||
""" | ||
|
||
import sys | ||
|
||
from . import unused, exported, renamed as bees | ||
|
||
if sys.version_info > (3, 9): | ||
from . import also_exported | ||
|
||
__all__ = ["exported"] | ||
|
||
if sys.version_info >= (3, 9): | ||
__all__ += ["also_exported"] |
1 change: 1 addition & 0 deletions
1
...es/ruff_linter/resources/test/fixtures/pyflakes/F401_29__all_conditional/also_exported.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 @@ | ||
# empty module imported by __init__.py for test fixture |
1 change: 1 addition & 0 deletions
1
crates/ruff_linter/resources/test/fixtures/pyflakes/F401_29__all_conditional/exported.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 @@ | ||
# empty module imported by __init__.py for test fixture |
1 change: 1 addition & 0 deletions
1
crates/ruff_linter/resources/test/fixtures/pyflakes/F401_29__all_conditional/renamed.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 @@ | ||
# empty module imported by __init__.py for test fixture |
1 change: 1 addition & 0 deletions
1
crates/ruff_linter/resources/test/fixtures/pyflakes/F401_29__all_conditional/unused.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 @@ | ||
# empty module imported by __init__.py for test fixture |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does
SUT
mean?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
system under test -- the test is long so i'm marking the bit that's unit tested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This acronym was also unfamiliar to me FWIW