Individually specify enabled preview features in configuration
#15767 opened on Sep 10, 2025
Description
Summary
Currently, preview features can be enabled in two ways:
- in configuration, with either the
tool.uv.previewkey inpyproject.tomlor thepreviewkey inuv.toml; or - on the command line, with the
--preview-featuresor--previewflags, or theUV_PREVIEWorUV_PREVIEW_FEATURESenvironment variables.
There's a disparity here: On the command line, I have a choice between enabling all preview features (with --preview or UV_PREVIEW=1) and only enabling individual features (with --preview-features=foo,bar,baz or UV_PREVIEW_FEATURES=foo,bar,baz). However, in configuration, I only have the former choice, and no way to enable specific features individually.
It would be nice to have this granularity be available in configuration.
Example
A potential solution could be to change the type of the tool.uv.preview / preview value from a boolean to a list of strings:
# pyproject.toml
[tool.uv]
preview = [
"json-output",
"format"
]
Alternatively, to allow more flexibility when merging configs (plus backwards compatibility), we could use this format:
# pyproject.toml
[tool.uv]
preview = true
[tool.uv.preview-features]
json-output = true
format = true
pylock = false
In the latter case, setting tool.uv.preview-features.pylock = false would disable it, taking precedence over the feature potentially being enabled at a user level. If tool.uv.preview were changed to false, all preview features would be disabled, regardless of the content of tool.uv.preview-features.