pydantic / bump-pydantic

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

@root_validator will not updated to model_validator #134

Open saber-solooki opened 11 months ago

saber-solooki commented 11 months ago

Description

I have a @root_validator without having any parameter in my project like this:

from pydantic import BaseModel, root_validator

class Model(BaseModel):
    name: str

    @root_validator
    def validate_root(cls, values):
        return values

In this way, bump-pydantic can't detect it and will not update it to a new version and without any TODO or anything. Also, if I define my root_validator like @root_validator(), it will be detected and converted to @model_validator() without defining mode parameter. The only successful convert will happen if I have @root_validator(pre=True). I've not checked other scenarios.

If it is an accepted bug, I will be happy to work on it and make a PR

My Environment

Python 3.11.4 bump-pydantic==0.7.0

Kludex commented 8 months ago

Hi @saber-solooki , do you still want to work on this? I'll be happy to review a PR. :)