Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ only add classmethod decorator with validator if it doesn't already exist #120

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

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