Skip to content

Modernize tooling, typing and the event bus for Python 3.11+ - #5

Open
dlski wants to merge 11 commits into
masterfrom
dlski/modernize
Open

dlski wants to merge 11 commits into
masterfrom
dlski/modernize

Conversation

@dlski

@dlski dlski commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Brings the project up to current Python and tooling. The minimum Python version is now 3.11 and the version is bumped to 0.8.0.

Changes

  • Tooling: uv and standard project metadata replace Poetry; ruff replaces black, isort and flake8; the package moves to a src/ layout with tests in tests/.
  • CI: rewritten around uv, tests Python 3.11 to 3.14 and PyPy, publishes with PyPI trusted publishing.
  • Typing: the package ships py.typed and passes strict mypy; interfaces are typing.Protocol classes.
  • Event bus: pluggable dispatchers (BackgroundEventDispatcher, AwaitingEventDispatcher) replace the sync_mode flag, and LocalEventBus.drain() waits for background handlers.
  • Requests: optional Request[R] base class gives execute() a precise result type.
  • Handlers: a handler annotated with a union (A | B) is registered for each type.

Fixes

  • Publishing an event with no handlers failed in sync mode.
  • Background handler errors were lost, and tasks could be garbage collected before finishing.
  • include() with a one-shot iterator stored handlers but never called them.
  • A handler taking the subject as a keyword argument leaked it into other handlers of the same event.
  • An unresolvable annotation on a non-subject argument failed handler registration, including on Python 3.14.

Breaking changes

Listed in CHANGELOG.md. The main ones are the removal of sync_mode, the explicit target keyword in ModifierFactory.create, and immutable ActionSubject / ActionResult.

Before the next release

  • Add a PyPI trusted publisher for this repository (workflow ci.yml, environment pypi).
  • Add a CODECOV_TOKEN repository secret.

@dlski dlski changed the title Move the package to a src layout and the tests to a top-level tests directory. Modernize tooling, typing and the event bus for Python 3.11+ Nov 15, 2026
dlski added 11 commits November 15, 2026 15:29
…and PyPy, and publish with PyPI trusted publishing.
…py.typed and mypy runs in strict mode. Modifier factories now receive the target as an explicit keyword argument.
…Callable handlers no longer write the subject into the shared extra arguments, which leaked it into other handlers of the same event.
…. Background tasks are now referenced and their errors reported, awaited publishing raises handler errors as an ExceptionGroup, and including handlers from a one-shot iterator works.
…ach of them. An unresolvable annotation on a non-subject argument no longer fails handler registration, including lazily evaluated annotations on Python 3.14.
…tures in the README, add a changelog and bump the version to 0.8.0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant