chore: accept Mapping as well as SupportsDuplicateItems

Although our types.SupportsDuplicateItems type is wider than Dict and
Mapping, it's not a familar type to users, so explicitly accepting
Mapping in the from_http() functions should make it more clear to users
that a dict-like object is required for the headers argument.

Signed-off-by: Hal Blackburn <hwtb2@cam.ac.uk>
This commit is contained in:
Hal Blackburn 2025-05-21 14:03:18 +00:00
parent 130cdfa46a
commit c144dbbba4
No known key found for this signature in database
4 changed files with 12 additions and 4 deletions

View File

@ -91,7 +91,9 @@ def from_json(
def from_http(
event_type: typing.Type[AnyCloudEvent],
headers: types.SupportsDuplicateItems[str, str],
headers: typing.Union[
typing.Mapping[str, str], types.SupportsDuplicateItems[str, str]
],
data: typing.Optional[typing.Union[str, bytes]],
data_unmarshaller: typing.Optional[types.UnmarshallerType] = None,
) -> AnyCloudEvent:

View File

@ -37,7 +37,9 @@ def from_json(
def from_http(
headers: types.SupportsDuplicateItems[str, str],
headers: typing.Union[
typing.Mapping[str, str], types.SupportsDuplicateItems[str, str]
],
data: typing.Optional[typing.Union[str, bytes]],
data_unmarshaller: typing.Optional[types.UnmarshallerType] = None,
) -> CloudEvent:

View File

@ -21,7 +21,9 @@ from cloudevents.sdk import types
def from_http(
headers: types.SupportsDuplicateItems[str, str],
headers: typing.Union[
typing.Mapping[str, str], types.SupportsDuplicateItems[str, str]
],
data: typing.Optional[typing.AnyStr],
data_unmarshaller: typing.Optional[types.UnmarshallerType] = None,
) -> CloudEvent:

View File

@ -22,7 +22,9 @@ from cloudevents.sdk import types
def from_http(
headers: types.SupportsDuplicateItems[str, str],
headers: typing.Union[
typing.Mapping[str, str], types.SupportsDuplicateItems[str, str]
],
data: typing.Optional[typing.AnyStr],
data_unmarshaller: typing.Optional[types.UnmarshallerType] = None,
) -> CloudEvent: