Skip to content

chore: cloudevents v2 migration#378

Merged
hairmare merged 4 commits intomainfrom
dependabot/pip/cloudevents-2.0.0
Mar 31, 2026
Merged

chore: cloudevents v2 migration#378
hairmare merged 4 commits intomainfrom
dependabot/pip/cloudevents-2.0.0

Conversation

@dependabot
Copy link
Copy Markdown
Contributor

@dependabot dependabot bot commented on behalf of github Mar 25, 2026

Three issues introduced by the cloudevents v2 migration were caught by CI: an unsorted import block, a str | None type mismatch in str.join(), and a key_mapper callback signature incompatible with to_structured_event.

Changes

  • Import ordering: sorted third-party imports alphabetically (configargparse before dateutil) to satisfy ruff I001
  • get_subject() nullability: BaseCloudEvent.get_subject() returns str | None in v2; added or "" fallback in _key_mapper to satisfy mypy
  • _key_mapper signature: changed from (ce: CloudEvent) -> str to (ce: BaseCloudEvent) -> str | bytes | None to match to_structured_event's expected Callable[[BaseCloudEvent], str | bytes | None]; BaseCloudEvent moved into the TYPE_CHECKING block per ruff TC002 (safe due to from __future__ import annotations)

Bumps [cloudevents](https://github.com/cloudevents/sdk-python) from 1.12.1 to 2.0.0.
- [Changelog](https://github.com/cloudevents/sdk-python/blob/main/CHANGELOG.md)
- [Commits](https://github.com/cloudevents/sdk-python/commits/2.0.0)

---
updated-dependencies:
- dependency-name: cloudevents
  dependency-version: 2.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
@dependabot dependabot bot added dependencies Pull requests that update a dependency file python Pull requests that update Python code labels Mar 25, 2026
@hairmare
Copy link
Copy Markdown
Member

Copy link
Copy Markdown

Copilot AI commented Mar 31, 2026

@copilot migrate to cloudevents 2.x https://github.com/cloudevents/sdk-python/blob/main/MIGRATION.md

Migrated to the cloudevents v2 API in commit e2bac3d. Changes include:

  • Updated imports to cloudevents.core.v1.event.CloudEvent and cloudevents.core.bindings.kafka
  • CloudEvent construction now uses attributes= keyword argument
  • eventTime is parsed to a timezone-aware datetime using dateutil (now a required v2 dependency)
  • _key_mapper updated to use explicit getters (get_type(), get_source(), get_subject())
  • to_structuredto_structured_event
  • Tests updated to reflect v2 behavior (attribute-based comparison, application/cloudevents+json content-type)

Copilot AI changed the title chore(deps): bump cloudevents from 1.12.1 to 2.0.0 fix: resolve CI failures after cloudevents v2 migration Mar 31, 2026
@hairmare hairmare changed the title fix: resolve CI failures after cloudevents v2 migration chore: cloudevents v2 migration Mar 31, 2026
@hairmare hairmare merged commit f631c9d into main Mar 31, 2026
7 checks passed
@hairmare hairmare deleted the dependabot/pip/cloudevents-2.0.0 branch March 31, 2026 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file python Pull requests that update Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants