Pyright's and BasedPyright's project-wide `extraPaths` (declaredPythonImportPaths).
(file: (name: string) => string | null)
| 931 | |
| 932 | /** Pyright's and BasedPyright's project-wide `extraPaths` ({@link declaredPythonImportPaths}). */ |
| 933 | function 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. */ |
| 947 | const TOML_PATH_KEYS = { |
no test coverage detected