Skip to content

Conversation

@smortezah
Copy link

Description

Added support for normalizing common Python types (pathlib.Path objects) to JSON-compatible values during TOON encoding. This enhancement makes it easier to serialize Python applications that work with file paths.

Type of Change

  • New feature (non-breaking change that adds functionality)
  • Test coverage improvement

Related Issues

Closes # (if applicable)

Changes Made

  • Extended normalize_value() function in src/toon_format/normalize.py:

    • Added pathlib.Path, PurePath, PurePosixPath, PureWindowsPath → string conversion
    • Updated module docstring to document new type conversions
    • Added detailed examples in function docstring
  • Added comprehensive test coverage in tests/test_normalization.py:

    • TestPathNormalization class with 5 tests covering Path object handling

SPEC Compliance

  • This PR implements/fixes spec compliance
  • Spec section(s) affected: Section 3 (Normalization) - extends Python-specific normalization
  • Spec version: v1.5 (maintains compatibility while extending Python support)

Testing

  • All existing tests pass
  • Added new tests for changes
  • Tested on Python 3.8
  • Tested on Python 3.9
  • Tested on Python 3.10
  • Tested on Python 3.11
  • Tested on Python 3.12

Test Output

$ pytest tests/test_normalization.py::TestPathNormalization -v
======================== test session starts =========================
collected 5 tests

tests/test_normalization.py::TestPathNormalization::test_path_to_string PASSED
tests/test_normalization.py::TestPathNormalization::test_relative_path PASSED
tests/test_normalization.py::TestPathNormalization::test_pure_path PASSED
tests/test_normalization.py::TestPathNormalization::test_path_in_array PASSED
tests/test_normalization.py::TestPathNormalization::test_path_in_nested_structure PASSED

$ pytest tests/ -v
======================== 818 passed, 13 skipped in 2.34s =========================

@smortezah smortezah requested a review from a team as a code owner November 10, 2025 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant