From 5a6fbdf0bf32d424e8c80596345f42383fc886b4 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Fri, 18 Oct 2024 15:21:17 +0100 Subject: [PATCH] private var --- src/textual/app.py | 2 +- src/textual/dom.py | 9 +++++---- src/textual/widget.py | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/textual/app.py b/src/textual/app.py index 129b18cabf..e829110b60 100644 --- a/src/textual/app.py +++ b/src/textual/app.py @@ -487,7 +487,7 @@ class MyApp(App[None]): INLINE_PADDING: ClassVar[int] = 1 """Number of blank lines above an inline app.""" - PSEUDO_CLASSES: ClassVar[dict[str, Callable[[App], bool]]] = { + _PSEUDO_CLASSES: ClassVar[dict[str, Callable[[App], bool]]] = { "focus": lambda app: app.app_focus, "blur": lambda app: not app.app_focus, "dark": lambda app: app.dark, diff --git a/src/textual/dom.py b/src/textual/dom.py index 57ab3281f1..e215c5116f 100644 --- a/src/textual/dom.py +++ b/src/textual/dom.py @@ -180,7 +180,8 @@ class DOMNode(MessagePump): # Names of potential computed reactives _computes: ClassVar[frozenset[str]] - PSEUDO_CLASSES: ClassVar[dict[str, Callable[[object], bool]]] = {} + _PSEUDO_CLASSES: ClassVar[dict[str, Callable[[object], bool]]] = {} + """Pseudo class checks.""" def __init__( self, @@ -1239,7 +1240,7 @@ def get_pseudo_classes(self) -> set[str]: return { name - for name, check_class in self.PSEUDO_CLASSES.items() + for name, check_class in self._PSEUDO_CLASSES.items() if check_class(self) } @@ -1665,7 +1666,7 @@ def has_pseudo_class(self, class_name: str) -> bool: Returns: `True` if the DOM node has the pseudo class, `False` if not. """ - return class_name in self.PSEUDO_CLASSES and self.PSEUDO_CLASSES[class_name]( + return class_name in self._PSEUDO_CLASSES and self._PSEUDO_CLASSES[class_name]( self ) @@ -1678,7 +1679,7 @@ def has_pseudo_classes(self, class_names: set[str]) -> bool: Returns: `True` if all pseudo class names are present. """ - PSEUDO_CLASSES = self.PSEUDO_CLASSES + PSEUDO_CLASSES = self._PSEUDO_CLASSES return all( (name in PSEUDO_CLASSES and PSEUDO_CLASSES[name](self)) for name in class_names diff --git a/src/textual/widget.py b/src/textual/widget.py index 0fe9d08264..8985566129 100644 --- a/src/textual/widget.py +++ b/src/textual/widget.py @@ -367,7 +367,7 @@ class Widget(DOMNode): # Default sort order, incremented by constructor _sort_order: ClassVar[int] = 0 - PSEUDO_CLASSES: ClassVar[dict[str, Callable[[Widget], bool]]] = { + _PSEUDO_CLASSES: ClassVar[dict[str, Callable[[Widget], bool]]] = { "hover": lambda widget: widget.mouse_hover, "focus": lambda widget: widget.has_focus, "blur": lambda widget: not widget.has_focus,