Skip to content

Commit

Permalink
schema: relax validation to allow additional props
Browse files Browse the repository at this point in the history
This change helps migrate validation of non-core specific sections
in pyproject.toml into poetry frontend.
  • Loading branch information
abn authored and neersighted committed May 29, 2022
1 parent dfd1b39 commit 8948f98
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 47 deletions.
43 changes: 1 addition & 42 deletions src/poetry/core/json/schemas/poetry-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "http://json-schema.org/draft-04/schema#",
"name": "Package",
"type": "object",
"additionalProperties": false,
"additionalProperties": true,
"required": [
"name",
"version",
Expand Down Expand Up @@ -188,16 +188,6 @@
"build": {
"$ref": "#/definitions/build-section"
},
"source": {
"type": "array",
"description": "A set of additional repositories where packages can be found.",
"additionalProperties": {
"$ref": "#/definitions/repository"
},
"items": {
"$ref": "#/definitions/repository"
}
},
"scripts": {
"type": "object",
"description": "A hash of scripts to be installed.",
Expand Down Expand Up @@ -627,37 +617,6 @@
}
}
},
"repository": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"description": "The name of the repository"
},
"url": {
"type": "string",
"description": "The url of the repository",
"format": "uri"
},
"default": {
"type": "boolean",
"description": "Make this repository the default (disable PyPI)"
},
"secondary": {
"type": "boolean",
"description": "Declare this repository as secondary, i.e. it will only be looked up last for packages."
},
"links": {
"type": "boolean",
"description": "Declare this as a link source. Links at uri/path can point to sdist or bdist archives."
},
"indexed": {
"type": "boolean",
"description": "For PEP 503 simple API repositories, pre-fetch and index the available packages. (experimental)"
}
}
},
"build-script": {
"type": "string",
"description": "The python script file used to build extensions."
Expand Down
7 changes: 2 additions & 5 deletions tests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,9 @@ def test_validate_fails() -> None:
complete = TOMLFile(fixtures_dir / "complete.toml")
doc: dict[str, Any] = complete.read()
content = doc["tool"]["poetry"]
content["this key is not in the schema"] = ""
content["authors"] = "this is not a valid array"

expected = (
"Additional properties are not allowed "
"('this key is not in the schema' was unexpected)"
)
expected = "[authors] 'this is not a valid array' is not of type 'array'"

assert Factory.validate(content) == {"errors": [expected], "warnings": []}

Expand Down

0 comments on commit 8948f98

Please sign in to comment.