Skip to content
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
4 changes: 3 additions & 1 deletion src/poetry/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,9 @@ def validate(
results = super().validate(toml_data, strict)
poetry_config = toml_data["tool"]["poetry"]

results["errors"].extend(validate_object(poetry_config))
results["errors"].extend(
[e.replace("data.", "tool.poetry.") for e in validate_object(poetry_config)]
)

# A project should not depend on itself.
# TODO: consider [project.dependencies] and [project.optional-dependencies]
Expand Down
6 changes: 3 additions & 3 deletions tests/json/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_pyproject_toml_invalid_priority() -> None:
).read()
assert Factory.validate(toml) == {
"errors": [
"data.source[0].priority must be one of ['primary',"
"tool.poetry.source[0].priority must be one of ['primary',"
" 'supplemental', 'explicit']"
],
"warnings": [],
Expand All @@ -41,7 +41,7 @@ def test_self_valid() -> None:
def test_self_invalid_version() -> None:
toml: dict[str, Any] = TOMLFile(FIXTURE_DIR / "self_invalid_version.toml").read()
assert Factory.validate(toml) == {
"errors": ["data.requires-poetry must be string"],
"errors": ["tool.poetry.requires-poetry must be string"],
"warnings": [],
}

Expand All @@ -50,7 +50,7 @@ def test_self_invalid_plugin() -> None:
toml: dict[str, Any] = TOMLFile(FIXTURE_DIR / "self_invalid_plugin.toml").read()
assert Factory.validate(toml) == {
"errors": [
"data.requires-plugins.foo must be valid exactly by one definition"
"tool.poetry.requires-plugins.foo must be valid exactly by one definition"
" (0 matches found)"
],
"warnings": [],
Expand Down
14 changes: 9 additions & 5 deletions tests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,13 +392,17 @@ def test_validate_fails(fixture_dir: FixtureDirGetter) -> None:
complete = TOMLFile(fixture_dir("complete.toml"))
pyproject: dict[str, Any] = complete.read()
pyproject["tool"]["poetry"]["this key is not in the schema"] = ""
pyproject["tool"]["poetry"]["source"] = {}

expected = (
"Additional properties are not allowed "
"('this key is not in the schema' was unexpected)"
)
expected = [
"tool.poetry.source must be array",
(
"Additional properties are not allowed "
"('this key is not in the schema' was unexpected)"
),
]

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


def test_create_poetry_fails_on_invalid_configuration(
Expand Down