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
merged 2 commits into from Nov 28, 2018

Conversation

Projects
None yet
2 participants
@dstufft
Copy link
Member

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.
@hynek

This comment has been minimized.

Copy link
Contributor

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! :)

@dstufft dstufft force-pushed the dstufft:isort branch from bcc9689 to 2289294 Nov 28, 2018

@dstufft

This comment has been minimized.

Copy link
Member

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 pypa:master Nov 28, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@dstufft dstufft deleted the dstufft:isort branch Nov 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment