Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
robsdedude opened this issue Aug 21, 2022 · 1 comment

Comments

@robsdedude
Copy link

robsdedude commented Aug 21, 2022

from a import b

as well as

# comment
from a import b

if run with lines_before_imports = 2 they should result in

 
 
from a import b

(ignore the spaces in the empty lines, they are needed for GH to display leading empty lines)

and

# comment


from a import b

respectively, but they don't. If you add any non-import statement to the files (e.g., foo = bar) the output is as expected.

@robsdedude robsdedude changed the title lines_before_import is ignored for files that only contain imports and comments lines_before_import is being ignored for files that only contain imports and comments Aug 21, 2022
robsdedude added a commit to robsdedude/isort that referenced this issue Aug 21, 2022
The config option `lines_before_import` was ignored if the file only contained
imports + optionally a leading comment.
@robsdedude
Copy link
Author

I stumbled over this while investigating #1855

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

No branches or pull requests

1 participant