MCPcopy
hub / github.com/Textualize/textual / _merge_bindings

Method _merge_bindings

src/textual/dom.py:671–695  ·  view source on GitHub ↗

Merge bindings from base classes. Returns: Merged bindings.

(cls)

Source from the content-addressed store, hash-verified

669
670 @classmethod
671 def _merge_bindings(cls) -> BindingsMap:
672 """Merge bindings from base classes.
673
674 Returns:
675 Merged bindings.
676 """
677 bindings: list[BindingsMap] = []
678
679 for base in reversed(cls.__mro__):
680 if issubclass(base, DOMNode):
681 if not base._inherit_bindings:
682 bindings.clear()
683 bindings.append(
684 BindingsMap(
685 base.__dict__.get("BINDINGS", []),
686 )
687 )
688
689 keys: dict[str, list[Binding]] = {}
690 for bindings_ in bindings:
691 for key, key_bindings in bindings_.key_to_bindings.items():
692 keys[key] = key_bindings
693
694 new_bindings = BindingsMap.from_keys(keys)
695 return new_bindings
696
697 def _post_register(self, app: App) -> None:
698 """Called when the widget is registered

Callers 1

__init_subclass__Method · 0.80

Calls 6

BindingsMapClass · 0.90
itemsMethod · 0.80
from_keysMethod · 0.80
clearMethod · 0.45
appendMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected