Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

schema: relax validation to allow additional props #369

Merged
merged 1 commit into from
Jun 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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