Added config file settings validation - #1
Closed
j-helland wants to merge 2 commits into
Closed
Conversation
…e fields * Instead of merging commandline `--preview-features` with config file `preview-features`, now the commandline arguments take precedence. This matches the semantics of how uv handles other commandline arguments. * Removed unnecessary `PreviewFeaturesMode` type. * Fixed bug with `PreviewFeatures` serde serializer that produced a list of lists instead of a flat list as expected.
j-helland
force-pushed
the
jwh/config-file-validation
branch
from
December 21, 2025 01:41
3d6b8cf to
59fd4f9
Compare
Specifically, disallow specifying both `preview` and `preview-features` in the config files. The implementation is intended to be extensible, should more validation rules be needed in the future.
j-helland
force-pushed
the
jwh/config-file-validation
branch
from
December 21, 2025 01:49
59fd4f9 to
ab5f1cd
Compare
j-helland
commented
Dec 21, 2025
Comment on lines
+7
to
+9
| pub(crate) trait Validator<Context = (), Err = ValidationError> { | ||
| fn validate(&self, ctx: &Context) -> Result<(), Err>; | ||
| } |
Owner
Author
There was a problem hiding this comment.
This trait might be a bit over-engineered. If we think that there will be lots of additional validation rules in the future, something like this makes sense. If not, simplifying to something like validate_uv_toml would be better.
YAGNI?
Comment on lines
+53
to
54
| options.validate(&Context { path: &file })?; | ||
| validate_uv_toml(&file, &options)?; |
Owner
Author
There was a problem hiding this comment.
I didn't consolidate validate_uv_toml into the validator trait impl because it actually doesn't get called in the pyproject.toml branch.
j-helland
marked this pull request as ready for review
December 21, 2025 01:50
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.
Relates to astral-sh#16452
Summary
Per discussion astral-sh#16452 (comment), it was determined that we need to have additional config validation for the
previewandpreview-featuresfields.This is a sketch of how we might approach that via a
Validatortrait implemented forOptionsandGlobalOptions.Test Plan
New and existing automated tests.