From f6858316bb7979310f13c644af5e6789d1f22405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Sat, 7 Sep 2024 08:34:38 -0700 Subject: [PATCH] Add 3.13 to CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bernát Gábor --- .github/workflows/check.yml | 10 +++++---- .github/workflows/release.yml | 4 ++-- .pre-commit-config.yaml | 4 ++-- pyproject.toml | 24 ++++++++++----------- src/tox/config/loader/convert.py | 31 ++++++++++++++-------------- src/tox/config/loader/str_convert.py | 3 ++- tox.ini | 23 +++++++++++---------- 7 files changed, 52 insertions(+), 47 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 4505e1076..843a1165e 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -20,6 +20,7 @@ jobs: fail-fast: false matrix: py: + - "3.13" - "3.12" - "3.11" - "3.10" @@ -43,6 +44,7 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.py }} + allow-prereleases: true - name: Pick environment to run run: | import os; import platform; import sys; from pathlib import Path @@ -52,7 +54,7 @@ jobs: file_handler.write(env) shell: python - name: Setup test suite - run: tox r -vv --notest + run: tox r -vv --notest --skip-missing-interpreters false - name: Run test suite run: tox r --skip-pkg-install env: @@ -87,7 +89,7 @@ jobs: python-version: "3.12" - name: Install self-tox run: python -m pip install . + - name: Setup check suite + run: tox r -vv --notest --skip-missing-interpreters false -e ${{ matrix.tox_env }} - name: Run check for ${{ matrix.tox_env }} - run: tox r -e ${{ matrix.tox_env }} - env: - UPGRADE_ADVISORY: "yes" + run: tox r --skip-pkg-install -e ${{ matrix.tox_env }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 02985e976..5d49f3084 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,12 +15,12 @@ jobs: with: python-version: "3.12" - name: Install build - run: python -m pip install build + run: python -m pip install build[uv] - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Build package - run: pyproject-build + run: pyproject-build --installer uv - name: Store the distribution packages uses: actions/upload-artifact@v4 with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ab38d2b7b..cfdd62078 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: - id: codespell additional_dependencies: ["tomli>=2.0.1"] - repo: https://github.com/tox-dev/tox-ini-fmt - rev: "1.3.1" + rev: "1.3.2" hooks: - id: tox-ini-fmt args: ["-p", "fix"] @@ -24,7 +24,7 @@ repos: hooks: - id: pyproject-fmt - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.6.3" + rev: "v0.6.4" hooks: - id: ruff-format - id: ruff diff --git a/pyproject.toml b/pyproject.toml index 8fe6f1748..d0643293c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ dynamic = [ "version", ] dependencies = [ - "cachetools>=5.4", + "cachetools>=5.5", "chardet>=5.2", "colorama>=0.4.6", "filelock>=3.15.4", @@ -62,17 +62,17 @@ dependencies = [ "virtualenv>=20.26.3", ] optional-dependencies.docs = [ - "furo>=2024.7.18", - "sphinx>=7.4.7", - "sphinx-argparse-cli>=1.16", - "sphinx-autodoc-typehints>=2.2.3", + "furo>=2024.8.6", + "sphinx>=8.0.2", + "sphinx-argparse-cli>=1.17", + "sphinx-autodoc-typehints>=2.4", "sphinx-copybutton>=0.5.2", "sphinx-inline-tabs>=2023.4.21", "sphinxcontrib-towncrier>=0.2.1a0", - "towncrier>=23.11", + "towncrier>=24.8", ] optional-dependencies.testing = [ - "build[virtualenv]>=1.2.1", + "build[virtualenv]>=1.2.2", "covdefaults>=2.3", "detect-test-pollution>=1.2", "devpi-process>=1", @@ -87,9 +87,9 @@ optional-dependencies.testing = [ "pytest-mock>=3.14", "pytest-xdist>=3.6.1", "re-assert>=1.1", - "setuptools>=70.3", - "time-machine>=2.14.2; implementation_name!='pypy'", - "wheel>=0.43", + "setuptools>=74.1.2", + "time-machine>=2.15; implementation_name!='pypy'", + "wheel>=0.44", ] urls.Documentation = "https://tox.wiki" urls.Homepage = "http://tox.readthedocs.org" @@ -141,10 +141,10 @@ lint.ignore = [ ] lint.per-file-ignores."tests/**/*.py" = [ "D", # don't care about documentation in tests - "FBT", # don"t care about booleans as positional arguments in tests + "FBT", # don't care about booleans as positional arguments in tests "INP001", # no implicit namespace "PLR2004", # Magic value used in comparison, consider replacing with a constant variable - "S101", # asserts allowed in tests... + "S101", # asserts allowed in tests "S603", # `subprocess` call: check for execution of untrusted input ] lint.isort = { known-first-party = [ diff --git a/src/tox/config/loader/convert.py b/src/tox/config/loader/convert.py index 9379c6eac..a91dbc0c2 100644 --- a/src/tox/config/loader/convert.py +++ b/src/tox/config/loader/convert.py @@ -3,6 +3,7 @@ import typing from abc import ABC, abstractmethod from collections import OrderedDict +from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Generic, Iterator, List, Literal, Optional, Set, TypeVar, Union, cast @@ -18,7 +19,7 @@ class Convert(ABC, Generic[T]): """A class that converts a raw type to a given tox (python) type.""" - def to(self, raw: T, of_type: type[V], factory: Factory[V]) -> V: # noqa: PLR0911 + def to(self, raw: T, of_type: type[V], factory: Factory[V]) -> V: # noqa: PLR0911, C901 """ Convert given raw type to python type. @@ -30,26 +31,26 @@ def to(self, raw: T, of_type: type[V], factory: Factory[V]) -> V: # noqa: PLR09 from_module = getattr(of_type, "__module__", None) if from_module in {"typing", "typing_extensions"}: return self._to_typing(raw, of_type, factory) - if issubclass(of_type, Path): - return self.to_path(raw) # type: ignore[return-value] - if issubclass(of_type, bool): - return self.to_bool(raw) # type: ignore[return-value] - if issubclass(of_type, Command): - return self.to_command(raw) # type: ignore[return-value] - if issubclass(of_type, EnvList): - return self.to_env_list(raw) # type: ignore[return-value] - if issubclass(of_type, str): - return self.to_str(raw) # type: ignore[return-value] - # python does not allow use of parametrized generics with isinstance, - # so we need to check for them. + if isclass(of_type): + if issubclass(of_type, Path): + return self.to_path(raw) # type: ignore[return-value] + if issubclass(of_type, bool): + return self.to_bool(raw) # type: ignore[return-value] + if issubclass(of_type, Command): + return self.to_command(raw) # type: ignore[return-value] + if issubclass(of_type, EnvList): + return self.to_env_list(raw) # type: ignore[return-value] + if issubclass(of_type, str): + return self.to_str(raw) # type: ignore[return-value] + # python does not allow use of parametrized generics with isinstance, so we need to check for them. if hasattr(typing, "GenericAlias") and isinstance(of_type, typing.GenericAlias): return list(self.to_list(raw, of_type=of_type)) # type: ignore[return-value] if isinstance(raw, of_type): # already target type no need to transform it # do it this late to allow normalization - e.g. string strip - return raw + return raw # type: ignore[no-any-return] if factory: return factory(raw) - return of_type(raw) # type: ignore[call-arg] + return of_type(raw) # type: ignore[no-any-return] def _to_typing(self, raw: T, of_type: type[V], factory: Factory[V]) -> V: # noqa: C901 origin = getattr(of_type, "__origin__", of_type.__class__) diff --git a/src/tox/config/loader/str_convert.py b/src/tox/config/loader/str_convert.py index 63fc41ded..762c05ec8 100644 --- a/src/tox/config/loader/str_convert.py +++ b/src/tox/config/loader/str_convert.py @@ -4,6 +4,7 @@ import shlex import sys +from inspect import isclass from itertools import chain from pathlib import Path from typing import TYPE_CHECKING, Any, Iterator @@ -28,7 +29,7 @@ def to_path(value: str) -> Path: @staticmethod def to_list(value: str, of_type: type[Any]) -> Iterator[str]: - splitter = "\n" if issubclass(of_type, Command) or "\n" in value else "," + splitter = "\n" if (isclass(of_type) and issubclass(of_type, Command)) or "\n" in value else "," splitter = splitter.replace("\r", "") for token in value.split(splitter): value = token.strip() diff --git a/tox.ini b/tox.ini index dc96c5af9..b00a0ef66 100644 --- a/tox.ini +++ b/tox.ini @@ -3,14 +3,15 @@ requires = tox>=4.2 env_list = fix - py312 - py311 - py310 - py39 - py38 cov type docs + 3.13 + 3.12 + 3.11 + 3.10 + 3.9 + 3.8 pkg_meta skip_missing_interpreters = true @@ -40,7 +41,7 @@ commands = description = format the code base to adhere to our styles, and complain about what we cannot do automatically skip_install = true deps = - pre-commit>=3.8 + pre-commit-uv>=4.1 pass_env = {[testenv]passenv} PROGRAMDATA @@ -51,8 +52,8 @@ commands = [testenv:type] description = run type check on code base deps = - mypy==1.11 - types-cachetools>=5.4.0.20240717 + mypy==1.11.2 + types-cachetools>=5.5.0.20240820 types-chardet>=5.0.4.6 commands = mypy src/tox @@ -71,11 +72,11 @@ commands = description = check that the long description is valid skip_install = true deps = - build[virtualenv]>=1.2.1 + build[uv]>=1.2.2 check-wheel-contents>=0.6 twine>=5.1.1 commands = - python -m build -o {envtmpdir} -s -w . + python -m build --installer uv -o {envtmpdir} -s -w . twine check {envtmpdir}{/}* check-wheel-contents --no-config {envtmpdir} @@ -85,7 +86,7 @@ skip_install = true deps = gitpython>=3.1.43 packaging>=24.1 - towncrier>=23.11 + towncrier>=24.8 commands = python {toxinidir}/tasks/release.py --version {posargs}