Summary
Currently, preview features can be enabled in two ways:
- in configuration, with either the
tool.uv.preview key in pyproject.toml or the preview key in uv.toml; or
- on the command line, with the
--preview-features or --preview flags, or the UV_PREVIEW or UV_PREVIEW_FEATURES environment 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.
Summary
Currently, preview features can be enabled in two ways:
tool.uv.previewkey inpyproject.tomlor thepreviewkey inuv.toml; or--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
--previeworUV_PREVIEW=1) and only enabling individual features (with--preview-features=foo,bar,bazorUV_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/previewvalue from a boolean to a list of strings:Alternatively, to allow more flexibility when merging configs (plus backwards compatibility), we could use this format:
In the latter case, setting
tool.uv.preview-features.pylock = falsewould disable it, taking precedence over the feature potentially being enabled at a user level. Iftool.uv.previewwere changed tofalse, all preview features would be disabled, regardless of the content oftool.uv.preview-features.