Skip to content

Conversation

Viicos
Copy link
Member

@Viicos Viicos commented Jul 18, 2025

Change Summary

Fixes pydantic/pydantic#12063.

Related issue number

Checklist

  • Unit tests for the changes exist
  • Documentation reflects the changes where applicable
  • Pydantic tests pass with this pydantic-core (except for expected changes)
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

@Viicos Viicos requested a review from davidhewitt July 18, 2025 16:24
Comment on lines 288 to 291
#[cfg(Py_3_11)]
let as_int = self.call_method0("__int__");
#[cfg(not(Py_3_11))]
let as_int = self.call_method0("__trunc__");
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure if there's a better way: maybe pyo3 can do the coercion directly? I've tried downcasting with no success.

@codspeed-hq
Copy link

codspeed-hq bot commented Jul 18, 2025

CodSpeed Performance Report

Merging #1757 will not alter performance

Comparing vp/fractions-int (0ca928c) with main (37ec6e7)

Summary

✅ 157 untouched benchmarks

@Viicos Viicos force-pushed the vp/fractions-int branch from 363bb55 to 83b6fba Compare July 20, 2025 08:41
Copy link
Contributor

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

Think this needs to check the denominator is 1?

@Viicos Viicos requested a review from davidhewitt July 21, 2025 10:55
Copy link
Contributor

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM 👍

@Viicos Viicos enabled auto-merge (squash) July 23, 2025 19:00
@Viicos Viicos merged commit eeb51e8 into main Jul 23, 2025
29 checks passed
@Viicos Viicos deleted the vp/fractions-int branch July 23, 2025 19:05
davidhewitt pushed a commit to pydantic/pydantic that referenced this pull request Oct 20, 2025
davidhewitt pushed a commit to pydantic/pydantic that referenced this pull request Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Coercion of Fraction to int inconsistent with documentation

2 participants