astral-sh / uv

An extremely fast Python package and project manager, written in Rust.
https://docs.astral.sh/uv
Apache License 2.0
27.27k stars 786 forks source link

precommit-hook: Syntax checker for pyproject.toml - equivalent for "poetry check" #8765

Open woutervh opened 3 weeks ago

woutervh commented 3 weeks ago

Using uv 0.4.29

I went through the docs, but I did not find an equivalent for "poetry check" that check for syntax errors in pyproject.toml.

imagine a typo in a required key of pyproject.toml:

[project]
nameZ = "foo"

resulting in errors like:

> 
uv lock
error: Failed to parse: `pyproject.toml`
  Caused by: `pyproject.toml` is using the `[project]` table, but the required `project.name` field is not set
  Caused by: TOML parse error at line 17, column 1
   |
17 | [project]
   | ^^^^^^^^^
missing field `name`

Poetry has a check-command that check the syntax of pyproject.toml

 > poetry check
The Poetry configuration is invalid:
  - The fields ['name'] are required in package mode.
  - Additional properties are not allowed ('_name' was unexpected)

Use-case: precommit-hooks

tcoliver commented 2 weeks ago

I've been using uv lock --dry-run >/dev/null 2>&1 for uses like this, but I agree an explicit command would be a good improvement.