From efca352e21b5cdd61b0f7afbaf191859f399194b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20H=C3=B6sler?= Date: Wed, 30 Oct 2024 10:41:03 +0100 Subject: [PATCH 1/3] fix kafka unmarshaller args typing and defaults (#240) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix kafka unmarshaller args typing and defaults Signed-off-by: Christoph Hösler * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: Christoph Hösler Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- cloudevents/kafka/conversion.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/cloudevents/kafka/conversion.py b/cloudevents/kafka/conversion.py index 97c355f..bfddca6 100644 --- a/cloudevents/kafka/conversion.py +++ b/cloudevents/kafka/conversion.py @@ -21,9 +21,14 @@ from cloudevents.kafka.exceptions import KeyMapperError from cloudevents.sdk import types -DEFAULT_MARSHALLER: types.MarshallerType = json.dumps -DEFAULT_UNMARSHALLER: types.MarshallerType = json.loads -DEFAULT_EMBEDDED_DATA_MARSHALLER: types.MarshallerType = lambda x: x +JSON_MARSHALLER: types.MarshallerType = json.dumps +JSON_UNMARSHALLER: types.UnmarshallerType = json.loads +IDENTITY_MARSHALLER = IDENTITY_UNMARSHALLER = lambda x: x + +DEFAULT_MARSHALLER: types.MarshallerType = JSON_MARSHALLER +DEFAULT_UNMARSHALLER: types.UnmarshallerType = JSON_UNMARSHALLER +DEFAULT_EMBEDDED_DATA_MARSHALLER: types.MarshallerType = IDENTITY_MARSHALLER +DEFAULT_EMBEDDED_DATA_UNMARSHALLER: types.UnmarshallerType = IDENTITY_UNMARSHALLER class KafkaMessage(typing.NamedTuple): @@ -109,7 +114,7 @@ def to_binary( def from_binary( message: KafkaMessage, event_type: typing.Optional[typing.Type[AnyCloudEvent]] = None, - data_unmarshaller: typing.Optional[types.MarshallerType] = None, + data_unmarshaller: typing.Optional[types.UnmarshallerType] = None, ) -> AnyCloudEvent: """ Returns a CloudEvent from a KafkaMessage in binary format. @@ -208,7 +213,7 @@ def to_structured( def from_structured( message: KafkaMessage, event_type: typing.Optional[typing.Type[AnyCloudEvent]] = None, - data_unmarshaller: typing.Optional[types.MarshallerType] = None, + data_unmarshaller: typing.Optional[types.UnmarshallerType] = None, envelope_unmarshaller: typing.Optional[types.UnmarshallerType] = None, ) -> AnyCloudEvent: """ @@ -222,7 +227,7 @@ def from_structured( :returns: CloudEvent """ - data_unmarshaller = data_unmarshaller or DEFAULT_EMBEDDED_DATA_MARSHALLER + data_unmarshaller = data_unmarshaller or DEFAULT_EMBEDDED_DATA_UNMARSHALLER envelope_unmarshaller = envelope_unmarshaller or DEFAULT_UNMARSHALLER try: structure = envelope_unmarshaller(message.value) From 96cfaa6529dfbd7a179d6433cae950c890de54a6 Mon Sep 17 00:00:00 2001 From: Yurii Serhiichuk Date: Wed, 30 Oct 2024 11:54:36 +0200 Subject: [PATCH 2/3] chore: release 1.11.1 (#241) Signed-off-by: Yurii Serhiichuk --- CHANGELOG.md | 6 ++++++ cloudevents/__init__.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e282597..458a1dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.11.1] + +### Fixed +- Kafka `conversion` marshaller and unmarshaller typings ([#240]) + ## [1.11.0] ### Fixed @@ -287,3 +292,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#232]: https://github.com/cloudevents/sdk-python/pull/232 [#235]: https://github.com/cloudevents/sdk-python/pull/235 [#236]: https://github.com/cloudevents/sdk-python/pull/236 +[#240]: https://github.com/cloudevents/sdk-python/pull/240 diff --git a/cloudevents/__init__.py b/cloudevents/__init__.py index 1f52fdb..d332910 100644 --- a/cloudevents/__init__.py +++ b/cloudevents/__init__.py @@ -12,4 +12,4 @@ # License for the specific language governing permissions and limitations # under the License. -__version__ = "1.11.0" +__version__ = "1.11.1" From c5645d8fcf03432639727b9a7f6508c3059a1673 Mon Sep 17 00:00:00 2001 From: Yurii Serhiichuk Date: Sat, 9 Nov 2024 20:27:52 +0200 Subject: [PATCH 3/3] chpre: disable attestations while we're not using trusted publishing (#243) Signed-off-by: Yurii Serhiichuk --- .github/workflows/pypi-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index 4cb248b..2b1dbf0 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -52,6 +52,7 @@ jobs: with: user: __token__ password: ${{ secrets.pypi_password }} + attestations: false - name: Install GitPython and cloudevents for pypi_packaging run: pip install -U -r requirements/publish.txt - name: Create Tag