Skip to content

Introduce PreviewFeature to clarify intent throughout the codebase#17670

Merged
EliteTK merged 1 commit into
mainfrom
tk/preview-enumflags2
Jan 23, 2026
Merged

Introduce PreviewFeature to clarify intent throughout the codebase#17670
EliteTK merged 1 commit into
mainfrom
tk/preview-enumflags2

Conversation

@EliteTK

@EliteTK EliteTK commented Jan 23, 2026

Copy link
Copy Markdown
Member

Summary

This PR replaces bitflags in favour of enumflags2 (which we already transitively depended on) so that PreviewFeatures can be replaced with PreviewFeature which is an enum. This clarifies intent in cases where we only care about one specific PreviewFeature.

To avoid a bunch of boilerplate changes, the Preview wrapper has been kept and creation now involves a &[PreviewFeature] in all cases. The alternative was to have everything which initialises a Preview use BitFlags directly and possibly to remove Preview entirely 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-settings which I don't believe we care about stability of output for?

The changes to --show-settings could be avoided with some custom Debug implementation 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.

@EliteTK EliteTK added the internal A refactor or improvement that is not user-facing label Jan 23, 2026
@EliteTK EliteTK requested a review from konstin January 23, 2026 16:41
@EliteTK EliteTK force-pushed the tk/preview-enumflags2 branch from 13bf31d to 3c42651 Compare January 23, 2026 16:41
@EliteTK EliteTK marked this pull request as ready for review January 23, 2026 16:41
@EliteTK EliteTK force-pushed the tk/preview-enumflags2 branch from 3c42651 to 2017756 Compare January 23, 2026 16:46
@EliteTK EliteTK merged commit 6e3ba2f into main Jan 23, 2026
229 of 234 checks passed
@EliteTK EliteTK deleted the tk/preview-enumflags2 branch January 23, 2026 17:19
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal A refactor or improvement that is not user-facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants