Skip to content

Commit 16bfa8f

Browse files
committed
fix: Address Copilot code review comments
- Removed empty TestDecodeJSONIndentation class (was adding unnecessary code) - Fixed flawed assertion logic in test_json_indent_with_different_indent_sizes - Changed return type from Any to Union[JsonValue, str] for better type safety (makes it clear the function returns either a Python value or a JSON string) - Added Union to typing imports in decoder.py All 19 spec-based json_indent tests passing ✓
1 parent 9f906f9 commit 16bfa8f

2 files changed

Lines changed: 6 additions & 13 deletions

File tree

src/toon_format/decoder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"""
1010

1111
import json
12-
from typing import Any, Dict, List, Optional, Tuple
12+
from typing import Any, Dict, List, Optional, Tuple, Union
1313

1414
from ._literal_utils import is_boolean_or_null_literal, is_numeric_literal
1515
from ._parsing_utils import (
@@ -229,7 +229,7 @@ def split_key_value(line: str) -> Tuple[str, str]:
229229
return (key, value)
230230

231231

232-
def decode(input_str: str, options: Optional[DecodeOptions] = None) -> Any:
232+
def decode(input_str: str, options: Optional[DecodeOptions] = None) -> Union[JsonValue, str]:
233233
"""Decode a TOON-formatted string to a Python value.
234234
235235
This function parses TOON format and returns the decoded data. By default,

tests/test_api.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -292,14 +292,8 @@ def test_roundtrip_with_length_marker(self):
292292
assert decoded == original
293293

294294

295-
class TestDecodeJSONIndentation:
296-
"""Test decode() JSON indentation feature (Issue #10).
297-
298-
Comprehensive tests for the json_indent feature are in TestDecodeJSONIndentationWithSpecFixtures,
299-
which validates against official TOON specification fixtures.
300-
"""
301-
302-
pass
295+
# Comprehensive tests for the json_indent feature are in TestDecodeJSONIndentationWithSpecFixtures,
296+
# which validates against official TOON specification fixtures from the TOON spec repository.
303297

304298

305299
def _get_sample_decode_fixtures() -> List[tuple]:
@@ -380,9 +374,8 @@ def test_json_indent_with_different_indent_sizes(
380374

381375
# Different indent sizes should produce different strings (unless single line)
382376
if "\n" in result_2 and "\n" in result_4:
383-
# Multi-line results should differ in formatting
384-
# (indentation characters will be different)
385-
assert result_2 != result_4 or result_2.count(" ") == result_4.count(" ")
377+
# Multi-line results should differ in formatting and whitespace count
378+
assert result_2 != result_4 and result_2.count(" ") != result_4.count(" ")
386379

387380
def test_json_indent_consistency_with_plain_decode(self):
388381
"""Verify that json_indent=None produces same data as plain decode."""

0 commit comments

Comments
 (0)