From 66219edf848ccca7582e9f930c364b22238ad138 Mon Sep 17 00:00:00 2001 From: "Felt, Nicholas" Date: Thu, 15 Aug 2024 12:35:04 -0700 Subject: [PATCH] ci: Use nodeenv to install node during tox runs, and install node with nodeenv during initial contributor setup --- .pre-commit-config.yaml | 2 +- docs/requirements.txt | 5 +++-- pyproject.toml | 10 +++++++--- scripts/contributor_setup.py | 5 +++-- src/tm_devices/components/dm_config_parser.py | 2 +- src/tm_devices/helpers/constants_and_dataclasses.py | 2 +- tests/requirements.txt | 6 +++--- 7 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ba62b30a..b69a20e2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -139,7 +139,7 @@ repos: always_run: true args: [audit, --json, --ignore-code=CVE-2019-8341] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: ac97362543353002a47d6cae8918b25444d102df # frozen: v0.5.7 + rev: 718fbf5fa5fb8cbe6aeac32a863271695104cd5d # frozen: v0.6.0 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/docs/requirements.txt b/docs/requirements.txt index c25ed00c..c1d35fc6 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -32,6 +32,7 @@ mkdocs-spellcheck==1.1.0 ; python_version >= "3.8" and python_version < "4.0" mkdocstrings==0.25.2 ; python_version >= "3.8" and python_version < "4.0" mkdocstrings-python==1.10.5 ; python_version >= "3.8" and python_version < "4.0" mypy-extensions==1.0.0 ; python_version >= "3.8" and python_version < "4.0" +nodeenv==1.9.1 ; python_version >= "3.8" and python_version < "4.0" packaging==24.1 ; python_version >= "3.8" and python_version < "4.0" pathspec==0.12.1 ; python_version >= "3.8" and python_version < "4.0" platformdirs==4.2.2 ; python_version >= "3.8" and python_version < "4.0" @@ -41,9 +42,9 @@ python-dateutil==2.9.0.post0 ; python_version >= "3.8" and python_version < "4.0 pyyaml==6.0.2 ; python_version >= "3.8" and python_version < "4.0" pyyaml-env-tag==0.1 ; python_version >= "3.8" and python_version < "4.0" requests==2.32.3 ; python_version >= "3.8" and python_version < "4.0" -setuptools==72.1.0 ; python_version >= "3.8" and python_version < "4.0" +setuptools==72.2.0 ; python_version >= "3.8" and python_version < "4.0" six==1.16.0 ; python_version >= "3.8" and python_version < "4.0" -soupsieve==2.5 ; python_version >= "3.8" and python_version < "4.0" +soupsieve==2.6 ; python_version >= "3.8" and python_version < "4.0" symspellpy==6.7.7 ; python_version >= "3.8" and python_version < "4.0" termcolor==2.4.0 ; python_version >= "3.8" and python_version < "4.0" tomli==2.0.1 ; python_version >= "3.8" and python_version < "4.0" diff --git a/pyproject.toml b/pyproject.toml index 26dc429e..49582038 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -100,6 +100,7 @@ matplotlib = [ {python = "3.8", version = "^3.7"} ] memory-profiler = "^0.61.0" +nodeenv = "^1.9.1" pip = "^24.0" poetry = "^1.8.0" poetry-audit-plugin = "^0.4.0" @@ -111,10 +112,10 @@ pre-commit = [ ] pyclean = "^3.0.0" pylint = "3.2.6" -pyright = "1.1.375" +pyright = "1.1.376" pyroma = "^4.2" python-semantic-release = "^9.6.0" -ruff = "0.5.7" +ruff = "0.6.0" toml-sort = "^0.23.0" tox = "^4.0" tox-gh-actions = "^3.1.0" @@ -140,6 +141,7 @@ mkdocs-section-index = "^0.3.9" mkdocs-spellcheck = "^1.1.0" mkdocstrings = "^0.25.0" mkdocstrings-python = "^1.10.2" +nodeenv = "^1.9.1" pygments = "^2.17.2" pymdown-extensions = "^10.8.1" symspellpy = "^6.7.7" @@ -158,7 +160,7 @@ pytest-env = "^1.1.3" pytest-github-report = "^0.0.1" pytest-html = "^4.1.1" pytest-order = "^1.2.1" -ruff = "0.5.7" +ruff = "0.6.0" tomli = "^2.0.1" [tool.poetry.scripts] @@ -465,6 +467,7 @@ basepython = {env:DOC_PYTHON_VERSION} deps = -rdocs/requirements.txt commands_pre = + nodeenv --python-virtualenv --clean-src commands = python -c "import shutil; shutil.rmtree('.results_{envname}', ignore_errors=True)" mkdocs --verbose build --site-dir .results_{envname} @@ -475,6 +478,7 @@ deps = -rdocs/requirements.txt -rtests/requirements.txt commands_pre = + nodeenv --python-virtualenv --clean-src commands = pytest -v -k "test_docs" --showlocals --junitxml={tox_root}/.results_{envname}/results.xml --self-contained-html --html={tox_root}/.results_{envname}/results.html """ diff --git a/scripts/contributor_setup.py b/scripts/contributor_setup.py index 6d138806..42d5ddae 100644 --- a/scripts/contributor_setup.py +++ b/scripts/contributor_setup.py @@ -136,8 +136,9 @@ def main() -> None: commands_to_send = ( f"{python_executable} -m pip install -U pip wheel poetry", f"{python_executable} -m poetry install", + f"{python_executable} -m nodeenv --python-virtualenv --clean-src", f"{python_executable} -m pre_commit install", - f"{python_executable} -m tox -vve tests", + f"{python_executable} -m tox -e tests", ) for command in commands_to_send: _run_cmd_in_subprocess(command) @@ -146,7 +147,7 @@ def main() -> None: "Unable to set up the environment. Please run this script from a " "standard Python installation, not a virtual environment." ) - raise SystemExit(msg) # noqa: TRY200,B904 + raise SystemExit(msg) # noqa: B904 finally: os.chdir(starting_dir) diff --git a/src/tm_devices/components/dm_config_parser.py b/src/tm_devices/components/dm_config_parser.py index 07adb8dd..3396ad72 100644 --- a/src/tm_devices/components/dm_config_parser.py +++ b/src/tm_devices/components/dm_config_parser.py @@ -430,7 +430,7 @@ def __parse_config_file( options_list = list(options_mapping) valid_options = set(get_type_hints(DMConfigOptions)) msg = f"Invalid configuration options found: {list(set(options_list) - valid_options)}" - raise KeyError(msg) # noqa: TRY200,B904 + raise KeyError(msg) # noqa: B904 devices_list = data.get("devices", []) return options, devices_list diff --git a/src/tm_devices/helpers/constants_and_dataclasses.py b/src/tm_devices/helpers/constants_and_dataclasses.py index 5c1f6d77..0d1e33d8 100644 --- a/src/tm_devices/helpers/constants_and_dataclasses.py +++ b/src/tm_devices/helpers/constants_and_dataclasses.py @@ -224,7 +224,7 @@ def __post_init__(self) -> None: # noqa: PLR0912, C901 object.__setattr__(self, "connection_type", ConnectionTypes(self.connection_type)) except ValueError as error: # this is from an invalid enum name - raise TypeError(*error.args) # noqa: TRY200,B904 + raise TypeError(*error.args) # noqa: B904 # Validate the GPIB board number if ( diff --git a/tests/requirements.txt b/tests/requirements.txt index e246ae41..4b626a7c 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -38,10 +38,10 @@ pytest-order==1.2.1 ; python_version >= "3.8" and python_version < "4.0" python-dateutil==2.9.0.post0 ; python_version >= "3.8" and python_version < "4.0" pytz==2024.1 ; python_version >= "3.8" and python_version < "4.0" requests==2.32.3 ; python_version >= "3.8" and python_version < "4.0" -ruff==0.5.7 ; python_version >= "3.8" and python_version < "4.0" -setuptools==72.1.0 ; python_version >= "3.8" and python_version < "4.0" +ruff==0.6.0 ; python_version >= "3.8" and python_version < "4.0" +setuptools==72.2.0 ; python_version >= "3.8" and python_version < "4.0" six==1.16.0 ; python_version >= "3.8" and python_version < "4.0" -soupsieve==2.5 ; python_version >= "3.8" and python_version < "4.0" +soupsieve==2.6 ; python_version >= "3.8" and python_version < "4.0" tabledata==1.3.3 ; python_version >= "3.8" and python_version < "4.0" tcolorpy==0.1.6 ; python_version >= "3.8" and python_version < "4.0" tomli==2.0.1 ; python_version >= "3.8" and python_version < "4.0"