Skip to content

Commit 708d432

Browse files
authored
add missing docstrings (#53)
1 parent 7e1eac6 commit 708d432

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

hikari_clusters/brain.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ def waiting_for(self, value: tuple[int, int] | None) -> None:
150150
self._waiting_for = value
151151

152152
def get_info(self) -> BrainInfo:
153-
# <<<docstring from superclass>>>
153+
# <<<docstring from BaseClient>>>
154+
154155
assert self.ipc.uid
155156
return BrainInfo(uid=self.ipc.uid)
156157

@@ -167,15 +168,17 @@ def sigstop(*args: Any, **kwargs: Any) -> None:
167168
loop.run_until_complete(self.close())
168169

169170
async def start(self) -> None:
170-
# <<<docstring from superclass>>>
171+
# <<<docstring from BaseClient>>>
172+
171173
self.stop_future = asyncio.Future()
172174

173175
await self.server.start()
174176
await super().start()
175177
self.tasks.create_task(self._main_loop())
176178

177179
async def close(self) -> None:
178-
# <<<docstring from superclass>>>
180+
# <<<docstring from BaseClient>>>
181+
179182
self.ipc.stop()
180183
await self.ipc.close()
181184

hikari_clusters/cluster.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ def __init__(
8888
self.bot.cluster = self # type: ignore
8989

9090
def get_info(self) -> ClusterInfo:
91+
# <<<docstring from BaseClient>>>
92+
9193
assert self.ipc.uid
9294
return ClusterInfo(
9395
self.ipc.uid, self.server_uid, self.shard_ids, self.ready
@@ -118,7 +120,8 @@ def shard_count(self) -> int:
118120
return self._shard_count
119121

120122
async def start(self, **kwargs: Any) -> None:
121-
# <<<docstring from superclass>>>
123+
# <<<docstring from BaseClient>>>
124+
122125
await super().start()
123126

124127
kwargs["shard_count"] = self.shard_count
@@ -127,9 +130,9 @@ async def start(self, **kwargs: Any) -> None:
127130
await self.bot.start(**kwargs)
128131

129132
async def close(self) -> None:
130-
# <<<docstring from superclass>>>
131-
await self.bot.close()
133+
# <<<docstring from BaseClient>>>
132134

135+
await self.bot.close()
133136
await super().close()
134137

135138

hikari_clusters/info_classes.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,22 @@ def __init_subclass__(cls) -> None:
4444
BaseInfo._info_classes[cls._info_class_id] = cls
4545

4646
def asdict(self) -> dict[str, Any]:
47+
"""Convert this info class to a dictionary."""
48+
4749
dct = asdict(self)
4850
dct["_info_class_id"] = self._info_class_id
4951
return dct
5052

5153
@staticmethod
5254
def fromdict(data: dict[str, Any]) -> BaseInfo:
55+
"""Convert a dictionary back into its info class."""
56+
5357
cls = BaseInfo._info_classes[data.pop("_info_class_id")]
5458
return cls(**data)
5559

5660
def __int__(self) -> int:
61+
"""The IPC UID of the client this info class represents."""
62+
5763
return self.uid
5864

5965

@@ -105,6 +111,8 @@ def get_cluster_id(shard_id: int, shards_per_cluster: int) -> int:
105111

106112
@dataclass
107113
class BrainInfo(BaseInfo):
114+
"""A representation of a :class:`~brain.Brain`."""
115+
108116
_info_class_id = 2
109117
uid: int
110118
"""The ipc uid of the brain."""

hikari_clusters/server.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ def clusters(self) -> list[ClusterInfo]:
103103
]
104104

105105
def get_info(self) -> ServerInfo:
106+
# <<<docstring from BaseClient>>>
107+
106108
assert self.ipc.uid
107109
return ServerInfo(self.ipc.uid, [c.uid for c in self.clusters])
108110

@@ -119,9 +121,9 @@ def sigstop(*args: Any, **kwargs: Any) -> None:
119121
loop.run_until_complete(self.close())
120122

121123
async def start(self) -> None:
122-
# <<<docstring from superclass>>>
123-
await super().start()
124+
# <<<docstring from BaseClient>>>
124125

126+
await super().start()
125127
self.tasks.create_task(self._loop_cleanup_processes())
126128

127129
async def _loop_cleanup_processes(self) -> None:

0 commit comments

Comments
 (0)