From d7c16ddfd7b2e879d9f829c84f4cc328142526bb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 31 Aug 2026 17:07:36 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.15.14 → v0.16.5](https://github.com/astral-sh/ruff-pre-commit/compare/v0.15.14...v0.16.5) - [github.com/pre-commit/mirrors-mypy: v1.20.2 → v2.3.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.20.2...v2.3.1) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4a980eba..6d87f690 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,14 +6,14 @@ repos: - id: end-of-file-fixer - id: check-toml - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.14 + rev: v0.16.5 hooks: # Run the linter. - id: ruff # Run the formatter. - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.20.2 + rev: v2.3.1 hooks: - id: mypy files: ^(src/cloudevents/|tests/) From cf7925255882c8940da5fb5777717fb5e3bee6f9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 31 Aug 2026 17:07:48 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- MIGRATION.md | 34 +++++++++++++++++----------------- README.md | 26 +++++++++++++------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/MIGRATION.md b/MIGRATION.md index e161931c..d68689a1 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -292,28 +292,28 @@ class YAMLFormat: """Example custom format -- implement the Format protocol.""" def read( - self, - event_factory: EventFactory | None, - data: str | bytes, - ) -> BaseCloudEvent: - ... # Parse YAML into attributes dict, call event_factory(attributes, data) + self, + event_factory: EventFactory | None, + data: str | bytes, + ) -> ( + BaseCloudEvent + ): ... # Parse YAML into attributes dict, call event_factory(attributes, data) - def write(self, event: BaseCloudEvent) -> bytes: - ... # Serialize entire event to YAML bytes + def write( + self, event: BaseCloudEvent + ) -> bytes: ... # Serialize entire event to YAML bytes def write_data( - self, - data: dict | str | bytes | None, - datacontenttype: str | None, - ) -> bytes: - ... # Serialize just the data payload + self, + data: dict | str | bytes | None, + datacontenttype: str | None, + ) -> bytes: ... # Serialize just the data payload def read_data( - self, - body: bytes, - datacontenttype: str | None, - ) -> dict | str | bytes | None: - ... # Deserialize just the data payload + self, + body: bytes, + datacontenttype: str | None, + ) -> dict | str | bytes | None: ... # Deserialize just the data payload def get_content_type(self) -> str: return "application/cloudevents+yaml" diff --git a/README.md b/README.md index 4787c58c..bf105150 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,8 @@ import requests # Create a CloudEvent # - The CloudEvent "id" is generated if omitted. "specversion" defaults to "1.0". attributes = { - "type": "com.example.sampletype1", - "source": "https://example.com/event-producer", + "type": "com.example.sampletype1", + "source": "https://example.com/event-producer", } data = {"message": "Hello World!"} event = CloudEvent(attributes, data) @@ -63,8 +63,8 @@ import requests # Create a CloudEvent # - The CloudEvent "id" is generated if omitted. "specversion" defaults to "1.0". attributes = { - "type": "com.example.sampletype2", - "source": "https://example.com/event-producer", + "type": "com.example.sampletype2", + "source": "https://example.com/event-producer", } data = {"message": "Hello World!"} event = CloudEvent(attributes, data) @@ -95,20 +95,20 @@ app = Flask(__name__) # create an endpoint at http://localhost:/3000/ @app.route("/", methods=["POST"]) def home(): - # create a CloudEvent - event = from_http_event(HTTPMessage(dict(request.headers), request.get_data())) + # create a CloudEvent + event = from_http_event(HTTPMessage(dict(request.headers), request.get_data())) - # you can access cloudevent fields as seen below - print( - f"Found {event.get_id()} from {event.get_source()} with type " - f"{event.get_type()} and specversion {event.get_specversion()}" - ) + # you can access cloudevent fields as seen below + print( + f"Found {event.get_id()} from {event.get_source()} with type " + f"{event.get_type()} and specversion {event.get_specversion()}" + ) - return "", 204 + return "", 204 if __name__ == "__main__": - app.run(port=3000) + app.run(port=3000) ``` You can find a complete example of turning a CloudEvent into a HTTP request