Skip to content

Commit 3a39e1e

Browse files
phlogistonjohnmergify[bot]
authored andcommitted
smabacc: document protocol methods
Add docststrings to various protocol types. Some are a bit vague as these are protocols not concrete types. Signed-off-by: John Mulligan <[email protected]>
1 parent 1e7e4d9 commit 3a39e1e

File tree

6 files changed

+22
-3
lines changed

6 files changed

+22
-3
lines changed

sambacc/config.py

+4
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,14 @@ def read_config_files(
193193

194194

195195
class SambaConfig(typing.Protocol):
196+
"""Minimal samba configuration protocol."""
197+
196198
def global_options(self) -> typing.Iterable[typing.Tuple[str, str]]:
199+
"""Return global options for Samba."""
197200
... # pragma: no cover
198201

199202
def shares(self) -> typing.Iterable[ShareConfig]:
203+
"""Return share configurations for Samba."""
200204
... # pragma: no cover
201205

202206

sambacc/ctdb.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,25 @@
4040

4141

4242
class ClusterMetaObject(typing.Protocol):
43+
"A Cluster Meta Object can load or dump persistent cluster descriptions."
44+
4345
def load(self) -> typing.Any:
44-
...
46+
"""Load a JSON-compatible object."""
47+
... # pragma: no cover
4548

4649
def dump(self, data: typing.Any) -> None:
47-
...
50+
"""Dump (save) a JSON-compatible object."""
51+
... # pragma: no cover
4852

4953

5054
class ClusterMeta(typing.Protocol):
55+
"""ClusterMeta manages access to persistent cluster descriptions."""
56+
5157
def open(
5258
self, *, read: bool = True, write: bool = False, locked: bool = False
5359
) -> typing.ContextManager[ClusterMetaObject]:
54-
...
60+
"""Return a context manager with access to a cluster meta object."""
61+
... # pragma: no cover
5562

5663

5764
class NodeState(str, enum.Enum):

sambacc/leader.py

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class LeaderStatus(typing.Protocol):
2525
"""Fetches information about the current cluster leader."""
2626

2727
def is_leader(self) -> bool:
28+
"""Return true if the current node is the leader."""
2829
... # pragma: no cover
2930

3031

@@ -35,9 +36,11 @@ class LeaderLocator(typing.Protocol):
3536
"""
3637

3738
def __enter__(self) -> LeaderStatus:
39+
"""Enter context manager. Returns LeaderStatus."""
3840
... # pragma: no cover
3941

4042
def __exit__(
4143
self, exc_type: ExcType, exc_val: ExcValue, exc_tb: ExcTraceback
4244
) -> bool:
45+
"""Exit context manager."""
4346
... # pragma: no cover

sambacc/opener.py

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class Opener(typing.Protocol):
2929
"""
3030

3131
def open(self, path_or_uri: str) -> typing.IO:
32+
"""Open a specified resource by path or (pseudo) URI."""
3233
... # pragma: no cover
3334

3435

sambacc/simple_waiter.py

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class Waiter(typing.Protocol):
6666
"""Waiter protocol - interfaces common to all waiters."""
6767

6868
def wait(self) -> None:
69+
"""Pause execution for a time."""
6970
... # pragma: no cover
7071

7172
def acted(self) -> None:

sambacc/smbconf_api.py

+3
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@
2121

2222
class ConfigStore(typing.Protocol):
2323
def __getitem__(self, name: str) -> list[tuple[str, str]]:
24+
"""Get an item, returning a config section."""
2425
... # pragma: no cover
2526

2627
def __setitem__(self, name: str, value: list[tuple[str, str]]) -> None:
28+
"""Set a new config section."""
2729
... # pragma: no cover
2830

2931
def __iter__(self) -> typing.Iterator[str]:
32+
"""Iterate over config sections in the store."""
3033
... # pragma: no cover
3134

3235

0 commit comments

Comments
 (0)