Skip to content

Support --output-format=json for uv python dir and gate under preview - #21858

Open
Abhirup0 wants to merge 3 commits into
astral-sh:mainfrom
Abhirup0:python-json-output
Open

Abhirup0 wants to merge 3 commits into
astral-sh:mainfrom
Abhirup0:python-json-output

Conversation

@Abhirup0

Copy link
Copy Markdown

Summary

Closes #20509.

This adds --output-format=json support to uv python dir and puts JSON output for uv python (dir and list) under preview (PreviewFeature::JsonOutput).

  • Added PythonDirFormat (Text, Json) and updated uv python dir arguments and settings to accept --output-format.
  • Serialized {"path": ...} using PortablePath when --output-format json is requested for uv python dir (including with --bin).
  • Emitted the experimental schema warning on stderr for both uv python dir and uv python list unless --preview-features json-output (or --preview) is passed.
  • Added integration snapshot tests for python dir and python list with --output-format json, --only-installed, constraints, and preview flags.

Test Plan

  • Ran cargo test --package uv --test python -- python_dir
  • Ran cargo test --package uv --test python -- python_list_json
  • Ran cargo clippy --package uv --package uv-cli -- -D warnings
  • Ran cargo fmt --all -- --check

@Abhirup0 Abhirup0 changed the title Support \--output-format=json\ for \uv python dir\ and gate under preview Support --output-format=json for uv python dir and gate under preview Sep 20, 2026
@astral-sh-bot

astral-sh-bot Bot commented Sep 20, 2026

Copy link
Copy Markdown

uv test inventory changes

This PR changes the tests when compared with the main base revision.

  • Added tests: 8
  • Removed tests: 0
  • Changed suites: 1
uv::python: +8 / -0

Added:

  • uv::python::python_dir::python_dir_bin_json_preview
  • uv::python::python_dir::python_dir_json
  • uv::python::python_dir::python_dir_json_preview
  • uv::python::python_list::python_list_json_downloads
  • uv::python::python_list::python_list_json_empty_installed
  • uv::python::python_list::python_list_json_installed
  • uv::python::python_list::python_list_json_no_match
  • uv::python::python_list::python_list_json_preview_warning

Removed: none

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support --output-format=json for uv python

1 participant