Switch to type hint policy registration.
Let the `singledispatch` logic handle the event class registration
based on the domain event type.  This makes things simpler as there
is only one event class to look at now, all the while helping IDEs
with type hint support.
@@ -85,13 +85,12 @@ class EmailProcess(ProcessApplication):
):
"""Default policy"""
- @policy.register(BankAccount.Opened)
+ @policy.register
def _(
self,
- domain_event: AggregateEvent,
+ domain_event: BankAccount.Opened,
processing_event: ProcessingEvent,
):
- assert isinstance(domain_event, BankAccount.Opened)
notification = EmailNotification.create(
to=domain_event.email_address,
subject="Your New Account",
