Skip to content

Commit

Permalink
feat(events): add __event_name__ as ClassVar to EventBase
Browse files Browse the repository at this point in the history
This improves types for event consumers that need to access the event name.
  • Loading branch information
psychedelicious committed May 28, 2024
1 parent ddff9b4 commit 91214db
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion invokeai/app/services/events/events_common.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from math import floor
from typing import TYPE_CHECKING, Any, Coroutine, Generic, Optional, Protocol, TypeAlias, TypeVar
from typing import TYPE_CHECKING, Any, ClassVar, Coroutine, Generic, Optional, Protocol, TypeAlias, TypeVar

from fastapi_events.handlers.local import local_handler
from fastapi_events.registry.payload_schema import registry as payload_schema
Expand Down Expand Up @@ -33,6 +33,7 @@ class EventBase(BaseModel):
A timestamp is automatically added to the event when it is created.
"""

__event_name__: ClassVar[str]
timestamp: int = Field(description="The timestamp of the event", default_factory=get_timestamp)

model_config = ConfigDict(json_schema_serialization_defaults_required=True)
Expand Down

0 comments on commit 91214db

Please sign in to comment.