-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Убрал повторную регистрацию мидлварей в диспетчере для таймаут события Добавил удобные тайпхинты для property полей Добавил session в __init__ в TYPE_CHECKING блоке для наследников от AliceEvent
- Loading branch information
Showing
16 changed files
with
195 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,35 @@ | ||
from typing import TYPE_CHECKING, Any | ||
from typing import TYPE_CHECKING, Any, cast | ||
|
||
from ..enums import EventType | ||
from .alice_event import AliceEvent | ||
from .update import Update | ||
from .base import MutableAliceObject | ||
from .update import Update, UpdateTypeLookupError | ||
|
||
|
||
class TimeoutEvent(AliceEvent): | ||
# Если кто-то сможет лучше реализовать подмену update'а - буду благодарен | ||
class TimeoutUpdate(Update): | ||
"""Внутренннее событие, используется для реакции на выход за время ответа.""" | ||
|
||
update: Update | ||
|
||
if TYPE_CHECKING: | ||
__init__ = Update.__init__ | ||
|
||
else: | ||
|
||
@property | ||
def event(self) -> AliceEvent: | ||
return cast(AliceEvent, getattr(self, self._real_event_type)) | ||
|
||
@property | ||
def event_type(self) -> str: | ||
return str(EventType.TIMEOUT) | ||
|
||
def __init__( | ||
__pydantic_self__, | ||
*, | ||
update: Update, | ||
**__pydantic_kwargs: Any, | ||
) -> None: | ||
super().__init__( | ||
update=update, | ||
**__pydantic_kwargs, | ||
) | ||
def model_post_init(self, __context: Any) -> None: | ||
MutableAliceObject.model_post_init(self, __context) | ||
try: | ||
self._event_model_validate(self._real_event_type, __context) | ||
except UpdateTypeLookupError: | ||
pass | ||
|
||
@property | ||
def event(self) -> AliceEvent: | ||
return self.update.event | ||
def _real_event_type(self) -> str: | ||
return super().event_type |
Oops, something went wrong.