home · contact · privacy
Drop unnecessary complexity of _UpdatingNode.log_scopes. master
authorChristian Heller <c.heller@plomlompom.de>
Fri, 19 Sep 2025 23:34:41 +0000 (01:34 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 19 Sep 2025 23:34:41 +0000 (01:34 +0200)
ircplom/client_tui.py

index 8bc3a797fc560f730cafab928ba335f5d9ba4152..9a5cf8a0a6e3b10087a394d594ee379759f716ae 100644 (file)
@@ -46,19 +46,10 @@ class _Update:
 
 
 class _UpdatingNode(AutoAttrMixin):
-    log_scopes: dict[str, LogScope] = {'': LogScope.SERVER}
 
     def _make_attr(self, cls: Callable, key: str):
         return cls()
 
-    @classmethod
-    def _scope(cls, key: str) -> LogScope:
-        scopes: dict[str, LogScope] = {}
-        for c in cls.__mro__:
-            if hasattr(c, 'log_scopes'):
-                scopes = c.log_scopes | scopes
-        return scopes.get(key, scopes[''])
-
     def recursive_set_and_report_change(self, update: _Update) -> None:
         'Apply update, and, if it makes a difference, add to its .results.'
         update.force_log = update.force_log or (not self._is_set(update.key))
@@ -68,7 +59,6 @@ class _UpdatingNode(AutoAttrMixin):
             node.recursive_set_and_report_change(update)
         else:
             update.old_value = node
-            scope = self._scope(update.key)
             do_report = update.force_log
             if update.value is None:
                 if self._is_set(update.key):
@@ -78,7 +68,7 @@ class _UpdatingNode(AutoAttrMixin):
                 self._set(update.key, update.value)
                 do_report |= True
             if do_report:
-                update.results += [(scope,
+                update.results += [(LogScope.SERVER,
                                     tuple(sorted(update.value))
                                     if isinstance(update.value, set)
                                     else update.value)]
@@ -247,7 +237,6 @@ class _UpdatingChannel(_UpdatingNode, Channel):
 
 
 class _UpdatingUser(_UpdatingNode, User):
-    log_scopes = {'exit_msg': LogScope.USER_NO_CHANNELS}
     prev_nick = '?'
 
     def recursive_set_and_report_change(self, update: _Update) -> None:
@@ -265,7 +254,7 @@ class _UpdatingUser(_UpdatingNode, User):
                     msg = f':{self} quits'
                     if len(update.value) > 1:
                         msg += f': {update.value[1:]}'
-                    update.results += [(self._scope(update.key), [msg])]
+                    update.results += [(LogScope.USER_NO_CHANNELS, [msg])]
 
     @property
     def prev(self) -> str: