Skip to content
Draft
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
6 changes: 5 additions & 1 deletion core/wren/src/wren/utils_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# report the total but stop naming each one, mirroring context_cli's
# _WARNING_SUMMARY_THRESHOLD so large batches don't flood stderr.
_SKIP_REPORT_LIMIT = 10
_REPR_LIMIT = 120


def _skipped_rows(data: object) -> list[tuple[int, object]]:
Expand Down Expand Up @@ -53,7 +54,10 @@ def _report_skipped(skipped: list[tuple[int, object]]) -> None:
err=True,
)
for i, v in corrupt[:_SKIP_REPORT_LIMIT]:
typer.echo(f" [{i}] {type(v).__name__}: {v!r:.120}", err=True)
value_repr = repr(v)
if len(value_repr) > _REPR_LIMIT:
value_repr = f"{value_repr[:_REPR_LIMIT]}… ({len(value_repr)} chars)"
typer.echo(f" [{i}] {type(v).__name__}: {value_repr}", err=True)
remaining = len(corrupt) - _SKIP_REPORT_LIMIT
if remaining > 0:
typer.echo(f" ... and {remaining} more", err=True)
Expand Down
2 changes: 2 additions & 0 deletions core/wren/tests/unit/test_type_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ def test_cli_parse_types_skip_report_truncates_past_limit() -> None:
assert "Warning: skipped 12 non-mapping row(s)" in result.stderr
assert "[1] int: 0" in result.stderr
assert "... and 2 more" in result.stderr
assert "[11] int: 10" not in result.stderr


def test_cli_parse_types_corrupt_value_repr_is_bounded() -> None:
Expand All @@ -463,6 +464,7 @@ def test_cli_parse_types_corrupt_value_repr_is_bounded() -> None:
)
_assert_success(result)
line = next(ln for ln in result.stderr.splitlines() if ln.startswith(" [1]"))
assert "… (5002 chars)" in line
assert len(line) < 200


Expand Down
Loading