From 33da5c1afca1e13e3bd6206d249093db828bb801 Mon Sep 17 00:00:00 2001 From: Luper Rouch Date: Mon, 22 May 2023 11:27:31 +0200 Subject: [PATCH] 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] --- src/textual/app.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/textual/app.py b/src/textual/app.py index d92c858dc..05ae29922 100644 --- a/src/textual/app.py +++ b/src/textual/app.py @@ -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)