facebook/usort

usort drops inline comments in multi-line imports without trailing commas

amyreese opened this issue · 0 comments

Source file:

from base import (  # one
    # two
    a,  # three
    b  # four
    # five
)  # six

Repro:

(venv) amethyst@luxray ~/scratch/usort-bug » usort diff source.py
--- a/source.py
+++ b/source.py
@@ -1,7 +1,2 @@
-from base import (  # one
-    # two
-    a,  # three
-    b  # four
-    # five
-)  # six
+from base import a, b  # one  # two  # three  # five  # six

With line-length=20 to prevent collapsing to single line:

(venv) amethyst@luxray ~/scratch/usort-bug » usort diff source.py
--- a/source.py
+++ b/source.py
@@ -1,7 +1,7 @@
 from base import (  # one
     # two
     a,  # three
-    b  # four
+    b,
     # five
 )  # six

Note that in both cases, comment # four is dropped from the final result.