From 882bbc91d0ad1900f98cacebe860813e4bb5f62a Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Thu, 18 Sep 2025 02:47:04 +0200 Subject: [PATCH] Ensure proper resets of dicts on connect/disconnect. --- ircplom/client.py | 12 +++--------- test.txt | 11 +++++++---- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/ircplom/client.py b/ircplom/client.py index 14274b6..6b9cd10 100644 --- a/ircplom/client.py +++ b/ircplom/client.py @@ -571,14 +571,6 @@ class _UpdatingChannelsDict(_UpdatingDict[_UpdatingChannel]): class _UpdatingIsupportDict(_UpdatingDict[str]): - def __init__(self, **kwargs) -> None: - super().__init__(**kwargs) - self._set_defaults() - - def _set_defaults(self): - for key, value in ISUPPORT_DEFAULTS.items(): - self._dict[key] = value - def __delitem__(self, key: str) -> None: if key in ISUPPORT_DEFAULTS: self[key] = ISUPPORT_DEFAULTS[key] @@ -587,7 +579,8 @@ class _UpdatingIsupportDict(_UpdatingDict[str]): def clear(self) -> None: super().clear() - self._set_defaults() + for key, value in ISUPPORT_DEFAULTS.items(): + self[key] = value class _ClientDb(_Clearable, _UpdatingAttrsMixin, SharedClientDbFields): @@ -762,6 +755,7 @@ class Client(ABC, ClientQueueMixin): self.client_id = conn_setup.hostname super().__init__(client_id=self.client_id, **kwargs) self.db = _ClientDb(on_update=self._on_update) + self.db.clear() self.caps = _CapsManager(self.send, self.db.caps) for k in conn_setup.__annotations__: setattr(self.db, k, getattr(conn_setup, k)) diff --git a/test.txt b/test.txt index 7f52a02..287dde1 100644 --- a/test.txt +++ b/test.txt @@ -43,7 +43,12 @@ # ETC. > /connect foo.bar.baz foo:bar baz +1,2 $ isupport cleared +1,2 $ isupport:CHANTYPES set to: [#&] +1,2 $ isupport:PREFIX set to: [(ov)@+] 1,2 $ caps cleared +1,2 $ users cleared +1,2 $ channels cleared 1,2 $ hostname set to: [foo.bar.baz] 1,2 $ port set to: [-1] 1,2 $ nick_wanted set to: [foo] @@ -53,8 +58,6 @@ 1,2 $ connection_state set to: [connecting] -1,2 $ channels cleared -1,2 $ users cleared 1,2 $ ?!?@? renames ? 1,2 $ users:me:user set to: [plom] 1,2 $ connection_state set to: [connected] @@ -71,8 +74,6 @@ 1,2 $$$ *** Found your hostname (baz.bar.foo) 2 < :*.?.net CAP * LS : foo bar sasl=PLAIN,EXTERNAL baz -1,2 $ isupport:CHANTYPES set to: [#&] -1,2 $ isupport:PREFIX set to: [(ov)@+] 2 > CAP REQ :sasl 2 > CAP :LIST @@ -209,6 +210,8 @@ 1,2,3,4 $ connection_state set to: [Closing link: (plom@baz.bar.foo) [Quit: ircplom says bye]] 1,2,3,4 $ connection_state set to: [] 1,2 $ isupport cleared +1,2 $ isupport:CHANTYPES set to: [#&] +1,2 $ isupport:PREFIX set to: [(ov)@+] 1,2 $ motd set to: 1,2 $ sasl_account set to: [] 1,2 $ sasl_auth_state set to: [] -- 2.30.2