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

fix: pydantic v2 Warnings: The dict method is deprecated; use model_dump instead #49

Merged

Conversation

bVdCreations
Copy link
Contributor

fixes issue #48

Copy link
Owner

@melvinkcx melvinkcx left a comment

Choose a reason for hiding this comment

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

Hi @bVdCreations, my apologies for not seeing your PR. Please check my comment.

@@ -116,7 +118,10 @@ def dispatch(
payload_schema_cls = payload_schema_registry.get(event_name)
if payload_schema_cls:
payload_schema_cls_dict_args = payload_schema_cls_dict_args or DEFAULT_PAYLOAD_SCHEMA_CLS_DICT_ARGS
payload = payload_schema_cls(**(payload or {})).dict(**payload_schema_cls_dict_args)
if IS_PYDANTIC_V2:
Copy link
Owner

Choose a reason for hiding this comment

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

My sincerest apologies as I completely missed your contribution.

Here's my thought on this:
As model_dump(...) is most likely to remain in future versions. It will be more robust if we inverse the if-else logic. I.e.: check if pydantic v1 is used before using .dict(...), and resort to model_dump(...) in the else clause.

Once again, my apologies for not seeing your contribution earlier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@melvinkcx changed as requested

Copy link
Owner

Choose a reason for hiding this comment

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

Thanks, could you please pull the latest changes from the upstream? There has been a new release since your first change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@melvinkcx rebased and squashed the commits

Copy link
Owner

Choose a reason for hiding this comment

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

thank you very much!

@bVdCreations bVdCreations force-pushed the fix-warning-pydantic-v2-use-model-dump branch from dc98226 to a481258 Compare January 10, 2024 20:27
@melvinkcx melvinkcx merged commit 9d7ab29 into melvinkcx:dev Jan 11, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants