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

🐛 deprecate __modify_schema__ method #20

Merged
merged 1 commit into from
Mar 2, 2023
Merged

🐛 deprecate __modify_schema__ method #20

merged 1 commit into from
Mar 2, 2023

Conversation

yezz123
Copy link
Collaborator

@yezz123 yezz123 commented Mar 2, 2023

    def _get_pydantic_modify_json_schema(obj: Any) -> typing.Callable[[JsonSchemaValue], None] | None:
        modify_js_function = getattr(obj, '__pydantic_modify_json_schema__', None)

        if modify_js_function is None and hasattr(obj, '__modify_schema__'):
>           warnings.warn(
                'The __modify_schema__ method is deprecated, use __pydantic_modify_json_schema__ instead',
                DeprecationWarning,
            )
E           DeprecationWarning: The __modify_schema__ method is deprecated, use __pydantic_modify_json_schema__ instead

venv/lib/python3.10/site-packages/pydantic/_internal/_generate_schema.py:712: DeprecationWarning

@yezz123 yezz123 added the bug Something isn't working label Mar 2, 2023
@yezz123 yezz123 self-assigned this Mar 2, 2023
@yezz123 yezz123 linked an issue Mar 2, 2023 that may be closed by this pull request
@yezz123 yezz123 merged commit d5b1ac7 into main Mar 2, 2023
@yezz123 yezz123 deleted the fix/color branch March 2, 2023 14:17
@dmontagu
Copy link
Contributor

dmontagu commented Mar 3, 2023

@yezz123 If you want to maintain the same schema that was present in v1, I would recommend re-adding this method, just with the non-deprecated name (__pydantic_modify_json_schema__) as it is present in current main branch of pydantic:

https://github.com/pydantic/pydantic/blob/565c9b603ac1a19dfed8474fa2bb1bcaee090ca0/pydantic/color.py#L86-L88

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tests/test_types_color.py::test_model_validation gets deprecation warning
2 participants