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

isort: automatic formatting/sorting of imports #2819

Closed
wants to merge 4 commits into from

Conversation

cjp256
Copy link
Contributor

@cjp256 cjp256 commented Nov 22, 2019

This commit adds an isort configuration that's pretty close to black with one exception.

Chris Patterson added 4 commits November 22, 2019 20:28
Signed-off-by: Chris Patterson <chris.patterson@canonical.com>
Nearly perfect match config to black formatting with one exception:
psf/black#251

That gap should be filled with the 'ensure_newline_before_comments=True'
that won't be honored until the next version of isort.

Signed-off-by: Chris Patterson <chris.patterson@canonical.com>
Ordering currently matters, so provide a script to perform it.

Signed-off-by: Chris Patterson <chris.patterson@canonical.com>
Signed-off-by: Chris Patterson <chris.patterson@canonical.com>
@@ -0,0 +1,7 @@
[settings]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does isort support pyproject.toml?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It in fact looks like they do!

Copy link
Collaborator

@sergiusens sergiusens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the requirement for tools/format-code.sh makes this proposal a not ideal one as everyone using a code editor could be affected and require this.

@cjp256
Copy link
Contributor Author

cjp256 commented Nov 25, 2019

the requirement for tools/format-code.sh makes this proposal a not ideal one as everyone using a code editor could be affected and require this.

I agree, but it's not really required if following the import style guide. black itself still does the actual formatting, isort will just ensure the imports are ordered and grouped appropriately.

Regardless, it looks like isort will hopefully have a new release soon which will enable the option be consistent with black. I think it would be just fine to wait until that release is available before doing anything with this PR. Then we can drop the format-code script if desired.

@cjp256 cjp256 closed this Feb 7, 2020
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.

2 participants