diff --git a/nose2/_toml.py b/nose2/_toml.py index 6577b223..ff81d026 100644 --- a/nose2/_toml.py +++ b/nose2/_toml.py @@ -1,4 +1,9 @@ +from __future__ import annotations + +import types + TOML_ENABLED: bool = False +toml: types.ModuleType | None = None try: import tomllib as toml @@ -15,7 +20,7 @@ def load_toml(file: str) -> dict: - if not TOML_ENABLED: + if toml is None: raise RuntimeError("toml library not found. Please install 'tomli'.") with open(file, "rb") as fp: return toml.load(fp)