Fix App.BINDINGS type (#2620)

The implicit type was creating mypy errors when defining bindings with
tuples. For example:

    class MyApp(App):
        BINDINGS = [("q", "quit", "Quit")]

Would give the error:

    error: List item 0 has incompatible type "Tuple[str, str, str]"; expected "Binding"  [list-item]
This commit is contained in:
Luper Rouch
2023-05-22 11:27:31 +02:00
committed by GitHub
parent 7d0d1ac5c8
commit 33da5c1afc

View File

@@ -71,7 +71,7 @@ from ._wait import wait_for_idle
from ._worker_manager import WorkerManager
from .actions import ActionParseResult, SkipAction
from .await_remove import AwaitRemove
from .binding import Binding, _Bindings
from .binding import Binding, _Bindings, BindingType
from .css.query import NoMatches
from .css.stylesheet import Stylesheet
from .design import ColorSystem
@@ -230,7 +230,9 @@ class App(Generic[ReturnType], DOMNode):
To update the sub-title while the app is running, you can set the [sub_title][textual.app.App.sub_title] attribute.
"""
BINDINGS = [Binding("ctrl+c", "quit", "Quit", show=False, priority=True)]
BINDINGS: ClassVar[list[BindingType]] = [
Binding("ctrl+c", "quit", "Quit", show=False, priority=True)
]
title: Reactive[str] = Reactive("", compute=False)
sub_title: Reactive[str] = Reactive("", compute=False)