-
Notifications
You must be signed in to change notification settings - Fork 883
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Respect Unicode characters in import sorting (#10529)
## Summary Ensures that we use the raw identifier as provided in the source code, rather than the normalized Unicode identifier. This _does_ mean that we treat these as two separate identifiers, and _don't_ merge them, even though Python will treat them as the same symbol: ```python import numpy as ℂℇℊℋℌℍℎℐℑℒℓℕℤΩℨKÅℬℭℯℰℱℹℴ import numpy as CƐgHHHhIILlNZΩZKÅBCeEFio ``` I think that's fine, this is super rare anyway and would likely be confusing for users. Closes #10528. ## Test Plan `cargo test`
- Loading branch information
1 parent
594b232
commit 61b7982
Showing
4 changed files
with
37 additions
and
6 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,6 @@ | ||
from astropy.constants import hbar as ℏ | ||
from numpy import pi as π | ||
import numpy as ℂℇℊℋℌℍℎℐℑℒℓℕℤΩℨKÅℬℭℯℰℱℹℴ | ||
import numpy as CƐgHHHhIILlNZΩZKÅBCeEFio | ||
|
||
h = 2 * π * ℏ |
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
24 changes: 24 additions & 0 deletions
24
...s/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__unicode.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,24 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/isort/mod.rs | ||
--- | ||
unicode.py:1:1: I001 [*] Import block is un-sorted or un-formatted | ||
| | ||
1 | / from astropy.constants import hbar as ℏ | ||
2 | | from numpy import pi as π | ||
3 | | import numpy as ℂℇℊℋℌℍℎℐℑℒℓℕℤΩℨKÅℬℭℯℰℱℹℴ | ||
4 | | import numpy as CƐgHHHhIILlNZΩZKÅBCeEFio | ||
5 | | | ||
6 | | h = 2 * π * ℏ | ||
| |_^ I001 | ||
| | ||
= help: Organize imports | ||
|
||
ℹ Safe fix | ||
1 |+import numpy as CƐgHHHhIILlNZΩZKÅBCeEFio | ||
2 |+import numpy as ℂℇℊℋℌℍℎℐℑℒℓℕℤΩℨKÅℬℭℯℰℱℹℴ | ||
1 3 | from astropy.constants import hbar as ℏ | ||
2 4 | from numpy import pi as π | ||
3 |-import numpy as ℂℇℊℋℌℍℎℐℑℒℓℕℤΩℨKÅℬℭℯℰℱℹℴ | ||
4 |-import numpy as CƐgHHHhIILlNZΩZKÅBCeEFio | ||
5 5 | | ||
6 6 | h = 2 * π * ℏ |