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

Issue/1499/float to top single line multiline comment #1501

Merged

Conversation

timothycrosley
Copy link
Member

Fixes #1499: updates isort to correctly detect beginning of single line multi line style comment, and place imports below it.

@timothycrosley timothycrosley merged commit b808f50 into develop Sep 26, 2020
@timothycrosley timothycrosley deleted the issue/1499/float-to-top-single-line-multiline-comment branch September 26, 2020 03:49
@char101
Copy link

char101 commented Sep 26, 2020

How do I preserve the empty line between the module comment and the import lines?

@timothycrosley
Copy link
Member Author

@char101, the simplest answer to this, is that if you don't want imports to float to the very top - don't use that option (the initial intended usage was to use it every once in a while as a one-off after you've added imports in the middle of the file to keep from losing flow). However, I do think the behaviour could be improved in the case that there is an import at the top that already demonstrates a desire to have one extra line after the top comment - I just think that is a separate issue - I filed it here: #1502

Thanks!

~Timothy

@char101
Copy link

char101 commented Sep 27, 2020

I haven't upgraded isort in a few months and with the old isort, float to top is the default behavior, and I have been using it as a convenience to add new imports on top of a function without having to scroll to the top of the file, isort will then move the imports to the top of the file. So to me it feels like an unnecessary regression. Also with the old isort, as far as remember it keeps a single blank line between the module comment and the import lines.

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.

Float-to-top causes imports to appear above a module's docstring
2 participants