Skip to content
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

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft

Conversation

yarqr
Copy link
Contributor

@yarqr yarqr commented Apr 30, 2024

No description provided.

def __eq__(self, other):
if type(other) is not MediaId:
def __eq__(self, other: object) -> bool:
if not isinstance(other, MediaId):
Copy link
Owner

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

Copy link
Owner

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":
Copy link
Owner

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]],
Copy link
Owner

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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Please, avoid ... imports. I would allow relative import within widgets package, but not outside of it.
  2. 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]:
Copy link
Owner

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]],
Copy link
Owner

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,
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants