You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Pydantic v2, it's required to have annotations in all fields, including fields with default values.
Problem
The current only way to detect the fields that need an annotation is to run the code, wait for the runtime error, and go and update the field. Then do it again to detect the next error.
But when startup is slow because the app is huge and has import side effects (e.g. connecting to a DB, importing ML models), the iteration speed can be very slow.
Desired Result
I would like bump-pydantic to add an annotation automatically, changing from:
frompydanticimportBaseModelclassItem(BaseModel):
name: str# TODO (pydantic v2): Add a type annotation to this fieldenabled=True# TODO (pydantic v2): Add a type annotation to this fielddescription="An item"
This way I could run bump-pydantic once, and then see all the changes in git in the places where I need to add annotations, instead of having to start the whole application once per each field that needs it.
The text was updated successfully, but these errors were encountered:
In Pydantic v1 it was okay to have fields without an explicit annotation:
In Pydantic v2, it's required to have annotations in all fields, including fields with default values.
Problem
The current only way to detect the fields that need an annotation is to run the code, wait for the runtime error, and go and update the field. Then do it again to detect the next error.
But when startup is slow because the app is huge and has import side effects (e.g. connecting to a DB, importing ML models), the iteration speed can be very slow.
Desired Result
I would like
bump-pydantic
to add an annotation automatically, changing from:...to:
Desired Result 2
I imagine the result above might be difficult to achieve as some default values would probably require runtime.
So alternatively, I would like
bump-pydantic
to add a# TODO (pydantic v2):
comment on top of each field that doesn't have an annotation, from:...to:
This way I could run
bump-pydantic
once, and then see all the changes in git in the places where I need to add annotations, instead of having to start the whole application once per each field that needs it.The text was updated successfully, but these errors were encountered: