Skip to content

Conversation

@CloseChoice
Copy link
Contributor

@CloseChoice CloseChoice commented Oct 23, 2025

Change Summary

Moves the Fraction validation to rust and makes sure that we handle it analogous to Decimal. Also changes the serialization in Python mode of Fraction.

Related issue number

#12286

This PR works in conjunction with pydantic/pydantic-core#1854 in pydantic-core

Checklist

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Tests pass on CI
  • Documentation reflects the changes where applicable
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

@github-actions github-actions bot added the relnotes-fix Used for bugfixes. label Oct 23, 2025
Model(a='wrong_format')
assert exc_info.value.errors(include_url=False) == [
{'type': 'fraction_parsing', 'loc': ('a',), 'msg': 'Input is not a valid fraction', 'input': 'wrong_format'}
{'type': 'fraction_parsing', 'loc': ('a',), 'msg': 'Fraction input should be a tuple of two integers, a string or a Fraction object', 'input': 'wrong_format'}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually we don't check for a tuple of 2 ints, should we allow that?

@CloseChoice CloseChoice marked this pull request as ready for review October 23, 2025 15:11
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 23, 2025

CodSpeed Performance Report

Merging #12442 will not alter performance

Comparing CloseChoice:add-fraction (9641079) with main (06448aa)

Summary

✅ 46 untouched

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

relnotes-fix Used for bugfixes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant