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 as part of the CI pipeline #804

Merged
merged 10 commits into from
May 22, 2019
Merged

Conversation

jay-tyler
Copy link
Contributor

Opening a dummy PR to get a little feedback re isort. The last 3x commits have been little experiment runs against isort and black.

When I run isort -c hug/*py on the latest commit I get the following.

ERROR: /Users/jason/python/hug/hug/__init__.py Imports are incorrectly sorted.
ERROR: /Users/jason/python/hug/hug/interface.py Imports are incorrectly sorted.

It seems black is also in a bit of a tug-of-war with isort, but I haven't looked closely enough to really understand it (yet).

@timothycrosley
Copy link
Collaborator

isort needs to be set to use a black compatible configuration:

https://github.com/python/black#how-black-wraps-lines (described at the bottom of this section)

$ isort --multi-line=3 --trailing-comma --force-grid-wrap=0 --use-parentheses --line-width=88 [ file.py ]

From command line, or:

[settings]
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
use_parentheses=True
line_length=88

in .isort.cfg

@jay-tyler
Copy link
Contributor Author

Ok, gave that I shot, but still coming back with a set of reformats. Running isort -c hug/*py on the latest commit (with isort.cfg) generates the following

ERROR: /Users/jason/python/hug/hug/__init__.py Imports are incorrectly sorted.
ERROR: /Users/jason/python/hug/hug/api.py Imports are incorrectly sorted.
ERROR: /Users/jason/python/hug/hug/development_runner.py Imports are incorrectly sorted.
ERROR: /Users/jason/python/hug/hug/input_format.py Imports are incorrectly sorted.
ERROR: /Users/jason/python/hug/hug/interface.py Imports are incorrectly sorted.
ERROR: /Users/jason/python/hug/hug/output_format.py Imports are incorrectly sorted.
ERROR: /Users/jason/python/hug/hug/route.py Imports are incorrectly sorted.
ERROR: /Users/jason/python/hug/hug/test.py Imports are incorrectly sorted.

@jay-tyler
Copy link
Contributor Author

jay-tyler commented May 21, 2019

Also is globbing stable? Or am I supposed to direct isort to a single file at a time?

There's a series of 3x commits in this PR where I was getting different results simply by running isort hug/*py over and over. A directive may have been ignored in the last of those commits.

(Also the commit msg for 3d05979 is wrong; I ran isort 2x times without the -c flag)

@timothycrosley
Copy link
Collaborator

timothycrosley commented May 21, 2019

I believe, the best way to do this in isort is isort -c --recursive hug or even nicer isort -c --diff --recursive hug so that it shows you exactly what it thinks is incorrectly sorted. Glob should work, though it's shell, and even shell setting dependent.

I made a small commit to develop, that removes the other cause of issues - I believe, which is the old usage of .editorconfig to specify some isort settings (b2f82aa)

@jay-tyler jay-tyler changed the title isort experiment -- NOT for merge isort as part of the CI pipeline May 22, 2019
@jay-tyler
Copy link
Contributor Author

Ok, I think we can merge this branch actually (even though that wasn't the original intent). Or if you want to get rid of the comment noise, happy to open another PR on a branch with a better name.

@timothycrosley
Copy link
Collaborator

No need, I'm fine keeping the comment history. This is awesome! Thank you!

@timothycrosley timothycrosley merged commit 7929150 into develop May 22, 2019
@timothycrosley timothycrosley deleted the jtyler/isort-experiment branch May 22, 2019 05:56
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