PyCQA / PyCQA/isort

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

Open
#2,093 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7k
Forks
687
Avg merge
4h 56m
Merged PRs (30d)
2

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the supplied configuration and input, focusing on the single-line import containing an as alias. Compare the output with the expected output and trace how # NOQA is added for long imports. Done means the aliased import receives # NOQA while existing comments remain intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.