Applied idiomatic Python improvements and micro-optimizations across registries and API layer.
CI / Formatting (push) Successful in 5s
CI / Linting (push) Successful in 5s
CI / Tests (Python 3.12) (push) Successful in 20s
CI / Tests (Python 3.13) (push) Successful in 19s
CI / Tests (Python 3.14) (push) Successful in 16s
CI / Type Checking (push) Successful in 9s
CI / Spelling (push) Successful in 5s

This commit is contained in:
2026-03-26 12:46:50 -04:00
parent 3cf93da28d
commit 0ddffe5e09
18 changed files with 192 additions and 172 deletions
+5 -4
View File
@@ -63,7 +63,7 @@ def _make_user(
name_changed_at=None,
is_bot=False,
is_authenticated=False,
scopes=[],
scopes=frozenset(),
)
@@ -230,7 +230,7 @@ class TestEventRegistry:
assert joined_entries[0].handler is handler
def test_register_multiple_handlers_same_type(self) -> None:
"""Two handlers for the same type both appear in get()."""
"""Two handlers for the same type both appear in get(), sorted by priority."""
registry = EventRegistry()
async def handler_a(ctx: EventContext[Any]) -> None:
@@ -243,8 +243,9 @@ class TestEventRegistry:
registry.register(handler_b, (EventType.CHAT,), "mod_b", 75)
entries = registry.get(EventType.CHAT)
assert len(entries) == 2
assert entries[0].handler is handler_a
assert entries[1].handler is handler_b
# Higher priority first (descending order).
assert entries[0].handler is handler_b
assert entries[1].handler is handler_a
def test_get_empty(self) -> None:
"""get() on a fresh registry returns an empty list."""