-
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.
) ## Summary I ran into this in the wild. It looks like Ruff will collapse the `else` and `elif` branches here (i.e., it doesn't recognize that they're too independent import blocks): ```python if "sdist" in cmds: _sdist = cmds["sdist"] elif "setuptools" in sys.modules: from setuptools.command.sdist import sdist as _sdist else: from setuptools.command.sdist import sdist as _sdist from distutils.command.sdist import sdist as _sdist ``` Likely fallout from the `elif_else_branches` refactor.
- Loading branch information
1 parent
aaf7f36
commit 94a004e
Showing
6 changed files
with
90 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
if "sdist" in cmds: | ||
_sdist = cmds["sdist"] | ||
elif "setuptools" in sys.modules: | ||
from setuptools.command.sdist import sdist as _sdist | ||
else: | ||
from setuptools.command.sdist import sdist as _sdist | ||
from distutils.command.sdist import sdist as _sdist |
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,7 @@ | ||
match 1: | ||
case 1: | ||
import sys | ||
import os | ||
case 2: | ||
import collections | ||
import abc |
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
crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__if_elif_else.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/src/rules/isort/mod.rs | ||
--- | ||
if_elif_else.py:6:1: I001 [*] Import block is un-sorted or un-formatted | ||
| | ||
4 | from setuptools.command.sdist import sdist as _sdist | ||
5 | else: | ||
6 | / from setuptools.command.sdist import sdist as _sdist | ||
7 | | from distutils.command.sdist import sdist as _sdist | ||
| | ||
= help: Organize imports | ||
|
||
ℹ Fix | ||
3 3 | elif "setuptools" in sys.modules: | ||
4 4 | from setuptools.command.sdist import sdist as _sdist | ||
5 5 | else: | ||
6 |- from setuptools.command.sdist import sdist as _sdist | ||
7 6 | from distutils.command.sdist import sdist as _sdist | ||
7 |+ | ||
8 |+ from setuptools.command.sdist import sdist as _sdist | ||
|
||
|
44 changes: 44 additions & 0 deletions
44
crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__match_case.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,44 @@ | ||
--- | ||
source: crates/ruff/src/rules/isort/mod.rs | ||
--- | ||
match_case.py:3:1: I001 [*] Import block is un-sorted or un-formatted | ||
| | ||
1 | match 1: | ||
2 | case 1: | ||
3 | / import sys | ||
4 | | import os | ||
5 | | case 2: | ||
| |_^ I001 | ||
6 | import collections | ||
7 | import abc | ||
| | ||
= help: Organize imports | ||
|
||
ℹ Fix | ||
1 1 | match 1: | ||
2 2 | case 1: | ||
3 |+ import os | ||
3 4 | import sys | ||
4 |- import os | ||
5 5 | case 2: | ||
6 6 | import collections | ||
7 7 | import abc | ||
|
||
match_case.py:6:1: I001 [*] Import block is un-sorted or un-formatted | ||
| | ||
4 | import os | ||
5 | case 2: | ||
6 | / import collections | ||
7 | | import abc | ||
| | ||
= help: Organize imports | ||
|
||
ℹ Fix | ||
3 3 | import sys | ||
4 4 | import os | ||
5 5 | case 2: | ||
6 |+ import abc | ||
6 7 | import collections | ||
7 |- import abc | ||
|
||
|