PyCQA / PyCQA/isort

ensure_newline_before_comments is not respected

Open
#2,009 2 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

https://pycqa.github.io/isort/docs/configuration/options.html#ensure-newline-before-comments

Behavior before:

example_app  | ERROR: /app/some_module.py Imports are incorrectly sorted and/or formatted.
example_app  | --- /app/some_module:before	2022-11-29 06:27:44.401078
example_app  | +++ /app/some_module.py:after	2022-11-29 06:27:47.062501
example_app  | @@ -3,6 +3,7 @@
example_app  |  from example_app.module1 import Import1
example_app  |  from example_app.module2 import Import2
example_app  |  from example_app.module3 import Import3
example_app  | +
example_app  |  # from example_app.module4 import (
example_app  |  #     Import4,
example_app  |  #     Import5,

Behavior after:
No error.

Version: 5.10.1

Configuration

setup.cfg (no other configs):

[isort]
profile = black
ensure_newline_before_comments = false
line_length = 80
sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER

I assume that profile setting overwrites ensure_newline_before_comments OR the later one is not working at all somewhy OR I do not understand it right.

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

Reproduce the report with isort 5.10.1 using the shown setup.cfg, including profile = black and ensure_newline_before_comments = false, against imports containing a commented import block. Start by tracing how these options are loaded and applied, then verify that the configured behavior produces no formatting error for the supplied example.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.