diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3fd20ee012..aa38c2a0b8 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: @@ -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 @@ -32,13 +32,13 @@ 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: - id: rst-backticks - repo: https://github.com/rbubley/mirrors-prettier - rev: "v3.4.2" + rev: "v3.5.0" hooks: - id: prettier - repo: local diff --git a/pyproject.toml b/pyproject.toml index 16f2e44e9b..9c1116c232 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 87d441c3c8..87629ae49a 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 @@ -20,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 @@ -287,11 +292,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 5713725962..8d1300aa42 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/report.py b/src/tox/report.py index 07c8e8b648..ef46bc702f 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 c5af7299d2..e2c5b4aaeb 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 e82acaa13d..a6d2b905b9 100644 --- a/src/tox/util/spinner.py +++ b/src/tox/util/spinner.py @@ -12,6 +12,11 @@ from colorama import Fore +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 from typing import Any, ClassVar @@ -104,7 +109,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() diff --git a/tox.toml b/tox.toml index 2273812801..8889cb5a7f 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