Skip to content

Wrong type hint of DOMNode.watch method #1805

@mzebrak

Description

@mzebrak

It looks like after the latest changes 0.11.0 (because in 0.10.1 there was no issue), the wrong type hint was used for DOMNode.watch method.

After upgrading textual in my project I see mypy errorrs like below:

Argument 3 to "watch" of "DOMNode" has incompatible type "Callable[[Any], None]"; expected "Union[Callable[[], Awaitable[None]], Callable[[], None]]"  [arg-type]

After some investigation, argument no.3 in the 0.11.0 is:

callback: CallbackType,

which is:

CallbackType = Union[Callable[[], Awaitable[None]], Callable[[], None]]

This is not true because Callabe can take additional arguments - current_value and previous_value (both of the Any type).

Previously, in the reactive.watch method, it was:

 callback: Callable[[Any], object]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions