PyCQA / isort

A Python utility / library to sort imports.
https://pycqa.github.io/isort/
MIT License
6.49k stars 580 forks source link

namespace package sorts differently when using the `from namespace import x` form #1208

Open pganssle opened 4 years ago

pganssle commented 4 years ago

Given a configuration file like this:

[tool.isort]
import_heading_firstparty="First party"
import_heading_thirdparty="Third party"
known_first_party = ["namespace.mymodule"]
default_section = "THIRDPARTY"

And an input file like this:

import namespace.mymodule
from namespace import mymodule

Installing isort[pyproject] (==4.3.21), I get:

# Third party
from namespace import mymodule

# First party
import namespace.mymodule

Normally this would not be a problem because you can put "namespace" into known_first_party, but when the namespace is backports or some other shared namespace, there are both first- and third-party packages in there. It seems to me that in the case of from x import y, the sorting should be based on x.y, not on x.

jhabarsingh commented 4 years ago

i want to work on this can you assign it to me

timothycrosley commented 4 years ago

@jhabarsingh, thank you for the help! I've assigned the issue to you. Let me know if I can assist at any point :)

timothycrosley commented 4 years ago

@jhabarsingh, are you still interested in taking this on? Anything I can do to help?

Thanks!

~Timothy

jhabarsingh commented 4 years ago

I would love to work on this but I am not getting how to start, I would be glad if you guide me.