Validate pyproject.toml before installing dependencies#1066
Merged
StellaHuang95 merged 10 commits intomicrosoft:mainfrom Dec 18, 2025
Merged
Validate pyproject.toml before installing dependencies#1066StellaHuang95 merged 10 commits intomicrosoft:mainfrom
StellaHuang95 merged 10 commits intomicrosoft:mainfrom
Conversation
4cc9d2f to
9cccf60
Compare
karthiknadig
previously requested changes
Dec 15, 2025
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) { |
Member
There was a problem hiding this comment.
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.
Contributor
Author
There was a problem hiding this comment.
Sounds good, made some changes to address your feedback.
eleanorjboyd
approved these changes
Dec 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.