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

Allow 2 spaces after an import block #119

Closed
dwaynebailey opened this issue Feb 14, 2014 · 4 comments
Closed

Allow 2 spaces after an import block #119

dwaynebailey opened this issue Feb 14, 2014 · 4 comments
Labels
enhancement New feature or request

Comments

@dwaynebailey
Copy link
Contributor

While PEP8 is unclear about how many lines after the import block it does say this:
"Separate top-level function and class definitions with two blank lines."

So in our code we add two lines after imports to closely match our high level double line breaks.

This probably isn't what other people do so being able to set the blank line following an import block would be a good option

@timothycrosley
Copy link
Member

Hi @dwaynebailey,

Thanks for pointing out this area for improvement. Currently, isort does add 2 lines if it sees the next item code construct is a class, decorator, or function - but one line otherwise. To fix the issue you are facing I plan on adding a "lines_after_import" option, that when set to a number of new lines will force this number independent to the code construct that follows.

Thanks!

Timothy

@timothycrosley
Copy link
Member

Thanks for reporting this issue, it has been fixed in version 3.5.0 with the addition of the 'lines_after_imports' setting.

~Timothy

@dwaynebailey
Copy link
Contributor Author

Thanks for all these changes. Tested and seems to be working great.

@excitoon
Copy link

@timothycrosley lines_after_import=2 does not help in all cases unfortunately:

if sys.version > (3, 8):
  import xxx

  class Abc:
    ...

In this example, I would like to have lai=1 for non-top-level imports. 🤷‍♂️🤷‍♂️🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants