File tree Expand file tree Collapse file tree 3 files changed +32
-5
lines changed
Expand file tree Collapse file tree 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/
77### 5.8.0 TBD
88 - Fixed #1631 : as import comments can in some cases be duplicated.
99 - 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.
1011 - Implemented #1648 : Export MyPY type hints.
1112 - Implemented #1641 : Identified import statements now return runnable code.
1213 - Implemented #1661 : Added "wemake" profile.
@@ -16,7 +17,7 @@ Find out more about isort's release policy [here](https://pycqa.github.io/isort/
1617 - Implemented #1684 : Added support for extending skips with ` --extend-skip ` and ` --extend-skip-glob ` .
1718 - Implemented #1688 : Auto identification and skipping of some invalid import statements.
1819 - 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.
2021 - Documented #1685 : Skip doesn't support plain directory names, but skip_glob does.
2122
2223### 5.7.0 December 30th 2020
Original file line number Diff line number Diff line change @@ -429,18 +429,22 @@ def _with_from_imports(
429429 parsed .categorized_comments ["nested" ].get (module , {}).pop (from_import , None )
430430 )
431431 if comment :
432+ from_imports .remove (from_import )
433+ if from_imports :
434+ use_comments = []
435+ else :
436+ use_comments = comments
437+ comments = None
432438 single_import_line = with_comments (
433- comments ,
439+ use_comments ,
434440 import_start + from_import ,
435441 removed = config .ignore_comments ,
436442 comment_prefix = config .comment_prefix ,
437443 )
438444 single_import_line += (
439- f"{ comments and ';' or config .comment_prefix } " f"{ comment } "
445+ f"{ use_comments and ';' or config .comment_prefix } " f"{ comment } "
440446 )
441447 output .append (wrap .line (single_import_line , parsed .line_separator , config ))
442- from_imports .remove (from_import )
443- comments = None
444448
445449 from_import_section = []
446450 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():
15851585 show_diff = True ,
15861586 float_to_top = True ,
15871587 )
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