Reject pyproject.toml in --config-file (#5842)

This already rejects `pyproject.toml`... but because the schema
validation is relaxed (we allow unknown fields, and all fields are
optional), a `pyproject.toml` doesn't get properly rejected here.

This PR makes the schema stricter, but in a safe way (by adding the
other `tool.uv` fields, like `workspace`, as any).

Closes #5832.
This commit is contained in:
Charlie Marsh 2024-08-06 19:40:59 -04:00 committed by GitHub
parent fae9a70ca0
commit 9b06b3905d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 266 additions and 1 deletions

View file

@ -76,10 +76,14 @@ pub struct Tool {
pub uv: Option<ToolUv>,
}
// NOTE(charlie): When adding fields to this struct, mark them as ignored on `Options` in
// `crates/uv-settings/src/settings.rs`.
#[derive(Serialize, Deserialize, OptionsMetadata, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "kebab-case")]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct ToolUv {
/// The sources to use (e.g., workspace members, Git repositories, local paths) when resolving
/// dependencies.
pub sources: Option<BTreeMap<PackageName, Source>>,
/// The workspace definition for the project, if any.
#[option_group]