Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for field level number to str coercion option #9137

Conversation

NeevCohen
Copy link
Contributor

@NeevCohen NeevCohen commented Mar 29, 2024

Change Summary

This change adds support for field level number to str coercion option as requested in #8383.

Support in pydantic-core has already been implemented in pydantic/pydantic-core@c607fd8.

This change requires a new pydantic-core version which includes the above commit. Opening this PR now to remember to merge it once a new core version comes out.

Related issue number

Fix #8383

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

Copy link

codspeed-hq bot commented Mar 29, 2024

CodSpeed Performance Report

Merging #9137 will not alter performance

Comparing NeevCohen:feature/field-level-number-to-str-coercion (b4784ea) with main (932b025)

Summary

✅ 13 untouched benchmarks

Copy link
Member

@sydney-runkle sydney-runkle left a comment

Choose a reason for hiding this comment

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

Looks great! Approving now, will merge once we get that new core version ready :).

@NeevCohen
Copy link
Contributor Author

@sydney-runkle Awesome! Thanks a lot! Just need to remember to remove the xfails from the tests 😄

@sydney-runkle
Copy link
Member

@NeevCohen,

Once we merge this PR #9153, you can pull that change in and remove your xfails!

@sydney-runkle
Copy link
Member

@NeevCohen, that PR is now merged!

tests/test_fields.py Outdated Show resolved Hide resolved
tests/test_fields.py Outdated Show resolved Hide resolved
@sydney-runkle
Copy link
Member

@NeevCohen,

Hmm, looks like tests are still failing...

@sydney-runkle
Copy link
Member

Going to go ahead and release 2.7 beta, but we can get this across the line this week + get it into the official release :).

@NeevCohen
Copy link
Contributor Author

@sydney-runkle I figured out the issue. In core, I forgot to add the corece_numbers_to_str option in the StringSchema typed dict. Sorry for that, my bad.

I opened a PR fixing that issue, pydantic/pydantic-core#1262

@sydney-runkle
Copy link
Member

Awesome, no worries at all. We can get that into the next pydantic-core release, which we'll include in 2.7!

@sydney-runkle
Copy link
Member

sydney-runkle commented Apr 11, 2024

@NeevCohen,

Could you pull in the changes from main once #9211 merges? Should be in just a few minutes :).

Edit: I'll save you the trouble and do the merge :)

@sydney-runkle
Copy link
Member

I'll review your other PR shortly - looking forward to it!! Just want to get 2.7 out first :).

@sydney-runkle sydney-runkle enabled auto-merge (squash) April 11, 2024 14:25
@sydney-runkle sydney-runkle merged commit 99821e9 into pydantic:main Apr 11, 2024
51 checks passed
@NeevCohen NeevCohen deleted the feature/field-level-number-to-str-coercion branch April 17, 2024 19:10
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.

coerce_numbers_to_str needs a per-field variant
2 participants