-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: correct typehints in project #395
base: develop
Are you sure you want to change the base?
Conversation
def __eq__(self, other): | ||
if type(other) is not MediaId: | ||
def __eq__(self, other: object) -> bool: | ||
if not isinstance(other, MediaId): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
original code was correct
@@ -7,6 +7,7 @@ | |||
from aiogram.fsm.state import State | |||
|
|||
from aiogram_dialog.api.exceptions import DialogStackOverflow | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we had a discussion that this is probably can be configured
from aiogram_dialog.api.protocols import DialogProtocol | ||
|
||
|
||
@runtime_checkable | ||
class Widget(Protocol): | ||
@abstractmethod | ||
def managed(self, manager: DialogManager) -> Any: | ||
def managed(self, manager: DialogManager) -> "Widget": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it does'n return widget, it returns managed version of widget - it's a differnt type.
@@ -28,7 +34,9 @@ def find(self, widget_id: str) -> Optional["Widget"]: | |||
class TextWidget(Widget, Protocol): | |||
@abstractmethod | |||
async def render_text( | |||
self, data: Dict, manager: DialogManager, | |||
self, | |||
data: Dict[str, Union[DataDict, Dict[str, Any], ChatEvent]], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very strange values. I believe it should be data: Dict[str, Any]
from aiogram_dialog.api.entities import Data, LaunchMode, NewMessage | ||
from ..internal import Widget | ||
|
||
from ... import ChatEvent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Please, avoid
...
imports. I would allow relative import within widgets package, but not outside of it. - Do not import from library package itself, import from subpackages, otherwise it will lead to cycle imports
) -> None: | ||
raise NotImplementedError | ||
|
||
@abstractmethod | ||
def find(self, widget_id) -> Any: | ||
def find(self, widget_id: str) -> Optional[Widget]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, it is not widget returned, but "managed" one
type: ContentType, | ||
media_id: MediaId, | ||
self, | ||
path: Optional[Union[str, Path]], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It breaks compatibility, let's keep str
intent_id, | ||
stack_id, | ||
event.from_user.id, | ||
cast(User, event.from_user).id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like we need to add check instead of cast
No description provided.