Skip to content

Commit

Permalink
test: FieldInfo repr with pydantic >= 2.7.0 (#1097)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunato committed Apr 12, 2024
1 parent 6077d56 commit c99e3be
Showing 1 changed file with 6 additions and 2 deletions.
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

0 comments on commit c99e3be

Please sign in to comment.