astral-sh/uv

Individually specify enabled preview features in configuration

Open

#15767 opened on Sep 10, 2025

View on GitHub
 (1 comment) (2 reactions) (0 assignees)Rust (84,934 stars) (3,111 forks)batch import
configurationenhancementhelp wanted

Description

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.

Contributor guide