Skip to content

Commit

Permalink
Remove update_json_schema (bad practice func) (#9125)
Browse files Browse the repository at this point in the history
  • Loading branch information
sydney-runkle committed Mar 27, 2024
1 parent 477e0a2 commit 3ad2018
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pydantic/_internal/_std_types_schema.py
Expand Up @@ -33,7 +33,7 @@
from pydantic.types import Strict

from ..config import ConfigDict
from ..json_schema import JsonSchemaValue, update_json_schema
from ..json_schema import JsonSchemaValue
from . import _known_annotated_metadata, _typing_extra, _validators
from ._core_utils import get_type_ref
from ._internal_dataclass import slots_true
Expand Down Expand Up @@ -87,7 +87,7 @@ def get_enum_core_schema(enum_type: type[Enum], config: ConfigDict) -> CoreSchem
def get_json_schema(schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue:
json_schema = handler(schema)
original_schema = handler.resolve_ref_schema(json_schema)
update_json_schema(original_schema, js_updates)
original_schema.update(js_updates)
return json_schema

# we don't want to add the missing to the schema if it's the default one
Expand All @@ -113,7 +113,7 @@ def get_json_schema(schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSc
def get_json_schema_no_cases(_, handler: GetJsonSchemaHandler) -> JsonSchemaValue:
json_schema = handler(core_schema.enum_schema(enum_type, cases, sub_type=sub_type, ref=enum_ref))
original_schema = handler.resolve_ref_schema(json_schema)
update_json_schema(original_schema, js_updates)
original_schema.update(js_updates)
return json_schema

# Use an isinstance check for enums with no cases.
Expand Down
4 changes: 4 additions & 0 deletions pydantic/json_schema.py
Expand Up @@ -89,6 +89,10 @@
_MODE_TITLE_MAPPING: dict[JsonSchemaMode, str] = {'validation': 'Input', 'serialization': 'Output'}


@deprecated(
'`update_json_schema` is deprecated, use a simple `my_dict.update(update_dict)` call instead.',
category=None,
)
def update_json_schema(schema: JsonSchemaValue, updates: dict[str, Any]) -> JsonSchemaValue:
"""Update a JSON schema in-place by providing a dictionary of updates.
Expand Down

0 comments on commit 3ad2018

Please sign in to comment.