Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

handlers: typing and doc fix #701

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

adekmaulana
Copy link
Contributor

@adekmaulana adekmaulana commented Jun 19, 2021

There's inconsistency between using callable and Callable so the typing will be giving some error incompatible.
Because on ~Handler used Callable while on every type of handlers using callable.

callable: obj -> bool
Callable[*args: Unknown, **kwargs: Unknown] -> Unknown

also fixed some doc.

Before

(class) MessageHandler(callback: (__obj: object) -> bool, filters: Unknown = None)
The base class of the class hierarchy.

When called, it accepts no arguments and returns a new featureless instance that has no instance attributes and cannot be given any.

Typing Error

Argument of type "(client: Client, msg: Message) -> Coroutine[Any, Any, None]" cannot be assigned to parameter "callback" of type "(__obj: object) -> bool" in function "__init__"
  Type "(client: Client, msg: Message) -> Coroutine[Any, Any, None]" cannot be assigned to type "(__obj: object) -> bool"
    Parameter 1: type "object" cannot be assigned to type "Client"
      "object" is incompatible with "Client"
    Function accepts too few positional parameters; expected 2 but received 1
    Keyword parameter "msg" is missing in destination
    Function return type "Coroutine[Any, Any, None]" is incompatible with type "bool"
      "Coroutine[Any, Any, None]" is incompatible with "bool"

After:

(class) MessageHandler(callback: (_p0: Client, _p1: Message) -> Any, filters: Filter | None = None)
The base class of the class hierarchy.

When called, it accepts no arguments and returns a new featureless instance that has no instance attributes and cannot be given any.

Typing Error:
None

@SpEcHiDe SpEcHiDe mentioned this pull request Jan 13, 2025
29 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant