jowilf / starlette-admin

Fast, beautiful and extensible administrative interface framework for Starlette & FastApi applications
https://jowilf.github.io/starlette-admin/
MIT License
618 stars 59 forks source link

pydantic.color is moved to pydantic_extra_types.color in V2 resulting in an error in odmantic converts(pydantic.color.Color) #452

Closed pvilas closed 5 days ago

pvilas commented 10 months ago

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):

Additional context pydantic version: 2.5.3

hasansezertasan commented 10 months ago

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

attid commented 3 months ago

Do you plan integrate pydantic v2 ?

attid commented 3 months ago

just @converts(pydantic_extra_types.color.Color) need

jowilf commented 2 months ago

Do you plan integrate pydantic v2 ?

I have no plan yet but PR is welcome

jowilf commented 5 days ago

solve in #594