Skip to content

Commit c1977b0

Browse files
Update the sub-schema for poetry. (#4670)
* Update the sub-schema for poetry. `"type": "string"` was missing from a few arrays. `"additionalProperties": false,` was missing from a few objects. Replaced all "oneOf" with "anyOf". For most cases in this schema, both are identical, but "anyOf" is simpler. Only for "poetry-script-table" there is a minor difference and "anyOf" is the correct option. For the 'source' property, I replaced the "if", "then" and "else" with equivalent logic that avoids these constructs. These issues showed up while converting the poetry JSON schema to a [TOML schema](https://github.com/udifuchs/toml-schema) that I am experimenting with. One feature of the JSON to TOML conversion tool is that it complains when the JSON schema is different from what the tool expects. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 6a8d70c commit c1977b0

File tree

1 file changed

+69
-42
lines changed

1 file changed

+69
-42
lines changed

src/schemas/json/partial-poetry.json

Lines changed: 69 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"description": "A Python packaging format."
4545
},
4646
"poetry-package-formats": {
47-
"oneOf": [
47+
"anyOf": [
4848
{
4949
"$ref": "#/definitions/poetry-package-format"
5050
},
@@ -58,7 +58,7 @@
5858
"description": "The format(s) for which the package must be included."
5959
},
6060
"poetry-dependency-any": {
61-
"oneOf": [
61+
"anyOf": [
6262
{
6363
"$ref": "#/definitions/poetry-dependency"
6464
},
@@ -140,13 +140,14 @@
140140
"additionalProperties": false,
141141
"properties": {
142142
"git": {
143-
"type": "string",
144143
"description": "The url of the git repository.",
145144
"anyOf": [
146145
{
146+
"type": "string",
147147
"format": "uri"
148148
},
149149
{
150+
"type": "string",
150151
"pattern": "^([A-Za-z0-9\\-]+@|https://|http://)[A-Za-z][A-Za-z0-9+.-]*(:|/)[A-Za-z0-9\\-\\.]+(/[A-Za-z0-9\\-_\\.]+)+\\.git$"
151152
}
152153
]
@@ -314,7 +315,7 @@
314315
"type": "array",
315316
"minItems": 1,
316317
"items": {
317-
"oneOf": [
318+
"anyOf": [
318319
{
319320
"$ref": "#/definitions/poetry-dependency"
320321
},
@@ -337,8 +338,7 @@
337338
}
338339
},
339340
"poetry-script-table": {
340-
"type": "object",
341-
"oneOf": [
341+
"anyOf": [
342342
{
343343
"$ref": "#/definitions/poetry-extra-script-legacy"
344344
},
@@ -413,14 +413,17 @@
413413
}
414414
},
415415
"poetry-build-section": {
416-
"oneOf": [
416+
"anyOf": [
417417
{
418418
"$ref": "#/definitions/poetry-build-script"
419419
},
420420
{
421421
"$ref": "#/definitions/poetry-build-config"
422422
}
423423
]
424+
},
425+
"poetry-priority": {
426+
"enum": ["default", "primary", "secondary", "supplemental", "explicit"]
424427
}
425428
},
426429
"type": "object",
@@ -489,6 +492,9 @@
489492
},
490493
"classifiers": {
491494
"type": "array",
495+
"items": {
496+
"type": "string"
497+
},
492498
"description": "A list of trove classifiers."
493499
},
494500
"packages": {
@@ -543,6 +549,9 @@
543549
},
544550
"exclude": {
545551
"type": "array",
552+
"items": {
553+
"type": "string"
554+
},
546555
"description": "A list of files and folders to exclude."
547556
},
548557
"dependencies": {
@@ -551,7 +560,6 @@
551560
"properties": {
552561
"python": {
553562
"$ref": "#/definitions/poetry-dependency",
554-
"type": "string",
555563
"description": "The Python versions the package is compatible with."
556564
}
557565
},
@@ -568,6 +576,7 @@
568576
"$ref": "#/definitions/poetry-dependency-any"
569577
}
570578
},
579+
"additionalProperties": false,
571580
"x-tombi-table-keys-order": "ascending"
572581
},
573582
"extras": {
@@ -580,6 +589,7 @@
580589
}
581590
}
582591
},
592+
"additionalProperties": false,
583593
"x-tombi-table-keys-order": "ascending"
584594
},
585595
"group": {
@@ -610,6 +620,7 @@
610620
"additionalProperties": false
611621
}
612622
},
623+
"additionalProperties": false,
613624
"x-tombi-table-keys-order": "ascending"
614625
},
615626
"build": {
@@ -620,7 +631,7 @@
620631
"description": "A hash of scripts to be installed.",
621632
"patternProperties": {
622633
"^[a-zA-Z-_.0-9]+$": {
623-
"oneOf": [
634+
"anyOf": [
624635
{
625636
"$ref": "#/definitions/poetry-script-legacy"
626637
},
@@ -630,6 +641,7 @@
630641
]
631642
}
632643
},
644+
"additionalProperties": false,
633645
"x-tombi-table-keys-order": "ascending"
634646
},
635647
"plugins": {
@@ -657,9 +669,11 @@
657669
"^[a-zA-Z-_.0-9]+$": {
658670
"type": "string"
659671
}
660-
}
672+
},
673+
"additionalProperties": false
661674
}
662675
},
676+
"additionalProperties": false,
663677
"x-tombi-table-keys-order": "ascending"
664678
},
665679
"urls": {
@@ -670,46 +684,59 @@
670684
"description": "The full url of the custom url."
671685
}
672686
},
687+
"additionalProperties": false,
673688
"x-tombi-table-keys-order": "ascending"
674689
},
675690
"source": {
676691
"$comment": "The unique 'pypi' source constraint is not implemented yet.",
677692
"type": "array",
678693
"items": {
679-
"type": "object",
680-
"additionalProperties": false,
681-
"required": ["name"],
682-
"properties": {
683-
"name": {
684-
"type": "string",
685-
"description": "The name of the source."
686-
},
687-
"url": {
688-
"type": "string",
689-
"format": "uri",
690-
"description": "The url of the source."
694+
"anyOf": [
695+
{
696+
"type": "object",
697+
"additionalProperties": false,
698+
"required": ["name"],
699+
"properties": {
700+
"name": {
701+
"const": "pypi",
702+
"description": "The name of the source."
703+
},
704+
"priority": {
705+
"$ref": "#/definitions/poetry-priority",
706+
"description": "The priority of the source."
707+
}
708+
}
691709
},
692-
"priority": {
693-
"enum": [
694-
"default",
695-
"primary",
696-
"secondary",
697-
"supplemental",
698-
"explicit"
699-
],
700-
"description": "The priority of the source."
710+
{
711+
"type": "object",
712+
"additionalProperties": false,
713+
"required": ["name", "url"],
714+
"properties": {
715+
"name": {
716+
"allOf": [
717+
{
718+
"type": "string"
719+
},
720+
{
721+
"not": {
722+
"const": "pypi"
723+
}
724+
}
725+
],
726+
"description": "The name of the source."
727+
},
728+
"url": {
729+
"type": "string",
730+
"format": "uri",
731+
"description": "The url of the source."
732+
},
733+
"priority": {
734+
"$ref": "#/definitions/poetry-priority",
735+
"description": "The priority of the source."
736+
}
737+
}
701738
}
702-
},
703-
"if": {
704-
"properties": { "name": { "const": "pypi" } }
705-
},
706-
"then": {
707-
"propertyNames": { "not": { "const": "url" } }
708-
},
709-
"else": {
710-
"required": ["url"],
711-
"properties": { "url": true }
712-
}
739+
]
713740
}
714741
}
715742
}

0 commit comments

Comments
 (0)