8000 Better error message for implicit branches by erikbosch · Pull Request #437 · COVESA/vss-tools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Better error message for implicit branches #437

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

Merged
merged 2 commits into from
Mar 10, 2025
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
10 changes: 9 additions & 1 deletion src/vss_tools/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def as_dict(
class VSSData(VSSRaw):
model_config = ConfigDict(extra="allow")
type: NodeType
description: str
description: str = ""
comment: str | None = None
delete: bool = False
deprecation: str | None = None
Expand All @@ -126,6 +126,14 @@ def check_const_uid_format(cls, v: str | None) -> str | None:
assert bool(re.match(pattern, v)), f"'{v}' is not a valid 'constUID'"
return v

@model_validator(mode="after")
def ensure_description(self) -> Self:
"""Give better explanation for empty description."""
ass 8000 ert (
self.description != ""
), "All nodes in the final tree must have a description. Implicit branches are not allowed in final tree!"
return self


class VSSDataBranch(VSSData):
instances: Any = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ def test_description_error(vspec_file: str, type_file: str, type_out_file: str,
assert process.returncode != 0
log_content = log.read_text()
print(log_content)
assert "'type': 'missing'" in log_content
assert "'type': 'assertion_error'" in log_content
assert "1 model error(s):" in log_content
2 changes: 1 addition & 1 deletion tests/vspec/test_overlay/test_overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@ def test_overlay_branch_error(tmp_path):
assert process.returncode != 0
log_content = log.read_text()
assert "'A.AB' has 1 model error(s)" in log_content
assert "'type': 'missing'" in log_content
assert "'type': 'assertion_error'" in log_content
assert "description" in log_content
0