Skip to content

Commit a2c3281

Browse files
fix: 🐛 remove package prefix in error message (#241)
# Description The hardcoded prefix led to some issues when integrating check-datapackage into sprout. See #240 for details. Test with: ```sh uv run python -c 'import check_datapackage as cdp; cdp.check({"resources": []}, error=True)' ``` Output before this PR: ``` 1 issue was found in your `datapackage.json`: At package.resources: | | resources: [] | ^^ [] should be non-empty ``` Output after this PR: ``` 1 issue was found in your `datapackage.json`: At resources: | | resources: [] | ^^ [] should be non-empty ``` I will say that with a top level path like this, it does appear a bit redundant to list `resources` twice and the `package.resource` aesthetically gave a bit more variation, but it is minor and for more nested paths this will look good and be shorter. Closes #240 Needs a quick review. ## Checklist - [ ] Formatted Markdown - [x] Ran `just run-all` --------- Co-authored-by: Luke W. Johnston <lwjohnst86@users.noreply.github.com>
1 parent b5cae5f commit a2c3281

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/check_datapackage/check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def _create_explanation(issue: Issue) -> str:
142142

143143
number_of_carets = len(str(issue.instance))
144144
return ( # noqa: F401
145-
f"At package{issue.jsonpath.removeprefix('$')}:\n"
145+
f"At {issue.jsonpath.removeprefix('$.')}:\n"
146146
"|\n"
147147
f"| {property_name}{': ' if property_name else ' '}{issue.instance}\n"
148148
f"| {' ' * len(property_name)} [red]{'^' * number_of_carets}[/red]\n"

0 commit comments

Comments
 (0)