-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
With ruff 0.3.4, I ran into unexpected behavior where the autofix for ruff rule I001 is now altering some characters from Unicode Block “Letterlike Symbols” (U+2100). I suspect that this is related to #10412. 🤔 This might not be the only Unicode block that is affected by this.
For example, ℏ (U+210F; which represents Planck's constant over ħ (U+0127; Latin Small Letter H with Stroke). To reproduce this, I created a file called hbar.py that contains:
from astropy.constants import hbar as ℏ
from numpy import pi as π
h = 2 * π * ℏAfter I ran:
ruff check hbar.py --select=I001 --fixI did a git diff and got this:
@@ -1,4 +1,4 @@
-from astropy.constants import hbar as ℏ
+from astropy.constants import hbar as ħ
from numpy import pi as π
Similarly, if I apply I001 to a file containing a bunch of characters from that block:
import numpy as ℂℇℊℋℌℍℎℐℑℒℓℕℤΩℨKÅℬℭℯℰℱℹℴthen the diff is
@@ -1 +1 @@
-import numpy as ℂℇℊℋℌℍℎℐℑℒℓℕℤΩℨKÅℬℭℯℰℱℹℴ
+import numpy as CƐgHHHhIILlNZΩZKÅBCeEFio
My expectation was for ruff to not change variable names that are valid Python names, except for rules that are designed specifically to make these changes (e.g., RUF001, RUF002, RUF003).
Thank you again for creating a wonderful tool!