Introduce PreviewFeature to clarify intent throughout the codebase#17670
Merged
Conversation
13bf31d to
3c42651
Compare
3c42651 to
2017756
Compare
zanieb
approved these changes
Jan 23, 2026
pull Bot
pushed a commit
to tjni/uv
that referenced
this pull request
Jun 3, 2026
## Summary astral-sh#17670 regressed our ability to accept unknown preview flags with a warning. This PR addresses this regression. In addition to this, the PR also fixes the error message for an empty preview feature (and adds tests for this), and removes the `value_enum` Clap derive attribute which wasn't working (because the type of the option value had never in the history of its existence implemented `clap::ValueEnum`), and if it somehow started to, it would also have caused this regression. ## Test Plan 4 new integration tests, two for the empty preview case, and two for this regression case. A new unit test case for the regression. And a minor edit to an existing unit test case to exercise the new code.
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.
Summary
This PR replaces
bitflagsin favour ofenumflags2(which we already transitively depended on) so thatPreviewFeaturescan be replaced withPreviewFeaturewhich is an enum. This clarifies intent in cases where we only care about one specificPreviewFeature.To avoid a bunch of boilerplate changes, the
Previewwrapper has been kept and creation now involves a&[PreviewFeature]in all cases. The alternative was to have everything which initialises aPreviewuseBitFlagsdirectly and possibly to removePreviewentirely but this keeps things simpler and limits the changes throughout the rest of the codebase solely to changes which deal with the name changes (ALL_CAPS to PascalCase) and the impact on--show-settingswhich I don't believe we care about stability of output for?The changes to
--show-settingscould be avoided with some customDebugimplementation but that seems excessive.This PR will impact #16452. But the changes were inspired by trying to remove the need for that particular PR to add more runtime type checking.
Test Plan
Existing tests were adjusted (I also fixed some missing cases). The test for panicking in cases which are now prevented through the use of type changes has been dropped. All the rest of the tests were ran, snapshot changes reviewed and applied.