Skip to content

No NOQA added to long line with as import for multi_line_output = 7 #2093

Closed

Description

@ruestefa

Summary

With force_single_line = true and multi_line_output = 7, single-import lines that are too long should receive a # NOQA comment (unless there's one already). This doesn't work for as imports (though at least existing # NOQAs are retained).

Versions

Python v3.11.0
isort v5.12.0

Config

# pyproject.toml
[tool.isort]
profile = "black"
force_single_line = true
multi_line_output = 7  # 7-noqa

Input

from some_module import some_function  # type: ignore [import]  # pylint: disable=no-name-in-module
from some_other_module import another_function as yet_another_function  # type: ignore [import]  # pylint: disable=no-name-in-module
from third_module import third_function as wow_three_functions  # type: ignore [import]  # pylint: disable=no-name-in-module  # NOQA

Expected output

from some_module import some_function  # type: ignore [import]  # pylint: disable=no-name-in-module  # NOQA
from some_other_module import another_function as yet_another_function  # type: ignore [import]  # pylint: disable=no-name-in-module  # NOQA
from third_module import third_function as wow_three_functions  # type: ignore [import]  # pylint: disable=no-name-in-module  # NOQA

Actual output

from some_module import some_function  # type: ignore [import]  # pylint: disable=no-name-in-module  # NOQA
from some_other_module import another_function as yet_another_function  # type: ignore [import]  # pylint: disable=no-name-in-module
from third_module import third_function as wow_three_functions  # type: ignore [import]  # pylint: disable=no-name-in-module  # NOQA

Activity

  1. added theissue type on Apr 1, 2026
  2. added 2 commits that reference this issue on Jun 29, 2026
    41f0602
    2b07aa5
  3. Eljees commented on Sep 24, 2026

    @Eljees
    Contributor

    This looks fixed on main (f00e0919). With the input from the report and --profile black --force-single-line-imports --multi-line 7:

    -from some_module import some_function  # type: ignore [import]  # pylint: disable=no-name-in-module
    -from some_other_module import another_function as yet_another_function  # type: ignore [import]  # pylint: disable=no-name-in-module
    +from some_module import some_function  # type: ignore [import]  # pylint: disable=no-name-in-module  # NOQA
    +from some_other_module import another_function as yet_another_function  # type: ignore [import]  # pylint: disable=no-name-in-module  # NOQA
     from third_module import third_function as wow_three_functions  # type: ignore [import]  # pylint: disable=no-name-in-module  # NOQA

    The as import now gets its # NOQA, and the line that already had one keeps a single one, which is the expected output in the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions