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

Add isort as a companion to black #5132

merged 2 commits into from Nov 28, 2018

Add isort as a companion to black #5132

merged 2 commits into from Nov 28, 2018


Copy link

@dstufft dstufft commented Nov 28, 2018

Much like black, this will sort our imports automatically and provide a check that will ensure that future PRs correctly sort imports. It has been added to make reformat and of course, any editors that support actions can be configured to automatically run these as well.

The biggest differences are:

  • We now require alphabetical imports.
    • Previously we kind of half way alphabetized them, but without any real enforcement.
  • We now require seperation of stdlib, thridparty, and our own imports.
    • Previously we mostly did this, but a few imports got stuck in the wrong place.
  • import and from <foo> import <bar> are now grouped together, with import being first.
    • Previously we did basically this, but we had the import and from import styles separated as separate sections, but otherwise did the same.
  • Separate "complex" imports moved to one per import statement (from foo import bar as frob, thing as other).
    • We used to have multiple of these per statement, but isort moves them to be one per import statement.

Copy link

hynek commented Nov 28, 2018

Since this is probably my only chance until I'll have to forever hold my peace: please add lines_between_types=1 🐶 I'll get you a $DRINK_OF_YOUR_CHOICE at PyCon…a fancy one! :)

Copy link
Member Author

dstufft commented Nov 28, 2018

Thanks to @hynek I fixed a few of the issues that were different than our previous ad hoc standard. Now the isort configuration is basically what we've always done, just automatically and enforced.

@dstufft dstufft merged commit 1fbb4ac into pypi:master Nov 28, 2018
@dstufft dstufft deleted the isort branch November 28, 2018 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants