Skip to content

Fix pylint disable-next comments at the start of imports - #2628

Open
Neallin-917 wants to merge 2 commits into
PyCQA:mainfrom
Neallin-917:codex/fix-2054-pylint-disable-next
Open

Fix pylint disable-next comments at the start of imports#2628
Neallin-917 wants to merge 2 commits into
PyCQA:mainfrom
Neallin-917:codex/fix-2054-pylint-disable-next

Conversation

@Neallin-917

Copy link
Copy Markdown

Summary

  • keep a leading pylint: disable-next directive with the import it governs
  • add a regression test for sorting two such from-imports

Closes #2054

Testing

  • uv run pytest tests/unit/test_regressions.py
  • uv run tox -e py3.13

@codecov

codecov Bot commented Aug 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.36%. Comparing base (d5f40fa) to head (47460eb).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2628   +/-   ##
=======================================
  Coverage   99.36%   99.36%           
=======================================
  Files          41       41           
  Lines        3165     3166    +1     
  Branches      682      682           
=======================================
+ Hits         3145     3146    +1     
  Misses         12       12           
  Partials        8        8           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@DanielNoord DanielNoord left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase this as well to get the new CI setup!

Comment thread tests/unit/test_regressions.py Outdated

def test_pylint_disable_next_stays_with_first_import_issue_2054():
test_input = (
"# pylint: disable-next=no-name-in-module\n"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change the content of the comments to show that they are properly attached to the imports by differentiating them

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Neallin-917 Please see this comment :)

@Neallin-917
Neallin-917 force-pushed the codex/fix-2054-pylint-disable-next branch from 3b0226e to 47460eb Compare August 18, 2026 02:26
@Neallin-917

Copy link
Copy Markdown
Author

Rebased onto current main in 47460eb to pick up the new CI setup. The targeted regression suite, Ruff checks, and the updated PR checks are green. Thanks!

@Neallin-917

Neallin-917 commented Aug 19, 2026

Copy link
Copy Markdown
Author

Addressed in 3bf67d5. The two pylint: disable-next comments now use distinct valid Pylint codes, so the expected sorted output proves each comment remains attached to its respective import. uv run pytest tests/unit/test_regressions.py passes (94 tests), along with Ruff and formatting checks.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

isort does not respect # pylint: disable-next

2 participants