-
Notifications
You must be signed in to change notification settings - Fork 572
Add isort to pre-commit #379
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
Conversation
ci.sh
Outdated
fi | ||
|
||
result=$(python -m isort -rc . | grep -v "Skipped") | ||
if [[ $result ]] ; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do we check here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking if unordered imports aren't remained.
python -m isort -rc .
also outputs diff when unordered imports remained.
To cover the case that developers don't set pre-commit and uploaded files have unordered imports. (Same to autopep8's check)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we check the exit code instead ($?
) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your comment is exact.
I've checked its behavior at first, but unfortunately both cases(ordered, unordered) return 0
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will look into again.
At least I found below issue(fixed) and codes. Sholud be returned non 0.
PyCQA/isort#423
https://github.com/timothycrosley/isort/blob/d093f97c1d26854fbb082e43cfae8a062dacda56/isort/main.py#L382
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could do as expected by using --check-only
opt for isort
:)
It's to keep imports clean.