You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an import section that has a import_heading isn't at the module top-level, running isort on the file adds an extra new line before the heading comment every time, i.e. the transformation isn't idempotent.
config:
[settings]
known_special = special
import_heading_special = Special imports
sections=FUTURE,STDLIB,THIRDPARTY,SPECIAL,FIRSTPARTY,LOCALFOLDER
file:
fromtypingimportTYPE_CHECKING# Special importsfromspecialimportthingifTYPE_CHECKING:
# Special importsfromspecialimportanother_thingdeffunc():
"""Docstring"""# Special importsfromspecialimportsomething_elsereturn
Running isort . gives the following diff:
diff --git a/f.py b/f.py
index f07d8ca..b71445c 100644
--- a/f.py+++ b/f.py@@ -4,6 +4,7 @@ from typing import TYPE_CHECKING
from special import thing
if TYPE_CHECKING:
+
# Special imports
from special import another_thing
@@ -11,6 +12,7 @@ if TYPE_CHECKING:
def func():
"""Docstring"""
+
# Special imports
from special import something_else
return
Running isort a second time modifies the file again, adding extra lines
diff --git a/f.py b/f.py
index b71445c..bc9d957 100644
--- a/f.py+++ b/f.py@@ -5,6 +5,7 @@ from special import thing
if TYPE_CHECKING:
+
# Special imports
from special import another_thing
@@ -13,6 +14,7 @@ def func():
"""Docstring"""
+
# Special imports
from special import something_else
return
And so on for further runs of isort.
The text was updated successfully, but these errors were encountered:
Thank you for reporting this especially nasty issue! I'm sorry it impacted you!
I've fixed it in the just released 5.0.5 patch release, with additional regression testing in place to ensure it doesn't resurface.
When an import section that has a
import_heading
isn't at the module top-level, runningisort
on the file adds an extra new line before the heading comment every time, i.e. the transformation isn't idempotent.config:
file:
Running
isort .
gives the following diff:Running isort a second time modifies the file again, adding extra lines
And so on for further runs of isort.
The text was updated successfully, but these errors were encountered: