pydantic / bump-pydantic

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

BP008 may not be working as intended. #168

Closed adonskoi closed 1 month ago

adonskoi commented 2 months ago

After execute bump-pydantic --diff app/ I received the following output:

 class UpscaleTaskOutput(ImageProcessTask):
     task_id: str
-    scale_factor: conint(ge=1, le=4)
+    scale_factor: Annotated

But I expect something like this:

 class UpscaleTaskOutput(ImageProcessTask):
     task_id: str
-    scale_factor: conint(ge=1, le=4)
+    scale_factor: Annotated[int, Field()]
class ImageProcessTask(BaseModel):
    samples: Optional[int] = 1
    steps: int = 1
    content_container_id: Optional[str] = None

Python: 3.11.4 bump-pydantic version: 0.8.0

Maybe I am doing something incorrect?

Kludex commented 1 month ago

I don't know... 🤔

Do you have an error? Sorry the delay here!

I've tried to run bump-pydantic main.py on this:

from pydantic import BaseModel, conint

class UpscaleTaskOutput(BaseModel):
    task_id: str
    scale_factor: conint(ge=1, le=4)

And it becomes...

from pydantic import Field, BaseModel
from typing_extensions import Annotated

class UpscaleTaskOutput(BaseModel):
    task_id: str
    scale_factor: Annotated[int, Field(ge=1, le=4)]

If you have more details, I'm happy to reopen this!