Closed ghost closed 2 years ago
Hi @nyuszika7h thanks for taking the time to open the issue. I see your point and agree it should be fixed.
Sadly I don't have time to implement this on my own, but if anyone is interested in contributing I think the easier way to do it is by implementing some logic when the different parts of the code are joined so that if the self.code
starts with def
or class
it should add a new \n
Available since 1.3.1
Description
autoimport removes extra blank lines after imports, even when it’s required for PEP 8 compliance (e.g. when imports are directly followed by a
class
or adef
). And also I like doinglines_after_imports = 2
in isort for consistency anyway.While you may say I can just run another auto-formatter afterwards to fix the issue, this actually makes it impossible to use autoimport as a pre-commit hook, as on the next run autoimport will remove the blank line again, and pre-commit requires all hooks to succeed.
Steps to reproduce
Create a file with the following contents:
autoimport foo.py
Current behavior
The file gets rewritten to this:
Desired behavior
The file should remain untouched.
Environment