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

Disable the blank line inserted at the top of the imports #148

Closed
dbatten5 opened this issue Oct 12, 2021 · 5 comments
Closed

Disable the blank line inserted at the top of the imports #148

dbatten5 opened this issue Oct 12, 2021 · 5 comments

Comments

@dbatten5
Copy link
Contributor

Description

I wasn't sure if this is a bug or a feature, but whenever I run autoimport a blank line is inserted above the import statements.

before running autoimport:
image

after running autoimport:
image

Possible Solution

If this is a feature, it would be great to have a config option to turn it off. If it's a bug, should be as simple as removing whatever is inserting it, I'd be happy to open a PR depending on what needs to be done.

Additional context

I'm running this from the command line via a vim command: :!autoimport %

@lyz-code
Copy link
Owner

Hi @dbatten5 , thank you for taking the time to open the issue and volunteering to do a PR. I'm afraid it's a "feature", autoimport parses the source code and divides it into four sections: header, imports, typing, and code. You can see it here. I thought it was interesting to add a new line between each section to improve readability.

That being said, I'm not against adding a config option to disable this behaviour. Sadly, autoimport doesn't yet have that feature implemented, so there is no way to deviate from the standard opinionated workflow. This has been raised too in yamlfix another fixer I maintain. If you were to make a PR I'd point in that direction.

Ideally for me, autoimport could read it's configuration from a section in the pyproject.toml project file, to avoid creating new fixer files in the repository, but if you have other ideas, I'm more than open to them.

@dbatten5
Copy link
Contributor Author

hi @lyz-code yeah i think reading from pyproject.toml would be a good starting point. i'd be happy to try and implement that and once that's in place could tackle the blank line config option?

@lyz-code
Copy link
Owner

Sounds really good to me :)

@dbatten5
Copy link
Contributor Author

just coming back to this now - i think this is mentioned in the docs as well but typically i just run black after autoimport which resolves any potential formatting issues. happy to close this issue as i don't really see it as an issue any more

@lyz-code
Copy link
Owner

I'm fine with closing it too, if anyone still sees it as an issue, please
comment here and we'll reopen it.

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

2 participants