PyCQA / isort

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

Firstparty + `from ... import ...` corner case #2167

Open thejcannon opened 1 year ago

thejcannon commented 1 year ago

:wave:

I come from pantsbuild land! I'm looking at trying to help world-model in this issue

One attempt was to specify each "known" module that we're going to supply (with -p=...) but ran into an interesting corner case.

Given

import requests

from subdirA import fileA

Running isort -p=subdir.fileA file.py (where subdir.fileA isn't in the sandbox we're running isort in) puts both imports together. Whereas:

import requests

import subdirA.fileA

doesn't.

thejcannon commented 1 year ago

I guess it's a flavor of ambiguity whether fileA is assumed to be a non-module object in subdirA, or whether we can also be OK with maybe thinking fileA could also be a module.