Repository navigation
firstparty vs thirdparty defaults and source paths #2785
Replies: 1 comment
|
There isn't a setting that does this directly.
#!/usr/bin/env python3
import subprocess, sys
from pathlib import Path
SKIP = (".dist-info", ".egg-info", ".libs", ".data")
names = sorted({
p.name.split(".")[0]
for p in Path("/thirdparty").iterdir()
if p.name != "__pycache__" and not p.name.endswith(SKIP)
})
args = [a for n in names for a in ("-o", n)]
sys.exit(subprocess.call(["isort", *args, *sys.argv[1:]]))Then run the wrapper in place of Two things to watch for:
I tested this with isort 9.0.2 against a directory containing a regular package, a single-file module, a namespace package and a compiled extension. All four were placed in the third-party section. |
Uh oh!
There was an error while loading. Please reload this page.
i'm on a project where our first party python files are scattered in a large variety of places on the filesystem, a possibly unknown list depending on the user. Whereas our thirdparty is isolated to a single shared directory e.g. /thirdparty/ and has hundreds of modules.
Essentially we control our downloaded modules closely by sysadmins, but anyone can write code in any shared/personal directory.
So it seems to make sense to set the default section as firstparty, and then set that single directory as the thirdparty. However, the only way i've been able to figure out how to do that is to have in my team's pyproject.toml:
This also means i need to update that list whenever we get a new module off of pypi.
Is there an easier way to specify a path e.g. "/thirdparty/**" and then let everything else default to firstparty?
All reactions