-
Notifications
You must be signed in to change notification settings - Fork 36
Validate pyproject.toml before installing dependencies #1066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
4cc9d2f to
9cccf60
Compare
src/managers/builtin/pipUtils.ts
Outdated
|
|
||
| export function validatePyprojectToml(toml: tomljs.JsonMap): string | undefined { | ||
| // 1. Validate package name (PEP 508) | ||
| if (toml.project && (toml.project as tomljs.JsonMap).name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be simplified if you check toml.project and exit out early.
You can additionally have const project = toml.project as tomljs.JsonMap, you could even create a interface for the version and name fields that you need and avoid tomljs.JsonMap entirely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, made some changes to address your feedback.
This PR implements validation for
pyproject.tomlwhen installing dependencies, addressing issue #411. It's an initial implementation that covers some most common formatting errors, we can definitely expand coverage as we receive user feedback.This PR
pyproject.tomladheres to relevant PEP standards (PEP 508, PEP 440, PEP 621, PEP 518) before attempting to install packages from it and provides feedback when validation fails, allowing the user to fix the file or proceed if they choose.It added
validatePyprojectTomlinpipUtils.tswhich checks:shouldProceedAfterPyprojectValidationto display an error message with options to "Open pyproject.toml", "Continue Anyway", or "Cancel", only when user selects dependencies from incorrectly formattedpypyroject.tomlfile to install when creating environment.Example user flow:
Recording.2025-12-15.115457.mp4
helpers.validatePyproject.unit.test.tswith comprehensive unit tests.