Skip to content

fix(python): preserve target types in integer widening - #5086

Closed
dbrattli wants to merge 1 commit into
mainfrom
fix/python-integer-widening
Closed

dbrattli wants to merge 1 commit into
mainfrom
fix/python-integer-widening

Conversation

@dbrattli

Copy link
Copy Markdown
Collaborator

The Thoth.Json.Python 0.7.0 update adds codec.py, exposing two Pyright errors where byte and uint16 encoders pass their original values to a method expecting uint32. The F# source explicitly converts these values, but Python's numeric replacements discard widening conversions and retain the source wrapper. This also lets subsequent operations use the wrong integer width.

Construct the target numeric type when widening, preserving both the runtime type and arithmetic width. Add regressions for sbyte-to-int16, byte-to-uint16, byte-to-uint32, and uint16-to-uint32 conversions. The generated codec remains covered by Pyright without adding an exclusion.

@github-actions

Copy link
Copy Markdown
Contributor

Python Type Checking Results (Pyright)

Metric Value
Total errors 34
Files with errors 4
Excluded files 4
New errors ✅ No
Excluded files with errors (4 files)

These files have known type errors and are excluded from CI. Remove from pyrightconfig.ci.json as errors are fixed.

File Errors Status
temp/tests/Python/test_hash_set.py 18 Excluded
temp/tests/Python/test_applicative.py 12 Excluded
temp/tests/Python/test_nested_and_recursive_pattern.py 2 Excluded
temp/tests/Python/fable_modules/thoth_json_python/encode.py 2 Excluded

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