-
Notifications
You must be signed in to change notification settings - Fork 0
fix(cli): report annotation validation errors; bump to 0.7.0 #15
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
mhusbynflow
merged 3 commits into
master
from
mhusbynflow/mhusbyn/flow/samples-py-review
Jun 9, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,18 +53,43 @@ def emit_advisory(self, message: str) -> None: | |
| if not self.json_mode: | ||
| print(message, file=self.stderr) | ||
|
|
||
| def emit_error(self, message: JsonValue, status_code: int | None = None) -> None: | ||
| def emit_error( | ||
| self, | ||
| message: JsonValue, | ||
| status_code: int | None = None, | ||
| details: list[JsonValue] | None = None, | ||
| ) -> None: | ||
| """Emit an error to stderr. | ||
|
|
||
| :param message: The error message — a string, or a structured value | ||
| (e.g. the library's field-level error dict) preserved as-is in JSON. | ||
| :param status_code: The HTTP status code, when the error came from the | ||
| server. Included in the JSON document where present. | ||
| :param details: Per-item detail behind a summary message (e.g. the | ||
| individual annotation validation errors). Listed under ``errors`` in | ||
| ``--json`` mode and one per line in human mode. | ||
| """ | ||
| if self.json_mode: | ||
| document: dict[str, JsonValue] = {"message": message} | ||
| if status_code is not None: | ||
| document["status_code"] = int(status_code) | ||
| if details: | ||
| document["errors"] = details | ||
| print(json.dumps(document), file=self.stderr) | ||
| else: | ||
| print(f"Error: {message}", file=self.stderr) | ||
| for detail in details or []: | ||
| print(f" {format_issue(detail)}", file=self.stderr) | ||
|
|
||
|
|
||
| def format_issue(issue: JsonValue) -> str: | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be a private function I'm guessing?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And we can move it back to _samples.py? |
||
| """Render a Flow ``{row, message}`` issue dict as a readable line. | ||
|
|
||
| Falls back to ``str`` for any other shape so unexpected payloads still | ||
| surface intact. | ||
| """ | ||
| if isinstance(issue, dict) and "message" in issue: | ||
| row = issue.get("row") | ||
| prefix = f"row {row}: " if row is not None else "" | ||
| return f"{prefix}{issue['message']}" | ||
| return str(issue) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We haven't added tests for this