Skip to content

Commit

Permalink
Removed tomlkit, added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ikollipara committed Oct 26, 2024
1 parent ecd2914 commit 918a498
Show file tree
Hide file tree
Showing 3 changed files with 206 additions and 33 deletions.
13 changes: 10 additions & 3 deletions green/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@
from typing import Callable, Sequence # pragma: no cover

import coverage # pragma: no cover
import tomlkit

try:
import tomllib # pragma: no cover

supports_tomllib = True
except ImportError:
supports_tomllib = False

coverage_version = f"Coverage {coverage.__version__}" # pragma: no cover

Expand Down Expand Up @@ -629,7 +635,8 @@ def getConfig( # pragma: no cover

cwd = pathlib.Path.cwd()
# Medium priority
for cfg_file in ("setup.cfg", ".green", "pyproject.toml"):
config_files = [] if not supports_tomllib else ["pyproject.toml"]
for cfg_file in config_files + ["setup.cfg", ".green"]:
config_path = cwd / cfg_file
if config_path.is_file():
filepaths.append(config_path)
Expand All @@ -649,7 +656,7 @@ def getConfig( # pragma: no cover
if config_path.name == "setup.cfg":
parser.read(config_path)
elif config_path.name == "pyproject.toml":
data = tomlkit.load(config_path.open("rb"))["tool"]
data = tomllib.load(config_path.open("rb"))["tool"]
parser.read_dict(data, source="green")
else:
parser.read_file(ConfigFile(config_path))
Expand Down
Loading

0 comments on commit 918a498

Please sign in to comment.