MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / pytestPythonPath

Function pytestPythonPath

src/resolution/import-resolver.ts:913–930  ·  view source on GitHub ↗

pytest's `pythonpath`, from the one config file pytest takes (declaredPythonImportPaths).

(file: (name: string) => string | null)

Source from the content-addressed store, hash-verified

911
912/** pytest's `pythonpath`, from the one config file pytest takes ({@link declaredPythonImportPaths}). */
913function pytestPythonPath(file: (name: string) => string | null): string[] {
914 const toml = (bodies: string[]): string[] => bodies.flatMap((body) => tomlPathList(body, 'pythonpath', true));
915 const ini = (bodies: string[]): string[] => bodies.flatMap((body) => iniPathList(body));
916 for (const name of ['pytest.toml', '.pytest.toml']) {
917 const text = file(name);
918 if (text !== null) return toml(tableBodies(text, ['pytest']));
919 }
920 for (const name of ['pytest.ini', '.pytest.ini']) {
921 const text = file(name);
922 if (text !== null) return ini(tableBodies(text, ['pytest']));
923 }
924 // The other three are pytest's only with its table in them.
925 const pyproject = tableBodies(file('pyproject.toml'), ['tool.pytest', 'tool.pytest.ini_options']);
926 if (pyproject.length > 0) return toml(pyproject);
927 const tox = tableBodies(file('tox.ini'), ['pytest']);
928 if (tox.length > 0) return ini(tox);
929 return ini(tableBodies(file('setup.cfg'), ['tool:pytest']));
930}
931
932/** Pyright's and BasedPyright's project-wide `extraPaths` ({@link declaredPythonImportPaths}). */
933function pyrightExtraPaths(file: (name: string) => string | null): string[] {

Callers 1

Calls 4

tomlFunction · 0.85
tableBodiesFunction · 0.85
iniFunction · 0.85
fileFunction · 0.50

Tested by

no test coverage detected