astral-sh/uv

Individually specify enabled preview features in configuration

已關閉

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

 (1 則留言) (3 個反應) (0 位負責人)Rust (3,111 個分叉)batch import
configurationenhancementhelp wanted

倉庫指標

星標
 (84,934 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

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.

貢獻者指南