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

test: FieldInfo repr with pydantic >= 2.7.0 #1097

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions eodag/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ def json_field_definition_to_python(
... 'title': 'Foo parameter'
... }
... )
>>> str(result).replace('_extensions', '') # python3.8 compatibility
>>> res_repr = str(result).replace('_extensions', '') # python3.8 compatibility
>>> res_repr = res_repr.replace(', default=None', '') # pydantic >= 2.7.0 compatibility
>>> res_repr
"typing.Annotated[bool, FieldInfo(annotation=NoneType, required=False, title='Foo parameter')]"

:param json_field_definition: the json field definition
Expand Down Expand Up @@ -205,7 +207,9 @@ def model_fields_to_annotated(
>>> from pydantic import create_model
>>> some_model = create_model("some_model", foo=(str, None))
>>> fields_definitions = model_fields_to_annotated(some_model.model_fields)
>>> str(fields_definitions).replace('_extensions', '') # python3.8 compatibility
>>> fd_repr = str(fields_definitions).replace('_extensions', '') # python3.8 compatibility
>>> fd_repr = fd_repr.replace(', default=None', '') # pydantic >= 2.7.0 compatibility
>>> fd_repr
"{'foo': typing.Annotated[str, FieldInfo(annotation=NoneType, required=False)]}"

:param model_fields: BaseModel.model_fields to convert
Expand Down