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/) 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