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:
		
							parent
							
								
									130cdfa46a
								
							
						
					
					
						commit
						c144dbbba4
					
				|  | @ -91,7 +91,9 @@ def from_json( | ||||||
| 
 | 
 | ||||||
| def from_http( | def from_http( | ||||||
|     event_type: typing.Type[AnyCloudEvent], |     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: typing.Optional[typing.Union[str, bytes]], | ||||||
|     data_unmarshaller: typing.Optional[types.UnmarshallerType] = None, |     data_unmarshaller: typing.Optional[types.UnmarshallerType] = None, | ||||||
| ) -> AnyCloudEvent: | ) -> AnyCloudEvent: | ||||||
|  |  | ||||||
|  | @ -37,7 +37,9 @@ def from_json( | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def from_http( | 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: typing.Optional[typing.Union[str, bytes]], | ||||||
|     data_unmarshaller: typing.Optional[types.UnmarshallerType] = None, |     data_unmarshaller: typing.Optional[types.UnmarshallerType] = None, | ||||||
| ) -> CloudEvent: | ) -> CloudEvent: | ||||||
|  |  | ||||||
|  | @ -21,7 +21,9 @@ from cloudevents.sdk import types | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def from_http( | 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: typing.Optional[typing.AnyStr], | ||||||
|     data_unmarshaller: typing.Optional[types.UnmarshallerType] = None, |     data_unmarshaller: typing.Optional[types.UnmarshallerType] = None, | ||||||
| ) -> CloudEvent: | ) -> CloudEvent: | ||||||
|  |  | ||||||
|  | @ -22,7 +22,9 @@ from cloudevents.sdk import types | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def from_http( | 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: typing.Optional[typing.AnyStr], | ||||||
|     data_unmarshaller: typing.Optional[types.UnmarshallerType] = None, |     data_unmarshaller: typing.Optional[types.UnmarshallerType] = None, | ||||||
| ) -> CloudEvent: | ) -> CloudEvent: | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue