From 6d22e49ef0edb44ecfcab13b06e974efaa690db3 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Mon, 14 Oct 2024 10:23:39 +0200 Subject: [PATCH] ENH: remove `toml` dependency (#91) --- .cspell.json | 10 +++++++++- create-pytest-matrix/action.yml | 2 -- create-pytest-matrix/main.py | 7 +++---- create-python-version-matrix/action.yml | 2 -- create-python-version-matrix/main.py | 7 +++---- pyproject.toml | 1 - 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.cspell.json b/.cspell.json index 05285d8..982b85d 100644 --- a/.cspell.json +++ b/.cspell.json @@ -41,7 +41,15 @@ ".vscode/*", "pyproject.toml" ], - "ignoreWords": ["elif", "mhutchie", "noqa", "noreply", "taplo", "tomlkit"], + "ignoreWords": [ + "elif", + "mhutchie", + "noqa", + "noreply", + "taplo", + "tomlkit", + "tomllib" + ], "language": "en-US", "version": "0.2", "words": [] diff --git a/create-pytest-matrix/action.yml b/create-pytest-matrix/action.yml index 874f489..a7243a2 100644 --- a/create-pytest-matrix/action.yml +++ b/create-pytest-matrix/action.yml @@ -35,8 +35,6 @@ runs: - uses: actions/setup-python@v5 with: python-version: "3.12" - - run: pip install toml - shell: bash - id: set-matrix name: Create run matrix in JSON form run: | diff --git a/create-pytest-matrix/main.py b/create-pytest-matrix/main.py index 3d0fa0f..4bcad1e 100644 --- a/create-pytest-matrix/main.py +++ b/create-pytest-matrix/main.py @@ -4,12 +4,11 @@ import json import os +import tomllib from argparse import ArgumentParser from configparser import ConfigParser from typing import TYPE_CHECKING -import toml - if TYPE_CHECKING: from collections.abc import Sequence @@ -130,8 +129,8 @@ def __get_classifiers_from_cfg(path: str) -> list[str]: def __get_classifiers_from_toml(path: str) -> list[str]: - with open(path) as f: - cfg = toml.load(f) + with open(path, "rb") as f: + cfg = tomllib.load(f) classifiers = cfg.get("project", {}).get("classifiers") if classifiers is None: raise ValueError(CLASSIFIERS_ERROR_MSG) diff --git a/create-python-version-matrix/action.yml b/create-python-version-matrix/action.yml index abb5f09..95170d5 100644 --- a/create-python-version-matrix/action.yml +++ b/create-python-version-matrix/action.yml @@ -31,8 +31,6 @@ runs: - uses: actions/setup-python@v5 with: python-version: "3.12" - - run: pip install toml - shell: bash - id: set-matrix name: Create run matrix in JSON form run: | diff --git a/create-python-version-matrix/main.py b/create-python-version-matrix/main.py index 64009e7..ba4bbc0 100644 --- a/create-python-version-matrix/main.py +++ b/create-python-version-matrix/main.py @@ -2,10 +2,9 @@ import json import os +import tomllib from configparser import ConfigParser -import toml - PYPROJECT_TOML = "pyproject.toml" SETUP_CFG = "setup.cfg" @@ -52,8 +51,8 @@ def __get_classifiers_from_cfg(path: str) -> list[str]: def __get_classifiers_from_toml(path: str) -> list[str]: - with open(path) as f: - cfg = toml.load(f) + with open(path, "rb") as f: + cfg = tomllib.load(f) classifiers = cfg.get("project", {}).get("classifiers") if classifiers is None: raise ValueError(CLASSIFIERS_ERROR_MSG) diff --git a/pyproject.toml b/pyproject.toml index 0a58e8a..76fbcec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,6 @@ classifiers = [ "Programming Language :: Python :: 3.12", "Programming Language :: Python", ] -dependencies = ["toml"] description = "Python scripts used by the ComPWA/actions repository" dynamic = ["version"] license = {text = "License :: OSI Approved :: MIT License"}