Skip to content

Conversation

@smortezah
Copy link

This pull request improves numeric literal detection and ensures consistency between encoder and decoder utilities. It refines the is_numeric_literal function to properly handle negative numbers with leading zeros, and introduces a comprehensive test suite to verify numeric detection logic and round-trip encoding/decoding behavior.

Numeric literal detection improvements

  • Updated is_numeric_literal in src/toon_format/_literal_utils.py to correctly reject negative numbers with leading zeros (e.g., -01), ensuring stricter validation of numeric literals.

Test coverage enhancements

  • Added tests/test_numeric_detection.py with extensive tests for both is_numeric_literal and is_numeric_like, covering valid numbers, floats, scientific notation, leading zeros, non-numeric strings, and special float values.
  • Included consistency tests to verify that encoder and decoder utilities agree on valid and invalid numeric representations, especially for octal-like numbers with leading zeros.
  • Added round-trip tests to confirm that encoding and decoding preserve the correct types for valid numbers and octal-like strings, preventing unintended type conversions.

@smortezah smortezah requested a review from a team as a code owner November 6, 2025 13:09
bpradana
bpradana previously approved these changes Nov 8, 2025
Copy link

@bpradana bpradana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved!
@Justar96 is it okay if I implement git submodules for the fixtures? So the fixtures are always up to date.
What do you think? 😄

@Justar96
Copy link
Contributor

Justar96 commented Nov 8, 2025

@bpradana pls do. Thanks a lot

@davidpirogov davidpirogov self-requested a review November 9, 2025 03:34
davidpirogov
davidpirogov previously approved these changes Nov 9, 2025
@davidpirogov davidpirogov dismissed stale reviews from bpradana and themself via 9301d02 November 9, 2025 03:43
Copy link
Contributor

@davidpirogov davidpirogov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor update to test asserts, otherwise looks good to me

@davidpirogov davidpirogov requested a review from bpradana November 9, 2025 03:45
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.

4 participants