use tomllib from standard library on Python3.11+

This commit is contained in:
Alexandre Detiste
2026-02-18 10:48:45 +01:00
parent 3ac7af4683
commit 673281ed71
2 changed files with 8 additions and 3 deletions

View File

@@ -24,13 +24,18 @@ import dataclasses
import functools import functools
import logging import logging
import secrets import secrets
import sys
from collections.abc import AsyncGenerator, Awaitable, Callable, Iterable, Sequence from collections.abc import AsyncGenerator, Awaitable, Callable, Iterable, Sequence
from typing import ( from typing import (
Any, Any,
) )
import click import click
import tomli
if sys.version_info >= (3, 11):
import tomllib
else:
import tomli as tomllib
try: try:
import lc3 # type: ignore # pylint: disable=E0401 import lc3 # type: ignore # pylint: disable=E0401
@@ -114,7 +119,7 @@ def parse_broadcast_list(filename: str) -> Sequence[Broadcast]:
broadcasts: list[Broadcast] = [] broadcasts: list[Broadcast] = []
with open(filename, "rb") as config_file: with open(filename, "rb") as config_file:
config = tomli.load(config_file) config = tomllib.load(config_file)
for broadcast in config.get("broadcasts", []): for broadcast in config.get("broadcasts", []):
sources = [] sources = []
for source in broadcast.get("sources", []): for source in broadcast.get("sources", []):

View File

@@ -37,7 +37,7 @@ dependencies = [
"pyserial-asyncio >= 0.5; platform_system!='Emscripten'", "pyserial-asyncio >= 0.5; platform_system!='Emscripten'",
"pyserial >= 3.5; platform_system!='Emscripten'", "pyserial >= 3.5; platform_system!='Emscripten'",
"pyusb >= 1.2; platform_system!='Emscripten'", "pyusb >= 1.2; platform_system!='Emscripten'",
"tomli ~= 2.2.1; platform_system!='Emscripten'", "tomli ~= 2.2.1; platform_system!='Emscripten'; python_version<'3.11'",
"websockets >= 15.0.1; platform_system!='Emscripten'", "websockets >= 15.0.1; platform_system!='Emscripten'",
] ]