MCPcopy
hub / github.com/pydantic/pydantic / create_patch_model

Function create_patch_model

tests/test_fields.py:406–412  ·  view source on GitHub ↗
(cls: type[BaseModel])

Source from the content-addressed store, hash-verified

404 """
405
406 def create_patch_model(cls: type[BaseModel]) -> type[BaseModel]:
407 fields = {}
408 for field_name, field in cls.model_fields.items():
409 field_copy = copy.deepcopy(field)
410 field_copy.default = None
411 fields[field_name] = (field.annotation, field_copy)
412 return create_model(f'Patch{cls.__name__}', **fields)
413
414 class Model(BaseModel):
415 a: Annotated[int, Field(gt=2)]

Callers 1

Calls 2

create_modelFunction · 0.90
itemsMethod · 0.45

Tested by

no test coverage detected