-
Notifications
You must be signed in to change notification settings - Fork 943
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Accept non-aliased (but correct) import in unconventional-import-alias (
#10729) ## Summary Given: ```toml [tool.ruff.lint.flake8-import-conventions.aliases] "django.conf.settings" = "settings" ``` We should accept `from django.conf import settings`. Closes #10599.
- Loading branch information
1 parent
7b48443
commit 159bad7
Showing
6 changed files
with
57 additions
and
11 deletions.
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
10 changes: 10 additions & 0 deletions
10
crates/ruff_linter/resources/test/fixtures/flake8_import_conventions/same_name.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,10 @@ | ||
def no_alias(): | ||
from django.conf import settings | ||
|
||
|
||
def conventional_alias(): | ||
from django.conf import settings as settings | ||
|
||
|
||
def unconventional_alias(): | ||
from django.conf import settings as s |
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
17 changes: 17 additions & 0 deletions
17
...onventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__same_name.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,17 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/flake8_import_conventions/mod.rs | ||
--- | ||
same_name.py:10:41: ICN001 [*] `django.conf.settings` should be imported as `settings` | ||
| | ||
9 | def unconventional_alias(): | ||
10 | from django.conf import settings as s | ||
| ^ ICN001 | ||
| | ||
= help: Alias `django.conf.settings` to `settings` | ||
|
||
ℹ Unsafe fix | ||
7 7 | | ||
8 8 | | ||
9 9 | def unconventional_alias(): | ||
10 |- from django.conf import settings as s | ||
10 |+ from django.conf import settings as settings |