MCPcopy Create free account
hub / github.com/vercel/vercel / maybeLoadPythonRequest

Function maybeLoadPythonRequest

packages/python-analysis/src/manifest/package.ts:704–734  ·  view source on GitHub ↗
(
  root: AbsPath,
  subdir: RelPath
)

Source from the content-addressed store, hash-verified

702 * Read and parse a .python-version file if it exists in the given subdirectory.
703 */
704async function maybeLoadPythonRequest(
705 root: AbsPath,
706 subdir: RelPath
707): Promise<PythonVersionConfig | null> {
708 const dotPythonVersionRelPath: RelPath = path.join(subdir, '.python-version');
709 const dotPythonVersionPath: AbsPath = path.join(
710 root,
711 dotPythonVersionRelPath
712 );
713 const data: string | null = await readFileTextIfExists(dotPythonVersionPath);
714
715 if (data == null) {
716 return null;
717 }
718
719 const pyreq = parsePythonVersionFile(data);
720 if (pyreq == null) {
721 throw new PythonAnalysisError({
722 message: `could not parse .python-version file: no valid Python version requests found`,
723 code: 'PYTHON_VERSION_FILE_PARSE_ERROR',
724 path: dotPythonVersionRelPath,
725 });
726 }
727
728 return {
729 kind: PythonConfigKind.PythonVersion,
730 path: dotPythonVersionRelPath,
731 data: pyreq,
732 specifier: data.trim(),
733 };
734}

Callers 1

loadPythonConfigsFunction · 0.85

Calls 3

readFileTextIfExistsFunction · 0.90
parsePythonVersionFileFunction · 0.90
joinMethod · 0.45

Tested by

no test coverage detected