File tree 3 files changed +32
-5
lines changed
3 files changed +32
-5
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ Find out more about isort's release policy [here](https://pycqa.github.io/isort/
7
7
### 5.8.0 TBD
8
8
- Fixed #1631 : as import comments can in some cases be duplicated.
9
9
- Fixed #1667 : extra newline added with float-to-top, after skip, in some cases.
10
+ - Fixed #1594 : incorrect placement of noqa comments with multiple from imports.
10
11
- Implemented #1648 : Export MyPY type hints.
11
12
- Implemented #1641 : Identified import statements now return runnable code.
12
13
- Implemented #1661 : Added "wemake" profile.
@@ -16,7 +17,7 @@ Find out more about isort's release policy [here](https://pycqa.github.io/isort/
16
17
- Implemented #1684 : Added support for extending skips with ` --extend-skip ` and ` --extend-skip-glob ` .
17
18
- Implemented #1688 : Auto identification and skipping of some invalid import statements.
18
19
- Implemented #1645 : Ability to reverse the import sorting order.
19
- - Implemented #1504 : Ability to push star imports to the top to avoid overriding explicitly defined imports.
20
+ - Implemented #1504 : Added ability to push star imports to the top to avoid overriding explicitly defined imports.
20
21
- Documented #1685 : Skip doesn't support plain directory names, but skip_glob does.
21
22
22
23
### 5.7.0 December 30th 2020
Original file line number Diff line number Diff line change @@ -429,18 +429,22 @@ def _with_from_imports(
429
429
parsed .categorized_comments ["nested" ].get (module , {}).pop (from_import , None )
430
430
)
431
431
if comment :
432
+ from_imports .remove (from_import )
433
+ if from_imports :
434
+ use_comments = []
435
+ else :
436
+ use_comments = comments
437
+ comments = None
432
438
single_import_line = with_comments (
433
- comments ,
439
+ use_comments ,
434
440
import_start + from_import ,
435
441
removed = config .ignore_comments ,
436
442
comment_prefix = config .comment_prefix ,
437
443
)
438
444
single_import_line += (
439
- f"{ comments and ';' or config .comment_prefix } " f"{ comment } "
445
+ f"{ use_comments and ';' or config .comment_prefix } " f"{ comment } "
440
446
)
441
447
output .append (wrap .line (single_import_line , parsed .line_separator , config ))
442
- from_imports .remove (from_import )
443
- comments = None
444
448
445
449
from_import_section = []
446
450
while from_imports and (
Original file line number Diff line number Diff line change @@ -1585,3 +1585,25 @@ def test_isort_shouldnt_add_extra_line_float_to_top_issue_1667():
1585
1585
show_diff = True ,
1586
1586
float_to_top = True ,
1587
1587
)
1588
+
1589
+
1590
+ def test_isort_shouldnt_move_noqa_comment_issue_1594 ():
1591
+ assert (
1592
+ isort .code (
1593
+ """
1594
+ from .test import TestTestTestTestTestTest1 # noqa: F401
1595
+ from .test import TestTestTestTestTestTest2, TestTestTestTestTestTest3, """
1596
+ """TestTestTestTestTestTest4, TestTestTestTestTestTest5 # noqa: F401
1597
+ """ ,
1598
+ profile = "black" ,
1599
+ )
1600
+ == """
1601
+ from .test import TestTestTestTestTestTest1 # noqa: F401
1602
+ from .test import ( # noqa: F401
1603
+ TestTestTestTestTestTest2,
1604
+ TestTestTestTestTestTest3,
1605
+ TestTestTestTestTestTest4,
1606
+ TestTestTestTestTestTest5,
1607
+ )
1608
+ """
1609
+ )
You can’t perform that action at this time.
0 commit comments