Skip to content

Commit

Permalink
Apply __modify_schema__ on enum schema rather than fields that use it
Browse files Browse the repository at this point in the history
Resolves #1576
  • Loading branch information
therefromhere committed May 31, 2020
1 parent 2eb62a3 commit 96349a9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pydantic/schema.py
Expand Up @@ -545,6 +545,10 @@ def enum_process_schema(enum: Type[Enum]) -> Dict[str, Any]:

add_field_type_to_schema(enum, schema)

modify_schema = getattr(enum, '__modify_schema__', None)
if modify_schema:
modify_schema(schema)

return schema


Expand Down Expand Up @@ -698,9 +702,9 @@ def field_singleton_schema( # noqa: C901 (ignore complexity)
else:
add_field_type_to_schema(field_type, f_schema)

modify_schema = getattr(field_type, '__modify_schema__', None)
if modify_schema:
modify_schema(f_schema)
modify_schema = getattr(field_type, '__modify_schema__', None)
if modify_schema:
modify_schema(f_schema)

if f_schema:
return f_schema, definitions, nested_models
Expand Down

0 comments on commit 96349a9

Please sign in to comment.