Skip to content

Conversation

ff137
Copy link

@ff137 ff137 commented Aug 19, 2023

I ran bump-pydantic on one of our projects, and it has auto-converted the following, from:

    @root_validator(pre=True)
    @classmethod

to:

    @model_validator(mode="before")
    @classmethod
    @classmethod

This PR amends this behavior to only add the classmethod decorator if it doesn't already exist.

To test, I ran pip install /path/to/my/fork, and ran bump-pydantic . again. Now the extra decorator won't be added unnecessarily

Edit: Also added some tests to validate behavior

@ff137 ff137 changed the title ✨ only add classmethod decorator if it doesn't already exist with validator ✨ only add classmethod decorator with validator if it doesn't already exist Aug 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant