Merge branch 'master' into master
This commit is contained in:
commit
aaa8098639
|
@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
### Added
|
||||
- Added `.get` accessor for even properties ([#165])
|
||||
- Added type information for all event member functions ([#173])
|
||||
|
||||
### Fixed
|
||||
- Fixed event `__eq__` operator raising `AttributeError` on non-CloudEvent values ([#172])
|
||||
|
@ -160,3 +161,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
[#169]: https://github.com/cloudevents/sdk-python/pull/169
|
||||
[#170]: https://github.com/cloudevents/sdk-python/pull/170
|
||||
[#172]: https://github.com/cloudevents/sdk-python/pull/172
|
||||
[#173]: https://github.com/cloudevents/sdk-python/pull/173
|
||||
|
|
|
@ -72,9 +72,10 @@ class CloudEvent:
|
|||
return self.data == other.data and self._attributes == other._attributes
|
||||
return False
|
||||
|
||||
|
||||
# Data access is handled via `.data` member
|
||||
# Attribute access is managed via Mapping type
|
||||
def __getitem__(self, key):
|
||||
def __getitem__(self, key: str) -> typing.Any:
|
||||
return self._attributes[key]
|
||||
|
||||
def get(
|
||||
|
@ -93,20 +94,20 @@ class CloudEvent:
|
|||
"""
|
||||
return self._attributes.get(key, default)
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
def __setitem__(self, key: str, value: typing.Any) -> None:
|
||||
self._attributes[key] = value
|
||||
|
||||
def __delitem__(self, key):
|
||||
def __delitem__(self, key: str) -> None:
|
||||
del self._attributes[key]
|
||||
|
||||
def __iter__(self):
|
||||
def __iter__(self) -> typing.Iterator[typing.Any]:
|
||||
return iter(self._attributes)
|
||||
|
||||
def __len__(self):
|
||||
def __len__(self) -> int:
|
||||
return len(self._attributes)
|
||||
|
||||
def __contains__(self, key):
|
||||
def __contains__(self, key: str) -> bool:
|
||||
return key in self._attributes
|
||||
|
||||
def __repr__(self):
|
||||
def __repr__(self) -> str:
|
||||
return str({"attributes": self._attributes, "data": self.data})
|
||||
|
|
Loading…
Reference in New Issue