From d7ce800013c18ebc42b2bd8f821c3656da84232d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 26 Jun 2023 18:25:52 -0700 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#3051) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bernát Gábor --- .pre-commit-config.yaml | 6 +++--- docs/index.rst | 2 +- docs/tox_conf.py | 6 ++++-- pyproject.toml | 10 +++++----- src/tox/config/cli/ini.py | 4 ++-- src/tox/config/loader/ini/replace.py | 3 +-- src/tox/config/loader/section.py | 2 +- src/tox/config/loader/str_convert.py | 9 ++++++--- src/tox/config/of_type.py | 2 +- src/tox/config/sets.py | 2 +- src/tox/plugin/inline.py | 3 +-- src/tox/report.py | 4 ++-- src/tox/run.py | 3 +-- src/tox/session/env_select.py | 2 +- src/tox/tox_env/python/pip/req/file.py | 6 ++---- src/tox/tox_env/python/pip/req/util.py | 3 +-- src/tox/tox_env/python/pip/req_file.py | 6 +++--- src/tox/util/spinner.py | 7 ++++--- tests/util/test_ci.py | 4 ++-- tox.ini | 2 +- 20 files changed, 43 insertions(+), 43 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index da45b1506..e8a033ba2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,10 +14,10 @@ repos: - id: tox-ini-fmt args: ["-p", "fix"] - repo: https://github.com/tox-dev/pyproject-fmt - rev: "0.12.0" + rev: "0.12.1" hooks: - id: pyproject-fmt - additional_dependencies: ["tox>=4.6.1"] + additional_dependencies: ["tox>=4.6.3"] - repo: https://github.com/pre-commit/mirrors-prettier rev: "v3.0.0-alpha.9-for-vscode" hooks: @@ -29,7 +29,7 @@ repos: - id: blacken-docs additional_dependencies: [black==23.3] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.0.272" + rev: "v0.0.275" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/docs/index.rst b/docs/index.rst index f1fad2e1c..02f146f45 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -22,7 +22,7 @@ and `devpi `_). :target: https://pypistats.org/packages/tox :alt: PyPI - Downloads .. image:: https://img.shields.io/pypi/l/tox?style=flat-square - :target: https://opensource.org/licenses/MIT + :target: https://opensource.org/license/mit/ :alt: PyPI - License .. image:: https://img.shields.io/github/issues/tox-dev/tox?style=flat-square :target: https://github.com/tox-dev/tox/issues diff --git a/docs/tox_conf.py b/docs/tox_conf.py index 6fe593f71..341c002b8 100644 --- a/docs/tox_conf.py +++ b/docs/tox_conf.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, cast +from typing import TYPE_CHECKING, Any, ClassVar, cast from docutils.nodes import Element, Node, Text, container, fully_normalize_name, literal, paragraph, reference, strong from docutils.parsers.rst.directives import flag, unchanged, unchanged_required @@ -11,6 +11,8 @@ from sphinx.util.logging import getLogger if TYPE_CHECKING: + from typing import Final + from docutils.parsers.rst.states import RSTState, RSTStateMachine LOGGER = getLogger(__name__) @@ -19,7 +21,7 @@ class ToxConfig(SphinxDirective): name = "conf" has_content = True - option_spec = { + option_spec: Final[ClassVar[dict[str, Any]]] = { "keys": unchanged_required, "version_added": unchanged, "version_changed": unchanged, diff --git a/pyproject.toml b/pyproject.toml index 427a0137d..5da0dcf15 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,10 +52,10 @@ dependencies = [ "chardet>=5.1", "colorama>=0.4.6", "filelock>=3.12.2", - 'importlib-metadata>=6.6; python_version < "3.8"', + 'importlib-metadata>=6.7; python_version < "3.8"', "packaging>=23.1", - "platformdirs>=3.5.3", - "pluggy>=1", + "platformdirs>=3.8", + "pluggy>=1.2", "pyproject-api>=1.5.2", 'tomli>=2.0.1; python_version < "3.11"', 'typing-extensions>=4.6.3; python_version < "3.8"', @@ -65,7 +65,7 @@ optional-dependencies.docs = [ "furo>=2023.5.20", "sphinx>=7.0.1", "sphinx-argparse-cli>=1.11.1", - "sphinx-autodoc-typehints!=1.23.4,>=1.23.2", + "sphinx-autodoc-typehints!=1.23.4,>=1.23.3", "sphinx-copybutton>=0.5.2", "sphinx-inline-tabs>=2023.4.21", "sphinxcontrib-towncrier>=0.2.1a0", @@ -82,7 +82,7 @@ optional-dependencies.testing = [ "hatch-vcs>=0.3", "hatchling>=1.17.1", "psutil>=5.9.5", - "pytest>=7.3.2", + "pytest>=7.4", "pytest-cov>=4.1", "pytest-mock>=3.11.1", "pytest-xdist>=3.3.1", diff --git a/src/tox/config/cli/ini.py b/src/tox/config/cli/ini.py index e0cd71791..adcee2cb7 100644 --- a/src/tox/config/cli/ini.py +++ b/src/tox/config/cli/ini.py @@ -5,7 +5,7 @@ import os from configparser import ConfigParser from pathlib import Path -from typing import Any +from typing import Any, ClassVar from platformdirs import user_config_dir @@ -18,7 +18,7 @@ class IniConfig: TOX_CONFIG_FILE_ENV_VAR = "TOX_USER_CONFIG_FILE" - STATE = {None: "failed to parse", True: "active", False: "missing"} + STATE: ClassVar[dict[bool | None, str]] = {None: "failed to parse", True: "active", False: "missing"} def __init__(self) -> None: config_file = os.environ.get(self.TOX_CONFIG_FILE_ENV_VAR, None) diff --git a/src/tox/config/loader/ini/replace.py b/src/tox/config/loader/ini/replace.py index cd7ad43b3..9d9373989 100644 --- a/src/tox/config/loader/ini/replace.py +++ b/src/tox/config/loader/ini/replace.py @@ -259,8 +259,7 @@ def replace_reference( # noqa: PLR0912, C901 exception = exc else: as_str, _ = stringify(value) - as_str = as_str.replace("#", r"\#") # escape comment characters as these will be stripped - return as_str + return as_str.replace("#", r"\#") # escape comment characters as these will be stripped except Exception as exc: # noqa: BLE001 exception = exc if exception is not None: diff --git a/src/tox/config/loader/section.py b/src/tox/config/loader/section.py index bfbf3e4b7..d31665168 100644 --- a/src/tox/config/loader/section.py +++ b/src/tox/config/loader/section.py @@ -52,7 +52,7 @@ def __repr__(self) -> str: def __eq__(self, other: Any) -> bool: return isinstance(other, self.__class__) and (self._prefix, self._name) == ( - other._prefix, # noqa: SLF001 + other._prefix, other.name, ) diff --git a/src/tox/config/loader/str_convert.py b/src/tox/config/loader/str_convert.py index 919f064a2..ddcdb5a54 100644 --- a/src/tox/config/loader/str_convert.py +++ b/src/tox/config/loader/str_convert.py @@ -5,11 +5,14 @@ import sys from itertools import chain from pathlib import Path -from typing import Any, Iterator +from typing import TYPE_CHECKING, Any, Iterator from tox.config.loader.convert import Convert from tox.config.types import Command, EnvList +if TYPE_CHECKING: + from typing import Final + class StrConvert(Convert[str]): """A class converting string values to tox types.""" @@ -111,8 +114,8 @@ def to_env_list(value: str) -> EnvList: elements = list(chain.from_iterable(extend_factors(expr) for expr in value.split("\n"))) return EnvList(elements) - TRUTHFUL_VALUES = {"true", "1", "yes", "on"} - FALSE_VALUES = {"false", "0", "no", "off", ""} + TRUTHFUL_VALUES: Final[set[str]] = {"true", "1", "yes", "on"} + FALSE_VALUES: Final[set[str]] = {"false", "0", "no", "off", ""} VALID_BOOL = sorted(TRUTHFUL_VALUES | FALSE_VALUES) @staticmethod diff --git a/src/tox/config/of_type.py b/src/tox/config/of_type.py index d3a951b7c..6c01a1231 100644 --- a/src/tox/config/of_type.py +++ b/src/tox/config/of_type.py @@ -71,7 +71,7 @@ def __init__( # noqa: PLR0913 of_type: type[T], default: Callable[[Config, str | None], T] | T, post_process: Callable[[T], T] | None = None, - factory: Factory[T] = None, + factory: Factory[T] | None = None, ) -> None: super().__init__(keys, desc) self.of_type = of_type diff --git a/src/tox/config/sets.py b/src/tox/config/sets.py index 098901c43..68e9d0fa6 100644 --- a/src/tox/config/sets.py +++ b/src/tox/config/sets.py @@ -47,7 +47,7 @@ def add_config( # noqa: PLR0913 default: Callable[[Config, str | None], V] | V, desc: str, post_process: Callable[[V], V] | None = None, - factory: Factory[Any] = None, + factory: Factory[Any] | None = None, ) -> ConfigDynamicDefinition[V]: """ Add configuration value. diff --git a/src/tox/plugin/inline.py b/src/tox/plugin/inline.py index cf4511f51..12a1b5174 100644 --- a/src/tox/plugin/inline.py +++ b/src/tox/plugin/inline.py @@ -27,7 +27,6 @@ def _load_plugin(path: Path) -> ModuleType: try: if module_name in sys.modules: del sys.modules[module_name] # pragma: no cover - module = importlib.import_module(module_name) - return module + return importlib.import_module(module_name) finally: del sys.path[0] diff --git a/src/tox/report.py b/src/tox/report.py index 029e1e4e4..35f67887d 100644 --- a/src/tox/report.py +++ b/src/tox/report.py @@ -8,7 +8,7 @@ from io import BytesIO, TextIOWrapper from pathlib import Path from threading import Thread, current_thread, enumerate, local -from typing import IO, Iterator, Tuple +from typing import IO, ClassVar, Iterator, Tuple from colorama import Fore, Style, init @@ -29,7 +29,7 @@ class _LogThreadLocal(local): """A thread local variable that inherits values from its parent.""" - _ident_to_data: dict[int | None, str] = {} + _ident_to_data: ClassVar[dict[int | None, str]] = {} def __init__(self, out_err: OutErr) -> None: self.name = self._ident_to_data.get(getattr(current_thread(), "parent_ident", None), "ROOT") diff --git a/src/tox/run.py b/src/tox/run.py index 5d94d458f..fa420006b 100644 --- a/src/tox/run.py +++ b/src/tox/run.py @@ -42,8 +42,7 @@ def main(args: Sequence[str]) -> int: if result is not False: return result handler = state._options.cmd_handlers[state.conf.options.command] # noqa: SLF001 - result = handler(state) - return result + return handler(state) def setup_state(args: Sequence[str]) -> State: diff --git a/src/tox/session/env_select.py b/src/tox/session/env_select.py index 23de3a711..127606b04 100644 --- a/src/tox/session/env_select.py +++ b/src/tox/session/env_select.py @@ -47,7 +47,7 @@ def __repr__(self) -> str: return f"{self.__class__.__name__}({'' if self.is_default_list else repr(str(self))})" def __eq__(self, other: Any) -> bool: - return type(self) == type(other) and self._names == other._names # noqa: SLF001 + return type(self) == type(other) and self._names == other._names def __ne__(self, other: Any) -> bool: return not (self == other) diff --git a/src/tox/tox_env/python/pip/req/file.py b/src/tox/tox_env/python/pip/req/file.py index 09dccac2d..e307729fb 100644 --- a/src/tox/tox_env/python/pip/req/file.py +++ b/src/tox/tox_env/python/pip/req/file.py @@ -246,8 +246,7 @@ def _get_file_content(self, url: str) -> str: scheme = get_url_scheme(url) if scheme in ["http", "https"]: with urlopen(url) as response: # noqa: S310 - text = self._read_decode(response) - return text + return self._read_decode(response) elif scheme == "file": url = url_to_path(url) try: @@ -275,8 +274,7 @@ def _pre_process(self, content: str) -> ReqFileLines: lines_enum: ReqFileLines = enumerate(content.splitlines(), start=1) lines_enum = self._join_lines(lines_enum) lines_enum = self._ignore_comments(lines_enum) - lines_enum = self._expand_env_variables(lines_enum) - return lines_enum + return self._expand_env_variables(lines_enum) def _parse_line(self, line: str) -> tuple[str, Namespace]: args_str, options_str = self._break_args_options(line) diff --git a/src/tox/tox_env/python/pip/req/util.py b/src/tox/tox_env/python/pip/req/util.py index 8e4d38ac5..23cec4029 100644 --- a/src/tox/tox_env/python/pip/req/util.py +++ b/src/tox/tox_env/python/pip/req/util.py @@ -27,8 +27,7 @@ def url_to_path(url: str) -> str: else: msg = f"non-local file URIs are not supported on this platform: {url!r}" raise ValueError(msg) - path = url2pathname(netloc + path) - return path + return url2pathname(netloc + path) def handle_binary_option(value: str, target: set[str], other: set[str]) -> None: diff --git a/src/tox/tox_env/python/pip/req_file.py b/src/tox/tox_env/python/pip/req_file.py index 5bf41fe07..55d9d36e4 100644 --- a/src/tox/tox_env/python/pip/req_file.py +++ b/src/tox/tox_env/python/pip/req_file.py @@ -8,12 +8,13 @@ if TYPE_CHECKING: from argparse import ArgumentParser, Namespace from pathlib import Path + from typing import Final class PythonDeps(RequirementsFile): # these options are valid in requirements.txt, but not via pip cli and # thus cannot be used in the testenv `deps` list - _illegal_options = ["hash"] + _illegal_options: Final[list[str]] = ["hash"] def __init__(self, raw: str, root: Path) -> None: super().__init__(root / "tox.ini", constraint=False) @@ -70,8 +71,7 @@ def _normalize_raw(raw: str) -> str: # for tox<4 supporting requirement/constraint files via -rreq.txt/-creq.txt lines.append(PythonDeps._normalize_line(line)) adjusted = "\n".join(lines) - raw = f"{adjusted}\n" if raw.endswith("\\\n") else adjusted # preserve trailing newline if input has it - return raw + return f"{adjusted}\n" if raw.endswith("\\\n") else adjusted # preserve trailing newline if input has it @staticmethod def _normalize_line(line: str) -> str: diff --git a/src/tox/util/spinner.py b/src/tox/util/spinner.py index c1b9cc94a..fb0cedde3 100644 --- a/src/tox/util/spinner.py +++ b/src/tox/util/spinner.py @@ -13,12 +13,13 @@ if TYPE_CHECKING: from types import TracebackType + from typing import Any, ClassVar if sys.platform == "win32": # pragma: win32 cover import ctypes class _CursorInfo(ctypes.Structure): - _fields_ = [("size", ctypes.c_int), ("visible", ctypes.c_byte)] + _fields_: ClassVar[list[tuple[str, Any]]] = [("size", ctypes.c_int), ("visible", ctypes.c_byte)] def _file_support_encoding(chars: Sequence[str], file: IO[str]) -> bool: @@ -47,8 +48,8 @@ class Outcome(NamedTuple): class Spinner: CLEAR_LINE = "\033[K" max_width = 120 - UNICODE_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] - ASCII_FRAMES = ["|", "-", "+", "x", "*"] + UNICODE_FRAMES: ClassVar[list[str]] = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] + ASCII_FRAMES: ClassVar[list[str]] = ["|", "-", "+", "x", "*"] UNICODE_OUTCOME = Outcome(ok="✔", fail="✖", skip="⚠") ASCII_OUTCOME = Outcome(ok="+", fail="!", skip="?") diff --git a/tests/util/test_ci.py b/tests/util/test_ci.py index 5783e754f..8ef9e89a5 100644 --- a/tests/util/test_ci.py +++ b/tests/util/test_ci.py @@ -22,7 +22,7 @@ "TEAMCITY_VERSION": None, # TeamCity "TRAVIS": "true", # Travis CI }.items(), - ids=lambda v: v[0], # type: ignore[no-any-return] + ids=lambda v: v[0], ) def test_is_ci(env_var: tuple[str, str | None], monkeypatch: pytest.MonkeyPatch) -> None: for var in _ENV_VARS: @@ -41,7 +41,7 @@ def test_is_ci(env_var: tuple[str, str | None], monkeypatch: pytest.MonkeyPatch) "GITHUB_ACTIONS": "", # GitHub Actions "TRAVIS": "", # Travis CI }.items(), - ids=lambda v: v[0], # type: ignore[no-any-return] + ids=lambda v: v[0], ) def test_is_ci_bad_set(env_var: tuple[str, str], monkeypatch: pytest.MonkeyPatch) -> None: for var in _ENV_VARS: diff --git a/tox.ini b/tox.ini index c18af6665..0e28277f2 100644 --- a/tox.ini +++ b/tox.ini @@ -52,7 +52,7 @@ commands = [testenv:type] description = run type check on code base deps = - mypy==1.3 + mypy==1.4.1 types-cachetools>=5.3.0.5 types-chardet>=5.0.4.6 commands =