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

pydantic v2 import errors #45

Closed
bVdCreations opened this issue Jul 31, 2023 · 6 comments · Fixed by #47
Closed

pydantic v2 import errors #45

bVdCreations opened this issue Jul 31, 2023 · 6 comments · Fixed by #47

Comments

@bVdCreations
Copy link
Contributor

When trying to upgrade to pydantic V2. there is the following import error

  File "/app/src/services/mail/events.py", line 1, in <module>
    from fastapi_events.handlers.local import local_handler
  File "/usr/local/lib/python3.11/site-packages/fastapi_events/handlers/local.py", line 10, in <module>
    from pydantic.error_wrappers import ErrorWrapper
  File "/usr/local/lib/python3.11/site-packages/pydantic/_migration.py", line 295, in wrapper
    raise PydanticImportError(f'`{import_path}` has been removed in V2.')
pydantic.errors.PydanticImportError: `pydantic.error_wrappers:ErrorWrapper` has been removed in V2.

For further information visit https://errors.pydantic.dev/2.1.1/u/import-error

it does not seem there is a direct replacement for "ErrorWrapper"
https://github.com/pydantic/pydantic/blob/main/pydantic/errors.py

@melvinkcx
Copy link
Owner

melvinkcx commented Jul 31, 2023

Hi @bVdCreations, thanks for reporting this. This is indeed an issue, I'll look into the compatibility issue with Pydantic v2 more this week.

@bVdCreations
Copy link
Contributor Author

@melvinkcx let me know if I can help. I love this project so I don't mind to contribute.
Any docs on how to setup the local dev env?

I would try replacing "ErrorWrapper" with a custom type/protocol, so we loose the dependency to pydantic. I would love to hear your thoughts on this.

@melvinkcx
Copy link
Owner

Hi, to set up your dev env, you may create a virtualenv and run pip install -e '.[test]'.

I plan to replace ErrorWrapper with a Protocol as well.

This library is supposed to support Pydantic for payload validation, but it's completely optional. So, I'd like to make sure it works properly with or without the presence of Pydantic. I'm also intended to change the test setup to ensure both scenario are well covered. I'll probably have some time this week to work on the changes.

@bVdCreations
Copy link
Contributor Author

hi @melvinkcx,

Looking at he local handler I did not see we where using the errors to I removed them in this pull request.
#46

I'm under the impression that the payload validation happens in the dispatch function, maybe I'm missing if it is propagated in the local handler

I'm not sure that was where you where headed, let me know.

@melvinkcx
Copy link
Owner

Hi @bVdCreations, I just released a new version, which includes a fix for this error. Feel free to try it out. Thanks.

@bVdCreations
Copy link
Contributor Author

@melvinkcx thanks a lot, I could complete the migration to pydantic v2.
I had noticed some warnings popping I reported in a new issue #48

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 a pull request may close this issue.

2 participants