( root: AbsPath, subdir: RelPath )
| 495 | } |
| 496 | |
| 497 | async function maybeLoadPyProjectToml( |
| 498 | root: AbsPath, |
| 499 | subdir: RelPath |
| 500 | ): Promise<PythonManifest | null> { |
| 501 | const pyprojectTomlRelPath = path.join(subdir, 'pyproject.toml'); |
| 502 | const pyprojectTomlPath = path.join(root, pyprojectTomlRelPath); |
| 503 | let pyproject: PyProjectToml | null; |
| 504 | try { |
| 505 | pyproject = await readConfigIfExists( |
| 506 | pyprojectTomlPath, |
| 507 | PyProjectTomlSchema |
| 508 | ); |
| 509 | } catch (error: unknown) { |
| 510 | if (error instanceof PythonAnalysisError) { |
| 511 | error.path = pyprojectTomlRelPath; |
| 512 | throw error; |
| 513 | } |
| 514 | throw new PythonAnalysisError({ |
| 515 | message: `could not parse pyproject.toml: ${error instanceof Error ? error.message : String(error)}`, |
| 516 | code: 'PYTHON_PYPROJECT_PARSE_ERROR', |
| 517 | path: pyprojectTomlRelPath, |
| 518 | }); |
| 519 | } |
| 520 | |
| 521 | if (pyproject == null) { |
| 522 | return null; |
| 523 | } |
| 524 | |
| 525 | // Inject contents of uv.toml into pyproject.toml, overriding |
| 526 | // [tool.uv]. |
| 527 | const uvTomlRelPath = path.join(subdir, 'uv.toml'); |
| 528 | const uvTomlPath = path.join(root, uvTomlRelPath); |
| 529 | let uvToml: import('./uv-config/types').UvConfig | null; |
| 530 | try { |
| 531 | uvToml = await readConfigIfExists(uvTomlPath, UvConfigSchema); |
| 532 | } catch (error: unknown) { |
| 533 | if (error instanceof PythonAnalysisError) { |
| 534 | error.path = uvTomlRelPath; |
| 535 | throw error; |
| 536 | } |
| 537 | throw new PythonAnalysisError({ |
| 538 | message: `could not parse uv.toml: ${error instanceof Error ? error.message : String(error)}`, |
| 539 | code: 'PYTHON_UV_CONFIG_PARSE_ERROR', |
| 540 | path: uvTomlRelPath, |
| 541 | }); |
| 542 | } |
| 543 | |
| 544 | if (uvToml != null) { |
| 545 | if (pyproject.tool == null) { |
| 546 | pyproject.tool = { uv: uvToml }; |
| 547 | } else { |
| 548 | pyproject.tool.uv = uvToml; |
| 549 | } |
| 550 | } |
| 551 | |
| 552 | // Check for lock files in the same directory |
| 553 | const lockFile = await maybeLoadLockFile(root, subdir); |
| 554 |
no test coverage detected