Skip to content

Commit

Permalink
private var
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Oct 18, 2024
1 parent 8dfc3d1 commit 5a6fbdf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/textual/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 5 additions & 4 deletions src/textual/dom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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
)

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/textual/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 5a6fbdf

Please sign in to comment.