From 0a2ed515423f1aad8fc14313e9d2dcf0a27e9b35 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 11 Oct 2024 01:58:30 -0400 Subject: [PATCH] feat: support PEP 735 Signed-off-by: Henry Schreiner --- .../pyproject_toml.schema.json | 31 ++++++++++++++++++- tests/examples/simple/depgroups.toml | 3 ++ .../pep735/invalid-group.errors.txt | 1 + .../pep735/invalid-group.toml | 2 ++ .../pep735/invalid-key.errors.txt | 1 + .../invalid-examples/pep735/invalid-key.toml | 2 ++ .../pep735/not-pep508.errors.txt | 1 + tests/invalid-examples/pep735/not-pep508.toml | 2 ++ 8 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 tests/examples/simple/depgroups.toml create mode 100644 tests/invalid-examples/pep735/invalid-group.errors.txt create mode 100644 tests/invalid-examples/pep735/invalid-group.toml create mode 100644 tests/invalid-examples/pep735/invalid-key.errors.txt create mode 100644 tests/invalid-examples/pep735/invalid-key.toml create mode 100644 tests/invalid-examples/pep735/not-pep508.errors.txt create mode 100644 tests/invalid-examples/pep735/not-pep508.toml diff --git a/src/validate_pyproject/pyproject_toml.schema.json b/src/validate_pyproject/pyproject_toml.schema.json index f540981..cebf22b 100644 --- a/src/validate_pyproject/pyproject_toml.schema.json +++ b/src/validate_pyproject/pyproject_toml.schema.json @@ -1,6 +1,5 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://packaging.python.org/en/latest/specifications/declaring-build-dependencies/", "title": "Data structure for ``pyproject.toml`` files", "$$description": [ @@ -60,6 +59,36 @@ "tool": { "type": "object" + }, + "dependency-groups": { + "type": "object", + "description": "Dependency groups following PEP 735", + "additionalProperties": false, + "patternProperties": { + "^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9])$": { + "type": "array", + "items": { + "oneOf": [ + { + "type": "string", + "description": "Python package specifiers following PEP 508", + "format": "pep508" + }, + { + "type": "object", + "additionalProperties": false, + "properties": { + "include-group": { + "description": "Another dependency group to include in this one", + "type": "string", + "pattern": "^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9])$" + } + } + } + ] + } + } + } } } } diff --git a/tests/examples/simple/depgroups.toml b/tests/examples/simple/depgroups.toml new file mode 100644 index 0000000..dfe825a --- /dev/null +++ b/tests/examples/simple/depgroups.toml @@ -0,0 +1,3 @@ +[dependency-groups] +test = ["one", "two"] +other = ["one", {include-group = "test"}] diff --git a/tests/invalid-examples/pep735/invalid-group.errors.txt b/tests/invalid-examples/pep735/invalid-group.errors.txt new file mode 100644 index 0000000..0fb54c4 --- /dev/null +++ b/tests/invalid-examples/pep735/invalid-group.errors.txt @@ -0,0 +1 @@ +dependency-groups` must not contain {'a b'} properties diff --git a/tests/invalid-examples/pep735/invalid-group.toml b/tests/invalid-examples/pep735/invalid-group.toml new file mode 100644 index 0000000..337beb7 --- /dev/null +++ b/tests/invalid-examples/pep735/invalid-group.toml @@ -0,0 +1,2 @@ +[dependency-groups] +"a b" = ["one"] diff --git a/tests/invalid-examples/pep735/invalid-key.errors.txt b/tests/invalid-examples/pep735/invalid-key.errors.txt new file mode 100644 index 0000000..9c90d19 --- /dev/null +++ b/tests/invalid-examples/pep735/invalid-key.errors.txt @@ -0,0 +1 @@ +`dependency-groups.mydep[1]` must be valid exactly by one definition diff --git a/tests/invalid-examples/pep735/invalid-key.toml b/tests/invalid-examples/pep735/invalid-key.toml new file mode 100644 index 0000000..ab97ff5 --- /dev/null +++ b/tests/invalid-examples/pep735/invalid-key.toml @@ -0,0 +1,2 @@ +[dependency-groups] +mydep = ["one", {other = "two"}] diff --git a/tests/invalid-examples/pep735/not-pep508.errors.txt b/tests/invalid-examples/pep735/not-pep508.errors.txt new file mode 100644 index 0000000..6bf2956 --- /dev/null +++ b/tests/invalid-examples/pep735/not-pep508.errors.txt @@ -0,0 +1 @@ +`dependency-groups.test[0]` must be valid exactly by one definition (0 matches found) diff --git a/tests/invalid-examples/pep735/not-pep508.toml b/tests/invalid-examples/pep735/not-pep508.toml new file mode 100644 index 0000000..83d6dd6 --- /dev/null +++ b/tests/invalid-examples/pep735/not-pep508.toml @@ -0,0 +1,2 @@ +[dependency-groups] +test = [" "]