PyCQA / PyCQA/isort

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

Open
#1,208 4 comments 0 reactions 1 assignee View on GitHub

@jhabarsingh is already working on this.

Since Jul 30, 2020.

enhancement
Dominant language
Python
Stars
7k
Forks
687
Avg merge
4h 56m
Merged PRs (30d)
2

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.