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

Processing extra fields #147

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

Processing extra fields #147

wants to merge 4 commits into from

Conversation

denisart
Copy link

@denisart denisart commented Feb 18, 2024

Problem

bump-pydantic doesn't change when i using extra fields in pydantic.Field. Simple example:

# my code
from pydantic import BaseModel, Field

class Human(BaseModel):
    name: str = Field(..., min_length=1, some_extra_field="some_extra_field_value")
# expected code
from pydantic import BaseModel, Field

class Human(BaseModel):
    name: str = Field(..., min_length=1, json_schema_extra={"some_extra_field": "some_extra_field_value"})

Plus refactor with running black bump_pydantic

Copy link
Member

@tiangolo tiangolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know about the implementation (I'm not familiar enough with LibCST, but achieving what the tests show would be useful! 🤓

@@ -4,6 +4,7 @@
from libcst import matchers as m
from libcst.codemod import CodemodContext, VisitorBasedCodemodCommand
from libcst.codemod.visitors import AddImportsVisitor, RemoveImportsVisitor
from pydantic import Field
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pydantic can't be a dependency of bump_pydantic.

The test passes because the test suit does have pydantic...

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.

3 participants