Skip to content

Fix #1964: lines_before_import sometimes ignored#1965

Merged
DanielNoord merged 1 commit into
PyCQA:mainfrom
robsdedude:fix/lbi-empty-only-import-files
Oct 11, 2025
Merged

Fix #1964: lines_before_import sometimes ignored#1965
DanielNoord merged 1 commit into
PyCQA:mainfrom
robsdedude:fix/lbi-empty-only-import-files

Conversation

@robsdedude

@robsdedude robsdedude commented Aug 21, 2022

Copy link
Copy Markdown
Contributor

The config option lines_before_import was ignored if the file only contained
imports + optionally a leading comment.

Fixes #1964

@robsdedude

Copy link
Copy Markdown
Contributor Author

@timothycrosley this is ready for review. It'd be great if this could be discussed and resolved before it starts lacking behind even more.

@DanielNoord

Copy link
Copy Markdown
Member

@robsdedude Are you still interested in pursuing this? We could rebase this and get this reviewed :)

@robsdedude

Copy link
Copy Markdown
Contributor Author

Hi @DanielNoord, yes please. I've been patiently waiting for a review :) I've merged main into the PR so it's ready for a review.

@codecov

codecov Bot commented Oct 5, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.19%. Comparing base (cc04d6a) to head (043261f).
⚠️ Report is 71 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1965   +/-   ##
=======================================
  Coverage   99.19%   99.19%           
=======================================
  Files          40       40           
  Lines        3105     3106    +1     
  Branches      681      681           
=======================================
+ Hits         3080     3081    +1     
  Misses         14       14           
  Partials       11       11           
🚀 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.

One comment/nit about typing in the tests. Otherwise LGTM and I'll merge after that is fixed :)

Comment thread tests/unit/test_isort.py Outdated
@DanielNoord

Copy link
Copy Markdown
Member

@robsdedude Since we use the merge queue I can't squash your commits myself. Could you perhaps squash the commits so I can merge this into main cleanly?

The config option `lines_before_import` was ignored if the file only contained
imports + optionally a leading comment.
@robsdedude robsdedude force-pushed the fix/lbi-empty-only-import-files branch from e39c314 to 043261f Compare October 5, 2025 19:05
@DanielNoord

Copy link
Copy Markdown
Member

Sorry, I missed the ping that this was squashed. Thanks for the fix!

@DanielNoord DanielNoord added this pull request to the merge queue Oct 11, 2025
Merged via the queue into PyCQA:main with commit 17746ba Oct 11, 2025
21 checks passed
@robsdedude robsdedude deleted the fix/lbi-empty-only-import-files branch October 12, 2025 09:16
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.

lines_before_import is being ignored for files that only contain imports and comments

2 participants