From: Christian Heller Date: Wed, 5 Nov 2025 19:19:13 +0000 (+0100) Subject: Variable renaming for greater code clarity. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%7B%7B%20web_path%20%7D%7D/decks/template?a=commitdiff_plain;p=ircplom Variable renaming for greater code clarity. --- diff --git a/src/ircplom/client.py b/src/ircplom/client.py index c6b1246..546026e 100644 --- a/src/ircplom/client.py +++ b/src/ircplom/client.py @@ -429,21 +429,21 @@ class _ClientDb(_Clearable, _UpdatingAttrsMixin, SharedClientDbFields): def __getattribute__(self, key: str): attr = super().__getattribute__(key) - if key == 'channels' and attr._create_if_none is None\ + if key == 'channels' and attr._preset_init_kwargs is None\ and super().__getattribute__('users' - )._create_if_none is not None: - attr._create_if_none = { + )._preset_init_kwargs is not None: + attr._preset_init_kwargs = { 'userid_for_nickuserhost': self.users.id_for_nickuserhost, 'get_membership_prefixes': self._get_membership_prefixes, 'purge_users': self.users.purge} elif key == 'users': attr.userlen = int(self.isupport['USERLEN']) - if attr._create_if_none is None: - attr._create_if_none = { + if attr._preset_init_kwargs is None: + attr._preset_init_kwargs = { 'names_channels_of_user': self.channels.of_user, 'remove_from_channels': self.channels.remove_user} - elif key == 'caps' and attr._create_if_none is None: - attr._create_if_none = {} + elif key == 'caps' and attr._preset_init_kwargs is None: + attr._preset_init_kwargs = {} return attr def messaging(self, src: str | NickUserHost) -> ChatMessage: diff --git a/src/ircplom/db_primitives.py b/src/ircplom/db_primitives.py index 55e670d..9728e2d 100644 --- a/src/ircplom/db_primitives.py +++ b/src/ircplom/db_primitives.py @@ -182,15 +182,15 @@ class _UpdatingAttrsMixin(_UpdatingMixin, AutoAttrMixin): class _UpdatingDict(_UpdatingMixin, Dict[DictItem]): - _create_if_none: Optional[dict[str, Any]] = None + _preset_init_kwargs: Optional[dict[str, Any]] = None def __bool__(self) -> bool: return bool(self._dict) def __getitem__(self, key: str) -> DictItem: if key not in self._dict: - if self._create_if_none is not None: - kw = {} | self._create_if_none + if self._preset_init_kwargs is not None: + kw = {} | self._preset_init_kwargs if _UpdatingMixin in self._item_cls.__mro__: kw |= {'on_update': lambda *steps: self._on_update(key, *steps)}