pydantic / bump-pydantic

Convert Pydantic from V1 to V2 ♻
MIT License
303 stars 24 forks source link

Not Transformed automatically for other parent class except BaseModel #166

Closed BhuwanPandey closed 1 month ago

BhuwanPandey commented 4 months ago

Hy I am using filter package fastapi-filter and when I try to migrate pydantic v1 to v2 using bump_pydantic it doesnot auto transformed.

here, the code filters.py

from fastapi_filter.contrib.sqlalchemy import Filter

class CommentFilter(Filter):
    content_id: Optional[UUID]
    creator_id: Optional[UUID]

    class Constants(Filter.Constants):
        model = Content

when i run python -m bum p_pydantic filters.py

It not transformed to

class CommentFilter(Filter):
    content_id: Optional[UUID] = None
    creator_id: Optional[UUID] = None

    class Constants(Filter.Constants):
        model = Content
Kludex commented 1 month ago

It's a limitation from the tool. We are not using any kind of type inference here.

Kludex commented 1 month ago

Let me know if you have any suggestions... 🙏