facebook / usort

Safe, minimal import sorting for Python projects.
https://usort.readthedocs.io
MIT License
189 stars 22 forks source link

usort incorrectly treats flatten_dict as a 1st party import #245

Open sknaumov opened 1 year ago

sknaumov commented 1 year ago

Hello. I have a pylint warning after applying usort formatting:

C0411: third party import "from flatten_dict import flatten, unflatten" should be placed before "import common as cmn" (wrong-import-order)

Unfortunately, usort treats flatten_dict as a first-party dependency.

Also I've noticed that usort always separates system imports from others with an empty line, but for some reason doesn't enforce an empty line between 3rd party and 1st party imports - which seems to be an inconsistency.

amyreese commented 1 year ago

Is there a public repo that I can repro this against? Alternately, can you run usort list-imports --debug <path/to/file.py> and share a paste of the results? That should show each import detected, along with the inferred category for each one, to make sure usort is doing what you think it's doing.

Also I've noticed that usort always separates system imports from others with an empty line, but for some reason doesn't enforce an empty line between 3rd party and 1st party imports - which seems to be an inconsistency.

Can you try running again with the 1.1.0b1 beta release? I believe that has more consistent normalization of blank lines between sections, but would like to confirm that. A repro we can test against would also be helpful.

Thank you!