Replies: 2 comments 15 replies
-
Why not isort? |
Beta Was this translation helpful? Give feedback.
3 replies
-
If adding |
Beta Was this translation helpful? Give feedback.
12 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We've already been dealing with occasion merge conflicts because of changes on imports (glaring at typing right now...). There are two solutions: One is https://pypi.org/project/reorder-python-imports/, via pre-commit. That even does the smart grouping following PEP8, but it does produces this rewrite:
See reasoning here. Maybe I could get used to it; part of the problem of having too many characters is solved by the smart grouping, I'm more used to the following, black compatible import style:
This does have a slightly higher chance of merge conflicts, but still solves most of them without adding a massive number of extra characters and visual clutter (it does add two lines, though). Generally I use black + isort + a flake8 grouping check to get this result; we could probably get most of the way there with isort + flake8, though, maybe with a pre-run of reorder-python-imports then manual grouping?
Note that
reorder_python_imports
has some useful tools unrelated to reordering, like removing/adding imports.Beta Was this translation helpful? Give feedback.
All reactions