From 4bc0a1e641025ec3bfa7456e7015ba2675b31c2c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 16:54:19 +0000 Subject: [PATCH 1/3] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.9.4 → v0.9.6](https://github.com/astral-sh/ruff-pre-commit/compare/v0.9.4...v0.9.6) - [github.com/rbubley/mirrors-prettier: v3.4.2 → v3.5.0](https://github.com/rbubley/mirrors-prettier/compare/v3.4.2...v3.5.0) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3fd20ee01..893845b83 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,7 +23,7 @@ repos: hooks: - id: validate-pyproject - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.9.4" + rev: "v0.9.6" hooks: - id: ruff-format - id: ruff @@ -38,7 +38,7 @@ repos: hooks: - id: rst-backticks - repo: https://github.com/rbubley/mirrors-prettier - rev: "v3.4.2" + rev: "v3.5.0" hooks: - id: prettier - repo: local From 47faa489adbfaab7d65fc75116aa1b2c60e48254 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 16:55:04 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/tox/config/cli/parser.py | 7 ++++--- src/tox/config/types.py | 2 +- src/tox/util/spinner.py | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/tox/config/cli/parser.py b/src/tox/config/cli/parser.py index 87d441c3c..60f97e975 100644 --- a/src/tox/config/cli/parser.py +++ b/src/tox/config/cli/parser.py @@ -1,4 +1,4 @@ -"""Customize argparse logic for tox (also contains the base options).""" # noqa: A005 +"""Customize argparse logic for tox (also contains the base options).""" from __future__ import annotations @@ -12,6 +12,7 @@ from typing import TYPE_CHECKING, Any, Callable, Dict, List, Literal, Optional, Sequence, Tuple, Type, TypeVar, cast from colorama import Fore +from typing_extensions import Self from tox.config.loader.str_convert import StrConvert from tox.plugin import NAME @@ -287,11 +288,11 @@ def add_argument(self, *args: str, of_type: type[Any] | None = None, **kwargs: A return result @classmethod - def base(cls: type[ToxParserT]) -> ToxParserT: + def base(cls) -> Self: return cls(add_help=False, root=True) @classmethod - def core(cls: type[ToxParserT]) -> ToxParserT: + def core(cls) -> Self: return cls( prog=NAME, formatter_class=HelpFormatter, diff --git a/src/tox/config/types.py b/src/tox/config/types.py index 571372596..8d1300aa4 100644 --- a/src/tox/config/types.py +++ b/src/tox/config/types.py @@ -1,4 +1,4 @@ -from __future__ import annotations # noqa: A005 +from __future__ import annotations from collections import OrderedDict from typing import Iterator, Sequence diff --git a/src/tox/util/spinner.py b/src/tox/util/spinner.py index e82acaa13..61d631e35 100644 --- a/src/tox/util/spinner.py +++ b/src/tox/util/spinner.py @@ -11,6 +11,7 @@ from typing import IO, TYPE_CHECKING, NamedTuple, Sequence, TypeVar from colorama import Fore +from typing_extensions import Self if TYPE_CHECKING: from types import TracebackType @@ -104,7 +105,7 @@ def frame(self) -> str: text_frame = textwrap.shorten(text_frame, width=self.max_width - 1, placeholder="...") return f"{frame} {text_frame}" - def __enter__(self: T) -> T: + def __enter__(self) -> Self: if self.enabled: self.disable_cursor() self.render_frame() From d41ea10fd3517a25b430b8877fc8fb91ed3cb52a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Mon, 10 Feb 2025 11:02:22 -0800 Subject: [PATCH 3/3] Fix CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bernát Gábor --- .pre-commit-config.yaml | 4 +-- pyproject.toml | 36 +++++++++++++------------- src/tox/config/cli/parser.py | 6 ++++- src/tox/report.py | 2 +- src/tox/tox_env/python/pip/req/args.py | 11 ++++++-- src/tox/util/spinner.py | 6 ++++- tox.toml | 2 +- 7 files changed, 41 insertions(+), 26 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 893845b83..aa38c2a0b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: rev: v2.4.1 hooks: - id: codespell - additional_dependencies: ["tomli>=2.1"] + additional_dependencies: ["tomli>=2.2.1"] - repo: https://github.com/tox-dev/pyproject-fmt rev: "v2.5.0" hooks: @@ -32,7 +32,7 @@ repos: rev: 1.19.1 hooks: - id: blacken-docs - additional_dependencies: [black==24.10] + additional_dependencies: [black==25.1] - repo: https://github.com/pre-commit/pygrep-hooks rev: v1.10.0 hooks: diff --git a/pyproject.toml b/pyproject.toml index 16f2e44e9..9c1116c23 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ build-backend = "hatchling.build" requires = [ "hatch-vcs>=0.4", - "hatchling>=1.26.3", + "hatchling>=1.27", ] [project] @@ -50,7 +50,7 @@ dynamic = [ "version", ] dependencies = [ - "cachetools>=5.5", + "cachetools>=5.5.1", "chardet>=5.2", "colorama>=0.4.6", "filelock>=3.16.1", @@ -58,13 +58,13 @@ dependencies = [ "platformdirs>=4.3.6", "pluggy>=1.5", "pyproject-api>=1.8", - "tomli>=2.1; python_version<'3.11'", + "tomli>=2.2.1; python_version<'3.11'", "typing-extensions>=4.12.2; python_version<'3.11'", - "virtualenv>=20.27.1", + "virtualenv>=20.29.1", ] optional-dependencies.test = [ "devpi-process>=1.0.2", - "pytest>=8.3.3", + "pytest>=8.3.4", "pytest-mock>=3.14", ] urls.Documentation = "https://tox.wiki" @@ -89,20 +89,20 @@ test = [ "distlib>=0.3.9", "flaky>=3.8.1", "hatch-vcs>=0.4", - "hatchling>=1.26.3", - "psutil>=6.1", - "pytest>=8.3.3", + "hatchling>=1.27", + "psutil>=6.1.1", + "pytest>=8.3.4", "pytest-cov>=5", "pytest-mock>=3.14", "pytest-xdist>=3.6.1", "re-assert>=1.1", - "setuptools>=75.1; python_version<='3.8'", - "setuptools>=75.6; python_version>'3.8'", + "setuptools>=75.3; python_version<='3.8'", + "setuptools>=75.8; python_version>'3.8'", "time-machine>=2.15; implementation_name!='pypy'", - "wheel>=0.45", + "wheel>=0.45.1", ] type = [ - "mypy==1.13", + "mypy==1.15", "types-cachetools>=5.5.0.20240820", "types-chardet>=5.0.4.6", { include-group = "test" }, @@ -110,8 +110,8 @@ type = [ docs = [ "furo>=2024.8.6", "sphinx>=8.1.3", - "sphinx-argparse-cli>=1.18.2", - "sphinx-autodoc-typehints>=2.5", + "sphinx-argparse-cli>=1.19", + "sphinx-autodoc-typehints>=3.0.1", "sphinx-copybutton>=0.5.2", "sphinx-inline-tabs>=2023.4.21", "sphinxcontrib-towncrier>=0.2.1a0", @@ -121,12 +121,12 @@ fix = [ "pre-commit-uv>=4.1.4", ] pkg-meta = [ - "check-wheel-contents>=0.6", - "twine>=5.1.1", - "uv>=0.5.3", + "check-wheel-contents>=0.6.1", + "twine>=6.1", + "uv>=0.5.29", ] release = [ - "gitpython>=3.1.43", + "gitpython>=3.1.44", "packaging>=24.2", "towncrier>=24.8", ] diff --git a/src/tox/config/cli/parser.py b/src/tox/config/cli/parser.py index 60f97e975..87629ae49 100644 --- a/src/tox/config/cli/parser.py +++ b/src/tox/config/cli/parser.py @@ -12,7 +12,6 @@ from typing import TYPE_CHECKING, Any, Callable, Dict, List, Literal, Optional, Sequence, Tuple, Type, TypeVar, cast from colorama import Fore -from typing_extensions import Self from tox.config.loader.str_convert import StrConvert from tox.plugin import NAME @@ -21,6 +20,11 @@ from .env_var import get_env_var from .ini import IniConfig +if sys.version_info >= (3, 11): # pragma: >=3.11 cover + from typing import Self +else: # pragma: <3.11 cover + from typing_extensions import Self + if TYPE_CHECKING: from tox.session.state import State diff --git a/src/tox/report.py b/src/tox/report.py index 07c8e8b64..ef46bc702 100644 --- a/src/tox/report.py +++ b/src/tox/report.py @@ -140,7 +140,7 @@ def stderr(self) -> TextIOWrapper: """:return: the current standard error""" return self._local.out_err[1] - @property # type: ignore[override] + @property def stream(self) -> IO[str]: """:return: the current stream to write to (alias for the current standard output)""" return self.stdout diff --git a/src/tox/tox_env/python/pip/req/args.py b/src/tox/tox_env/python/pip/req/args.py index c5af7299d..e2c5b4aae 100644 --- a/src/tox/tox_env/python/pip/req/args.py +++ b/src/tox/tox_env/python/pip/req/args.py @@ -3,13 +3,20 @@ import bisect import re from argparse import Action, ArgumentParser, ArgumentTypeError, Namespace -from typing import IO, Any, NoReturn, Sequence +from typing import Any, NoReturn, Protocol, Sequence, TypeVar from tox.tox_env.python.pip.req.util import handle_binary_option +_T_contra = TypeVar("_T_contra", contravariant=True) + + +# stable +class _SupportsWrite(Protocol[_T_contra]): + def write(self, s: _T_contra, /) -> object: ... + class _OurArgumentParser(ArgumentParser): - def print_usage(self, file: IO[str] | None = None) -> None: + def print_usage(self, file: _SupportsWrite[str] | None = None) -> None: """ """ def exit(self, status: int = 0, message: str | None = None) -> NoReturn: # noqa: ARG002, PLR6301 diff --git a/src/tox/util/spinner.py b/src/tox/util/spinner.py index 61d631e35..a6d2b905b 100644 --- a/src/tox/util/spinner.py +++ b/src/tox/util/spinner.py @@ -11,7 +11,11 @@ from typing import IO, TYPE_CHECKING, NamedTuple, Sequence, TypeVar from colorama import Fore -from typing_extensions import Self + +if sys.version_info >= (3, 11): # pragma: >=3.11 cover + from typing import Self +else: # pragma: <3.11 cover + from typing_extensions import Self if TYPE_CHECKING: from types import TracebackType diff --git a/tox.toml b/tox.toml index 227381280..8889cb5a7 100644 --- a/tox.toml +++ b/tox.toml @@ -1,4 +1,4 @@ -requires = ["tox>=4.23.2"] +requires = ["tox>=4.24.1"] env_list = ["fix", "3.13", "3.12", "3.11", "3.10", "3.9", "3.8", "cov", "type", "docs", "pkg_meta"] skip_missing_interpreters = true