Skip to content

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

Merged
timothycrosley merged 3 commits into
developfrom
issue/1499/float-to-top-single-line-multiline-comment
Sep 26, 2020
Merged

Issue/1499/float to top single line multiline comment#1501
timothycrosley merged 3 commits into
developfrom
issue/1499/float-to-top-single-line-multiline-comment

Conversation

@timothycrosley
Copy link
Copy Markdown
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
Copy Markdown

char101 commented Sep 26, 2020

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

@timothycrosley
Copy link
Copy Markdown
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
Copy Markdown

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