Skip to content

Allow configuring preview features in uv.toml and pyproject.toml#18437

Open
EliteTK wants to merge 2 commits into
mainfrom
tk/preview-features-toml
Open

Allow configuring preview features in uv.toml and pyproject.toml#18437
EliteTK wants to merge 2 commits into
mainfrom
tk/preview-features-toml

Conversation

@EliteTK

@EliteTK EliteTK commented Mar 13, 2026

Copy link
Copy Markdown
Member

Summary

This is a continuation of the excellent work by @j-helland in #16452 and #17202 and closes #15767.

This PR adds preview-features to uv.toml and pyproject.toml.

This field can be set to a boolean or to a list of features.

It is intended to supersede the preview setting itself, and conflicts with it.

There's a little bit of complexity required to ensure that setting either preview or preview-features is combined at the right point, but it's also necessary to leave them split to accurately warn when a uv.toml masks a pyproject.toml in the same directory.

Additionally there's complexity involved in making things work with deny_unknown_fields and flatten (they're incompatible so require manual flattening) and also this improves error messages somewhat.

Also (supersedes) closes #16452 and (supersedes) closes #17202.

Test Plan

Tests taken from the original PR with some alterations and a bunch of additional tests.

@EliteTK EliteTK added the enhancement New feature or improvement to existing functionality label Mar 13, 2026
@EliteTK EliteTK force-pushed the tk/preview-features-toml branch 8 times, most recently from 4b38fe3 to 1a2856f Compare March 16, 2026 23:10
@EliteTK EliteTK marked this pull request as ready for review March 16, 2026 23:22
@EliteTK EliteTK requested a review from zanieb March 16, 2026 23:33
@EliteTK EliteTK force-pushed the tk/preview-features-toml branch from 1a2856f to ae3a28e Compare March 17, 2026 19:00
@EliteTK EliteTK removed the request for review from zanieb June 2, 2026 14:20
@EliteTK EliteTK marked this pull request as draft June 3, 2026 22:32
@EliteTK EliteTK force-pushed the tk/preview-features-toml branch 2 times, most recently from 221e22b to 6669578 Compare June 4, 2026 12:59
@zanieb

zanieb commented Jun 4, 2026

Copy link
Copy Markdown
Member

Can you justify replacing the preview field? I think we'll have --preview forever and I'd expect preview = true to work ~forever too?

@EliteTK

EliteTK commented Jun 4, 2026

Copy link
Copy Markdown
Member Author

It's not replaced, just hidden and mutually exclusive. More context here: #16452 (comment) and even more context is on discord I believe (from that time).

Although as written, the docs still keep the preview documentation so it's not really hidden.

The "deprecated": true in the json schema might be a bit of an overreach in this regard?

@EliteTK EliteTK force-pushed the tk/preview-features-toml branch from 6669578 to c1b1b11 Compare June 4, 2026 15:19
@EliteTK EliteTK force-pushed the tk/preview-features-toml branch from c1b1b11 to 87d383c Compare June 5, 2026 00:54
Preview features can be configured as a boolean or list of feature names
in uv.toml, pyproject.toml, and PEP 723 metadata. These values participate
in preview resolution alongside command-line and environment settings.

Preserve the deprecated preview spelling, reject configuring both
spellings in the same document, and expose the option through settings
metadata and the generated schema.

Co-authored-by: Tomasz (Tom) Kramkowski <tom@astral.sh>
Co-authored-by: Zanie Blue <contact@zanie.dev>
@EliteTK EliteTK force-pushed the tk/preview-features-toml branch from 87d383c to e3f0438 Compare June 5, 2026 01:00
@EliteTK EliteTK marked this pull request as ready for review June 5, 2026 01:03
@EliteTK EliteTK requested review from Gankra, konstin and zanieb June 5, 2026 01:04
@astral-sh-bot

astral-sh-bot Bot commented Jun 5, 2026

Copy link
Copy Markdown

uv test inventory changes

This PR changes the tests when compared with the latest main baseline.

  • Added tests: 5
  • Removed tests: 1
  • Changed suites: 2
uv-preview: +0 / -1

Added: none

Removed:

  • uv-preview::tests::test_preview_from_args
uv::it: +5 / -0

Added:

  • uv::it::show_settings::preview_features_pyproject_toml
  • uv::it::show_settings::preview_features_uv_toml
  • uv::it::show_settings::preview_precedence
  • uv::it::show_settings::resolve_both_preview
  • uv::it::show_settings::run_pep723_script_preview_features

Removed: none

@zsol zsol self-requested a review June 11, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or improvement to existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Individually specify enabled preview features in configuration

3 participants