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

Function pyrightExtraPaths

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

Pyright's and BasedPyright's project-wide `extraPaths` (declaredPythonImportPaths).

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

Source from the content-addressed store, hash-verified

931
932/** Pyright's and BasedPyright's project-wide `extraPaths` ({@link declaredPythonImportPaths}). */
933function pyrightExtraPaths(file: (name: string) => string | null): string[] {
934 const json = file('pyrightconfig.json');
935 if (json !== null) {
936 // Pyright reads it as JSON with comments and trailing commas.
937 const config: unknown = parseJsonc(json, [], { allowTrailingComma: true });
938 const extra = config && typeof config === 'object' ? (config as { extraPaths?: unknown }).extraPaths : null;
939 return Array.isArray(extra) ? extra.filter((item): item is string => typeof item === 'string') : [];
940 }
941 return tableBodies(file('pyproject.toml'), ['tool.pyright', 'tool.basedpyright']).flatMap((body) =>
942 tomlPathList(body, 'extraPaths', false)
943 );
944}
945
946/** Where the value of each key {@link tomlPathList} reads starts, on a line of a table body. */
947const TOML_PATH_KEYS = {

Callers 1

Calls 3

tableBodiesFunction · 0.85
tomlPathListFunction · 0.85
fileFunction · 0.50

Tested by

no test coverage detected