Closed questionlp closed 12 months ago
I can't reproduce your MRE.
If I have the following code:
from pydantic import BaseModel, Field, conint
class GuestAppearance(BaseModel):
"""Appearance Information"""
show_id: conint(ge=0, lt=2**31) = Field(title="Show ID")
And I run bump-pydantic main.py
, it becomes:
from pydantic import BaseModel, Field
from typing_extensions import Annotated
class GuestAppearance(BaseModel):
"""Appearance Information"""
show_id: Annotated[int, Field(ge=0, lt=2**31)] = Field(title="Show ID")
If you can show me an MRE that fails as you mentioned, I'll be happy to work on it. I'll be closing this for now.
Please open a new issue if you find a good example.
Python version: 3.10.12 bump-pydantic version: 0.6.1 Pydantic version: 2.3.0
I installed and ran
bump-pydantic
per the project's README.md file instructions against my FastAPI project*. The resulting diff doesn't handleconint(ge=, lt=)
correctly.Before running
bump-pydantic
, one of the models looks like:The diff generated by
bump-pydantic
returns:It is losing both the
int
type and thege
andlt
constraints. Replacing the expression2**31
with2147483648
doesn't change howbump-pydantic
handles theconint
per the following diff: