rich-london-74860
09/16/2022, 7:58 PMextras
) and within that library, a file imports another module from the same library plus some 3rd party dependencies like:
from extras.foo import bar
from pyspark.sql import functions as F
pylint
correctly identifies this as wrong-import-order
since 3rd party libraries should come first, but if we manually change the import order, isort
incorrectly identifies both as 3rd party libraries and puts extras
ahead of pyspark
. It seems like isort
does not know when something is a local import.happy-kitchen-89482
09/16/2022, 9:01 PMrich-london-74860
09/16/2022, 9:26 PMextras
and isort
cannot tell that extras
is a local dependency?rich-london-74860
09/16/2022, 10:04 PMhappy-kitchen-89482
09/17/2022, 12:45 AMrich-london-74860
09/20/2022, 2:36 PMisort
is not able to properly identify the root paths. I was able to fix my problem by adding src_paths=extras
in .isort.cfg
, but it seems extremely cumbersome that pants
does not do this automatically so that every time I add another project, I need to add it to .isort.cfg
as wellhappy-kitchen-89482
09/20/2022, 5:02 PMsrc_paths
is supposed to be set to what pants calls “source roots” - package root dirs (see https://github.com/PyCQA/isort/blob/main/isort/place.py#L76-L87) , e.g., in your case the parent of extras, whereas for you extras
is the top-level package itself?rich-london-74860
09/20/2022, 6:21 PMin your case the parent of extras, whereas for youNot quite, the structure is more like:is the top-level package itself?extras
extras/
BUILD
extras/
__init__.py
foo.py
models/
model_a/
model_a/
train.py
transform.py
script.py
config.yml
BUILD
model_b/
...
and in pants.toml
[source]
root_patterns = [
"/",
"/extras/",
"/models/model_a",
"/models/model_b",
]
Perhaps this is all a misunderstanding of how the directory structure should be setup?happy-kitchen-89482
09/20/2022, 7:12 PM./pants roots
show)