Skip to content

Commit 3905ed7

Browse files
phlogistonjohnmergify[bot]
authored andcommitted
sambacc: support tomli for reading toml on older versions
In versions of python prior to 3.11, we can fall back to the tomli library for toml support. Signed-off-by: John Mulligan <[email protected]>
1 parent 83d5863 commit 3905ed7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

sambacc/config.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,13 @@ def _load_toml(source: typing.IO) -> JSONData:
8080
else:
8181

8282
def _load_toml(source: typing.IO) -> JSONData:
83-
raise ConfigFormatUnsupported(ConfigFormat.TOML)
83+
try:
84+
import tomli
85+
except ImportError:
86+
raise ConfigFormatUnsupported(ConfigFormat.TOML)
87+
if typing.TYPE_CHECKING:
88+
assert isinstance(source, typing.BinaryIO)
89+
return tomli.load(source)
8490

8591

8692
def _load_yaml(source: typing.IO) -> JSONData:

0 commit comments

Comments
 (0)