[+] improve toml compatibility for python 3.10

This commit is contained in:
Siarhei Siniak 2025-04-30 10:43:11 +03:00
parent 1faa511d15
commit e5af828867

@ -8,12 +8,25 @@ import sys
import subprocess
import os
import logging
import tomllib
from typing import (Self, Optional, Any,)
logger = logging.getLogger(__name__)
def toml_load(f: io.BytesIO) -> Any:
try:
import tomllib
return tomllib.load(f)
except:
pass
try:
import tomli
return tomli.load(f)
except:
pass
@dataclasses.dataclass
class PyProject:
path: pathlib.Path
@ -28,7 +41,7 @@ def pyproject_load(
d: pathlib.Path,
) -> PyProject:
with io.open(d, 'rb') as f:
content = tomllib.load(f)
content = toml_load(f)
assert isinstance(content, dict)