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

feat: Add support for v2 model_dump and v1 dict to pydantic plugin #3327

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

kedod
Copy link
Contributor

@kedod kedod commented Apr 6, 2024

Description

  • Add support for additional V1 model_dump and V2 dict parameters in PydanticPlugin

This is a continuation of #3171
The last unresolved conversation is here #3171 (comment)

Closes #3147

@kedod kedod requested review from a team as code owners April 6, 2024 09:26
Copy link

codecov bot commented Apr 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.28%. Comparing base (40a5685) to head (ac65dc0).

❗ Current head ac65dc0 differs from pull request most recent head 84b2b41. Consider uploading reports for the commit 84b2b41 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3327   +/-   ##
=======================================
  Coverage   98.28%   98.28%           
=======================================
  Files         323      323           
  Lines       14777    14785    +8     
  Branches     2347     2345    -2     
=======================================
+ Hits        14523    14531    +8     
  Misses        116      116           
  Partials      138      138           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kedod kedod force-pushed the 3147-add-support-all-kwargs-for-model-dump-in-pydantic-plugin branch from 2c86e28 to 8046b36 Compare April 6, 2024 09:32
@kedod kedod force-pushed the 3147-add-support-all-kwargs-for-model-dump-in-pydantic-plugin branch from 8046b36 to ca9b618 Compare April 6, 2024 17:13
Copy link
Member

Choose a reason for hiding this comment

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

I think the tests should probably go into tests/test_contrib/test_pydantic/test_plugin_serialization.py.

Copy link
Contributor Author

@kedod kedod Apr 10, 2024

Choose a reason for hiding this comment

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

I'm not sure about it.

We still need E2E for checking the passing arguments flow.
Will be ok for you if E2E will stay here and I add additional tests to test_plugin_serialization?

@@ -57,3 +62,5 @@
EncodableMsgSpecType: TypeAlias = "Ext | Raw | Struct"
LitestarEncodableType: TypeAlias = "EncodableBuiltinType | EncodableBuiltinCollectionType | EncodableStdLibType | EncodableStdLibIPType | EncodableMsgSpecType | BaseModel | AttrsInstance" # pyright: ignore
DataContainerType: TypeAlias = "Struct | BaseModel | AttrsInstance | TypedDictClass | DataclassProtocol" # pyright: ignore
PydanticV2FieldsListType: TypeAlias = "Set[int] | Set[str] | Dict[int, Any] | Dict[str, Any] | None"
Copy link
Contributor

Choose a reason for hiding this comment

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

just for my understanding, is it ok to have | None in the type alias? I would prefer PydanticV2FieldsListType | None just to be explicit, but I am not sure if that is the norm 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is None in different type already:
EncodableBuiltinType: TypeAlias = "None | bool | int | float | str | bytes | bytearray"

But I like your approach more :)
Changed.

@github-actions github-actions bot added size: small type/feat area/types This PR involves changes to the custom types pr/internal labels Apr 9, 2024
@kedod kedod requested review from Alc-Alc and guacs April 10, 2024 09:47
Copy link

Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/3327

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/types This PR involves changes to the custom types pr/external pr/internal size: small Triage Required 🏥 This requires triage type/feat
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: Support all kwargs for model_dump in PydanticPlugin
4 participants