mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Address review comments.
This commit is contained in:
@@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
- Added read-only public access to the children of a `TreeNode` via `TreeNode.children` https://github.com/Textualize/textual/issues/1398
|
||||
- Added `Tree.get_node_by_id` to allow getting a node by its ID https://github.com/Textualize/textual/pull/1535
|
||||
- Added a `Tree.NodeHighlighted` message, giving a `on_tree_node_highlighted` event handler https://github.com/Textualize/textual/issues/1400
|
||||
- Added a `_inherit_component_classes` class variable to control whether or not component classes are inherited from base classes https://github.com/Textualize/textual/issues/1399
|
||||
- Added a `inherit_component_classes` subclassing parameter to control whether or not component classes are inherited from base classes https://github.com/Textualize/textual/issues/1399
|
||||
- Added `diagnose` as a `textual` command https://github.com/Textualize/textual/issues/1542
|
||||
|
||||
### Changed
|
||||
|
||||
@@ -163,11 +163,15 @@ class DOMNode(MessagePump):
|
||||
self.refresh()
|
||||
|
||||
def __init_subclass__(
|
||||
cls, inherit_css: bool = True, inherit_bindings: bool = True
|
||||
cls,
|
||||
inherit_css: bool = True,
|
||||
inherit_bindings: bool = True,
|
||||
inherit_component_classes: bool = True,
|
||||
) -> None:
|
||||
super().__init_subclass__()
|
||||
cls._inherit_css = inherit_css
|
||||
cls._inherit_bindings = inherit_bindings
|
||||
cls._inherit_component_classes = inherit_component_classes
|
||||
css_type_names: set[str] = set()
|
||||
for base in cls._css_bases(cls):
|
||||
css_type_names.add(base.__name__)
|
||||
|
||||
@@ -47,6 +47,7 @@ def test_validate():
|
||||
|
||||
def test_inherited_bindings():
|
||||
"""Test if binding merging is done correctly when (not) inheriting bindings."""
|
||||
|
||||
class A(DOMNode):
|
||||
BINDINGS = [("a", "a", "a")]
|
||||
|
||||
@@ -81,14 +82,19 @@ def test_inherited_bindings():
|
||||
def test_get_default_css():
|
||||
class A(DOMNode):
|
||||
pass
|
||||
|
||||
class B(A):
|
||||
pass
|
||||
|
||||
class C(B):
|
||||
DEFAULT_CSS = "C"
|
||||
|
||||
class D(C):
|
||||
pass
|
||||
|
||||
class E(D):
|
||||
DEFAULT_CSS = "E"
|
||||
|
||||
node = DOMNode()
|
||||
node_css = node.get_default_css()
|
||||
a = A()
|
||||
@@ -121,9 +127,8 @@ def test_component_classes_inheritance():
|
||||
class A(DOMNode):
|
||||
COMPONENT_CLASSES = {"a-1", "a-2"}
|
||||
|
||||
class B(A):
|
||||
class B(A, inherit_component_classes=False):
|
||||
COMPONENT_CLASSES = {"b-1"}
|
||||
_inherit_component_classes = False
|
||||
|
||||
class C(B):
|
||||
COMPONENT_CLASSES = {"c-1", "c-2"}
|
||||
@@ -134,9 +139,8 @@ def test_component_classes_inheritance():
|
||||
class E(D):
|
||||
COMPONENT_CLASSES = {"e-1"}
|
||||
|
||||
class F(E):
|
||||
class F(E, inherit_component_classes=False):
|
||||
COMPONENT_CLASSES = {"f-1"}
|
||||
_inherit_component_classes = False
|
||||
|
||||
node = DOMNode()
|
||||
node_cc = node.get_component_classes()
|
||||
|
||||
Reference in New Issue
Block a user