Skip to content

Commit ff00de5

Browse files
author
notactuallyfinn
committed
removed toml dependency and pined setuptools to <82
1 parent 23a11b3 commit ff00de5

7 files changed

Lines changed: 532 additions & 542 deletions

File tree

docs/source/conf.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
#
2323
import os
2424
import sys
25-
import toml
25+
26+
import tomlkit
2627

2728
sys.path.insert(0, os.path.abspath('../../src'))
2829
sys.path.append(os.path.abspath('_ext'))
@@ -36,7 +37,7 @@ def read_from_pyproject(file_path="../../pyproject.toml"):
3637
"""
3738
try:
3839
# Load the pyproject.toml file
39-
data = toml.load(file_path)
40+
data = tomlkit.load(open(file_path, 'r')).unwrap()
4041

4142
# Navigate to the authors metadata
4243
metadata = data.get("project", {})
@@ -45,7 +46,7 @@ def read_from_pyproject(file_path="../../pyproject.toml"):
4546
return metadata
4647
except FileNotFoundError:
4748
return f"The file {file_path} was not found."
48-
except toml.TomlDecodeError:
49+
except tomlkit.exceptions.TOMLKitError:
4950
return f"Failed to parse {file_path}. Ensure it is a valid TOML file."
5051
except Exception as e:
5152
return f"An unexpected error occurred: {e}"

poetry.lock

Lines changed: 516 additions & 528 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ dependencies = [
3232
"jsonschema>=3.0.0, <4.0.0",
3333
"pyld>=2.0.3, <3.0.0",
3434
"cffconvert>=2.0.0, <3.0.0",
35-
"toml>=0.10.2, <1.0.0",
35+
"setuptools<82",
3636
"pyparsing>=3.0.9, <4.0.0",
3737
"requests>=2.28.1, <3.0.0",
3838
"pydantic>=2.5.1, <3.0.0",

src/hermes/commands/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
from importlib import metadata
1212
from typing import Type, Union
1313

14-
import toml
1514
from pydantic import BaseModel
1615
from pydantic_settings import BaseSettings, SettingsConfigDict
16+
import tomlkit
1717

1818

1919
class HermesSettings(BaseSettings):
@@ -131,7 +131,7 @@ def init_command_parser(self, command_parser: argparse.ArgumentParser) -> None:
131131
def load_settings(self, args: argparse.Namespace):
132132
"""Load settings from the configuration file (passed in from command line)."""
133133

134-
toml_data = toml.load(args.path / args.config)
134+
toml_data = tomlkit.load((args.path / args.config).open()).unwrap()
135135
self.root_settings = HermesCommand.settings_class.model_validate(toml_data)
136136
self.settings = getattr(self.root_settings, self.command_name)
137137

src/hermes/commands/init/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
from urllib.parse import urljoin, urlparse
1717

1818
import requests
19-
import toml
2019
from pydantic import BaseModel
2120
from requests import HTTPError
21+
import tomlkit
2222

2323
import hermes.commands.init.util.slim_click as sc
2424
from hermes.commands import marketplace
@@ -359,7 +359,7 @@ def create_hermes_toml(self) -> None:
359359
or sc.confirm("Do you want to replace your `hermes.toml` with a new one?", default=True):
360360
with open(hermes_toml_path, 'w') as toml_file:
361361
# noinspection PyTypeChecker
362-
toml.dump(self.hermes_toml_data, toml_file)
362+
tomlkit.dump(self.hermes_toml_data, toml_file)
363363
sc.echo("`hermes.toml` was created.", formatting=sc.Formats.OKGREEN)
364364

365365
def create_citation_cff(self) -> None:

test/hermes_test/commands/postprocess/test_invenio_postprocess.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import sys
99

1010
from ruamel import yaml
11-
import toml
11+
import tomlkit
1212

1313
from hermes.commands import cli
1414
from hermes.model import context_manager
@@ -72,12 +72,12 @@ def test_invenio_postprocess(tmp_path, monkeypatch):
7272
if e.code != 0:
7373
raise e
7474
finally:
75-
result_toml = toml.load(config_file)
75+
result_toml = tomlkit.load(config_file.open('r')).unwrap()
7676
result_cff = yaml.YAML().load(citation_file)
7777
result_codemeta = json.loads(codemeta_file.read_text())
7878
sys.argv = orig_argv
7979

80-
assert result_toml == toml.loads(
80+
assert result_toml == tomlkit.loads(
8181
"""# SPDX-FileCopyrightText: 2023 German Aerospace Center (DLR)
8282
#
8383
# SPDX-License-Identifier: CC0-1.0
@@ -103,7 +103,7 @@ def test_invenio_postprocess(tmp_path, monkeypatch):
103103
[postprocess]
104104
run = ["config_invenio_record_id", "cff_doi", "codemeta_doi"]
105105
"""
106-
)
106+
).unwrap()
107107
assert result_cff == yaml.YAML().load(
108108
"""cff-version: 1.2.0
109109
title: Test

test/hermes_test/test_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
#
44
# SPDX-License-Identifier: Apache-2.0
55

6-
import toml
76
from pathlib import Path
87

9-
pyproject = toml.load(Path(__file__).parent.parent.parent / "pyproject.toml")
8+
import tomlkit
9+
10+
pyproject = tomlkit.load((Path(__file__).parent.parent.parent / "pyproject.toml").open('r')).unwrap()
1011
expected_name = pyproject["project"]["name"]
1112
expected_version = pyproject["project"]["version"]
1213
expected_homepage = pyproject["project"]["urls"]["homepage"]

0 commit comments

Comments
 (0)