Skip to content

Commit 0b04032

Browse files
sambacc: add a JSONData type for convenience
When working with arbitrary json data dicts it's easier to write "JSONData". Signed-off-by: John Mulligan <[email protected]>
1 parent d5f7f98 commit 0b04032

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

sambacc/config.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
PasswdEntryTuple = typing.Tuple[str, str, str, str, str, str, str]
3333
GroupEntryTuple = typing.Tuple[str, str, str, str]
3434

35+
# JSONData is not really a completely valid representation of json in
36+
# the type system, but it's good enough for now. Using it can help
37+
# clarify what works with json and what works with real python dicts.
38+
JSONData = dict[str, typing.Any]
39+
3540
# the standard location for samba's smb.conf
3641
SMB_CONF = "/etc/samba/smb.conf"
3742

@@ -68,7 +73,7 @@ def read_config_files(fnames: list[str]) -> GlobalConfig:
6873
return gconfig
6974

7075

71-
def _check_config_data(data: dict[str, typing.Any]) -> dict[str, typing.Any]:
76+
def _check_config_data(data: JSONData) -> JSONData:
7277
"""Return the config data or raise a ValueError if the config
7378
is invalid or incomplete.
7479
"""
@@ -91,7 +96,7 @@ def shares(self) -> typing.Iterable[ShareConfig]:
9196

9297
class GlobalConfig:
9398
def __init__(self, source: typing.Optional[typing.IO] = None) -> None:
94-
self.data: dict[str, typing.Any] = {}
99+
self.data: JSONData = {}
95100
if source is not None:
96101
self.load(source)
97102

0 commit comments

Comments
 (0)