isort icon indicating copy to clipboard operation
isort copied to clipboard

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

Open pganssle opened this issue 4 years ago • 4 comments

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.

pganssle avatar May 20 '20 18:05 pganssle

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

jhabarsingh avatar Jul 29 '20 20:07 jhabarsingh

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

timothycrosley avatar Jul 30 '20 00:07 timothycrosley

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

Thanks!

~Timothy

timothycrosley avatar Sep 05 '20 23:09 timothycrosley

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

jhabarsingh avatar Sep 06 '20 03:09 jhabarsingh