Thanks to visit codestin.com
Credit goes to github.com

Skip to content

example should be examples in Field()? #231

@lcasassa

Description

@lcasassa

I get this warning message: /Users/...-ZX1ANZWw-py3.11/lib/python3.11/site-packages/pydantic/fields.py:799: PydanticDeprecatedSince20: Using extra keyword arguments on Field is deprecated and will be removed. Use json_schema_extra instead. (Extra keys: 'example'). Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/

Should this line be examples instead of example? https://github.com/cloudevents/sdk-python/blob/main/cloudevents/pydantic/v2/event.py#L54C7-L54C12

Or maybe change the example argument to:

    data: typing.Optional[typing.Any] = Field(
        title=FIELD_DESCRIPTIONS["data"].get("title"),
        description=FIELD_DESCRIPTIONS["data"].get("description"),
        json_schema_extra={"example": FIELD_DESCRIPTIONS["data"].get("example")},
        default=None,
    )

?

Steps to Reproduce the Problem

python -Wa -c "from cloudevents.pydantic import CloudEvent"

Specifications

  • Platform: Mac M1
  • Python Version: 3.11

% poetry show cloudevents
name : cloudevents
version : 1.10.1
description : CloudEvents Python SDK

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions