-
Notifications
You must be signed in to change notification settings - Fork 38
feat(pre-commit): add isort #224
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
@kattni I really like |
I like isort too! maybe there's some lib we can test it on to make sure the try/import/except blocks aren't affected? do we need to turn off any of the import-related pylint checks too, or does pylint fully endorse the changes that might be made by isort?
|
If I recall correctly, isort typically doesn't conflict with black or pylint. The only one that I'm not fully sure about is |
I went ahead and ran isort across the bundle and found at least one problem. Note: finding one problem, or a small number of problems, shouldn't stop us from doing this. We just need to be aware of the scope of the problem before opting to do it. It's the usual "pylint comment gets moved to where it doesn't have the desired effeect" problem that happens at the intersection of pylint & source formatters:
now, pylint produces the import-outside-toplevlel diagnostic, as the comment is not properly placed.
Note that I did not run black from pre-commit, just from the shell. However, I did use the 'black' profile:
|
about 50 "+" lines in the resulting diff across the bundle also contain "pylint" so that probably is approximately the scope of what will need human attention. This is in 28 separate repos. |
@jepler Awesome, thank you!! That's totally patchable. Can you provide that list of repos that will need manual patching? I have a tool that will catch repos that fail the CI as well so I'll still run that, but good to have a tentative list. |
most libs have a change introduced by isort. That wasn't what I concentrated on, because running pre-commit alone would fix the problem. The following have a change affecting a line that has a pylint comment, and are more likely to need additional work beyond running pre-commit with isort enabled:
|
I feel that my PR has generated a lot of work. Is there anything I can do to help? |
I'm happy with this, and would be willing to help patch up things if we merge this. @jepler, if you want to merge and regenerate that list, I'll happily take care of the cleanup! |
I think the cookiecutter change can be merged without immediate additional work, and it'd cover new libraries. It's just that when updating pre-commit later via adabot patch it'll require individual attention. |
oh, wait, when running isort I think we want the "black profile"
or similar |
and pylint wrong-input-order does seem to need to be disabled globally |
I would love to add isort, and happy to help update any/all libraries. The correct way at this point is:
Happy to create a new PR if desired. |
@jepler did you have an example on where |
No, I don't have that context from last year anymore, sorry. |
We are updating cookie-cutter to use ruff (#237) so this will need updating before merging. |
Since we are using:
|
That matches my understanding. As I understand it the ruff configuration will handle the sorting of imports for us. I believe this PR could be closed. |
Thanks for the ruff info. I've closed. |
Adding
isort
to have a consistent style for imports.