home · contact · privacy
Sort out dataclasses Mixins on _IrcConnection.
authorChristian Heller <c.heller@plomlompom.de>
Tue, 5 Aug 2025 11:04:32 +0000 (13:04 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Tue, 5 Aug 2025 11:04:32 +0000 (13:04 +0200)
ircplom/client.py

index 0d755c2506c591bacd4ed36a6ceb0982e3f13d65..5453afe274a4c7686867aaeaa586ddc3a08caaa4 100644 (file)
@@ -2,7 +2,7 @@
 # built-ins
 from abc import ABC, abstractmethod
 from base64 import b64encode
-from dataclasses import dataclass
+from dataclasses import dataclass, InitVar
 from getpass import getuser
 from threading import Thread
 from typing import Callable, Optional
@@ -32,12 +32,14 @@ class ClientEvent(AffectiveEvent, ClientIdMixin):
     'To affect Client identified by ClientIdMixin.'
 
 
-class _IrcConnection(BaseIrcConnection):
+@dataclass
+class _IrcConnection(BaseIrcConnection, ClientIdMixin):
+    hostname: InitVar[str]
+    port: InitVar[int]
 
-    def __init__(self, client_id: str, **kwargs) -> None:
-        # TODO: find out why I can't just ClientIdMixin here
-        self.client_id = client_id
-        super().__init__(**kwargs)
+    def __post_init__(self, hostname, port, **kwargs) -> None:
+        super().__init__(hostname=hostname, port=port, q_out=self.q_out,
+                         **kwargs)
 
     def _make_recv_event(self, msg: IrcMessage) -> ClientEvent:
         # pylint: disable=unexpected-keyword-arg  # confused by client_id=