astral-sh/uv

Individually specify enabled preview features in configuration

Open

#15,767 建立於 2025年9月10日

在 GitHub 查看
 (1 留言) (2 反應) (0 負責人)Rust (84,934 star) (3,111 fork)batch import
configurationenhancementhelp wanted

描述

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.

貢獻者指南

Individually specify enabled preview features in configuration · astral-sh/uv#15767 | Good First Issue