cloudevents / sdk-python

Python SDK for CloudEvents
https://pypi.org/p/cloudevents/
Apache License 2.0
266 stars 53 forks source link

example should be examples in Field()? #231

Closed lcasassa closed 1 month ago

lcasassa commented 7 months ago

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

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

jason-tang5 commented 5 months ago

I'd be happy to work on this issue!

xSAVIKx commented 1 month ago

I believe it's now fixed with https://github.com/cloudevents/sdk-python/pull/235