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.color is moved to pydantic_extra_types.color in V2 resulting in an error in odmantic converts(pydantic.color.Color) #452

Open
pvilas opened this issue Dec 31, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@pvilas
Copy link

pvilas commented Dec 31, 2023

Describe the bug

Using pydantic V2 import starlette_admin.contrib.odmantic.Admin results in an import error because pydantic.color is moved to pydantic_extra_types.color.

See the migration guide to V2.

To Reproduce

from starlette_admin.contrib.odmantic import Admin

raises this error

  File "/usr/local/lib/python3.11/site-packages/starlette_admin/contrib/odmantic/converters.py", line 55, in <module>
    class ModelConverter(BaseODMModelConverter):
  File "/usr/local/lib/python3.11/site-packages/starlette_admin/contrib/odmantic/converters.py", line 120, in ModelConverter
    @converts(pydantic.color.Color)
              ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pydantic/__init__.py", line 363, in __getattr__
    return _getattr_migration(attr_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pydantic/_migration.py", line 306, in wrapper
    raise AttributeError(f'module {module!r} has no attribute {name!r}')
AttributeError: module 'pydantic' has no attribute 'color'

Environment (please complete the following information):

  • Starlette-Admin version: 0.12.2
  • ORM/ODMs: ODMantic

Additional context
pydantic version: 2.5.3

@pvilas pvilas added the bug Something isn't working label Dec 31, 2023
@hasansezertasan
Copy link
Contributor

If you pin your pydantic version, this will be resolved.

@attid
Copy link

attid commented Aug 3, 2024

Do you plan integrate pydantic v2 ?

@attid
Copy link

attid commented Aug 3, 2024

just @converts(pydantic_extra_types.color.Color) need

@jowilf
Copy link
Owner

jowilf commented Aug 5, 2024

Do you plan integrate pydantic v2 ?

I have no plan yet but PR is welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants