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 more builtin pydantic v2 types #3101

Merged

Conversation

ppease
Copy link
Contributor

@ppease ppease commented Sep 18, 2023

Description

Previously when using Pydantic v2 there were several builtin pydantic types that were not supported like EmailStr or PostgresDsn. In this PR, I am adding support for several of these built in types. I am also enabling the tests for these fields within the pydantic test suite.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Documentation

Issues Fixed or Closed by This PR

EmailStr and others can now be used as the type for a pydantic field.

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@botberry
Copy link
Member

botberry commented Sep 18, 2023

Thanks for adding the RELEASE.md file!

Here's a preview of the changelog:


Adding support for additional pydantic built in types like EmailStr or PostgresDsn.


Here's the preview release card for twitter:

Here's the tweet text:

🆕 Release (next) is out! Thanks to ppease for the PR 👏

Get it here 👉 https://github.com/strawberry-graphql/strawberry/releases/tag/(next)

Copy link
Member

@patrick91 patrick91 left a comment

Choose a reason for hiding this comment

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

Looks good! Can you add a release file? ☺️

@codecov
Copy link

codecov bot commented Sep 18, 2023

Codecov Report

Merging #3101 (0ec548c) into main (1171e7f) will decrease coverage by 0.04%.
Report is 3 commits behind head on main.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3101      +/-   ##
==========================================
- Coverage   96.48%   96.45%   -0.04%     
==========================================
  Files         469      469              
  Lines       29289    29293       +4     
  Branches     3611     3613       +2     
==========================================
- Hits        28260    28255       -5     
- Misses        846      851       +5     
- Partials      183      187       +4     

@codspeed-hq
Copy link

codspeed-hq bot commented Sep 18, 2023

CodSpeed Performance Report

Merging #3101 will not alter performance

Comparing ppease:feature/more-pydantic-v2-support (0ec548c) with main (319bd5e)

Summary

✅ 12 untouched benchmarks

@@ -35,7 +34,21 @@
(pydantic.RedisDsn, str),
]
if IS_PYDANTIC_V1
else [],
else [
(pydantic.PositiveInt, int),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this gets to an equivalent state as far as testing goes with what we had in V1. I removed all the classes that don't exist anymore in pydanticv2, but kept all the ones that do still exist.

Copy link
Member

@patrick91 patrick91 left a comment

Choose a reason for hiding this comment

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

Thank you!

@patrick91 patrick91 force-pushed the feature/more-pydantic-v2-support branch from 9af0a58 to 863872c Compare September 19, 2023 15:10
@patrick91 patrick91 merged commit 05a161f into strawberry-graphql:main Sep 19, 2023
54 of 57 checks passed
@botberry
Copy link
Member

Thanks for contributing to Strawberry! 🎉 You've been invited to join
the Strawberry GraphQL organisation 😊

You can also request a free sticker by filling this form: https://forms.gle/dmnfQUPoY5gZbVT67

And don't forget to join our discord server: https://strawberry.rocks/discord 🔥

etripier pushed a commit to Greenbax/strawberry that referenced this pull request Oct 25, 2023
* Add support for more builtin pydantic v2 types

* add release file

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add return type

* Empty for codecov

* Fix import

---------

Co-authored-by: Patrick Pease <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Patrick Arminio <[email protected]>
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.

4 participants