Skip to content

Commit

Permalink
Fix type annotations for tomllib/tomli
Browse files Browse the repository at this point in the history
  • Loading branch information
sirosen committed May 31, 2024
1 parent 9f88512 commit b19e371
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion nose2/_toml.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
from __future__ import annotations

import types

TOML_ENABLED: bool = False
toml: types.ModuleType | None = None

try:
import tomllib as toml
Expand All @@ -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)

0 comments on commit b19e371

Please sign in to comment.