Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #3091

Merged
merged 2 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ jobs:
fail-fast: false
matrix:
py:
- "3.12.0-beta.2"
- "3.12.0-rc.1"
- "3.11"
- "3.10"
- "3.9"
- "3.8"
- "3.7"
os:
- ubuntu-latest
- windows-latest
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ repos:
- id: tox-ini-fmt
args: ["-p", "fix"]
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "0.13.0"
rev: "0.13.1"
hooks:
- id: pyproject-fmt
additional_dependencies: ["tox>=4.6.4"]
additional_dependencies: ["tox>=4.8"]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.1"
hooks:
Expand All @@ -29,7 +29,7 @@ repos:
- id: blacken-docs
additional_dependencies: [black==23.7]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.0.282"
rev: "v0.0.284"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
27 changes: 13 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
build-backend = "hatchling.build"
requires = [
"hatch-vcs>=0.3",
"hatchling>=1.17.1",
"hatchling>=1.18",
]

[project]
Expand All @@ -24,7 +24,7 @@ maintainers = [
{ name = "Oliver Bestwalter", email = "oliver@bestwalter.de" },
]
authors = [{ name = "Bernát Gábor", email = "gaborjbernat@gmail.com" }]
requires-python = ">=3.7"
requires-python = ">=3.8"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Framework :: tox",
Expand All @@ -34,7 +34,6 @@ classifiers = [
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand All @@ -49,23 +48,23 @@ dynamic = [
]
dependencies = [
"cachetools>=5.3.1",
"chardet>=5.1",
"chardet>=5.2",
"colorama>=0.4.6",
"filelock>=3.12.2",
'importlib-metadata>=6.7; python_version < "3.8"',
'importlib-metadata>=6.8; python_version < "3.8"',
"packaging>=23.1",
"platformdirs>=3.9.1",
"platformdirs>=3.10",
"pluggy>=1.2",
"pyproject-api>=1.5.3",
'tomli>=2.0.1; python_version < "3.11"',
'typing-extensions>=4.7.1; python_version < "3.8"',
"virtualenv>=20.24.1",
"virtualenv>=20.24.3",
]
optional-dependencies.docs = [
"furo>=2023.5.20",
"sphinx>=7.0.1",
"furo>=2023.7.26",
"sphinx>=7.1.2",
"sphinx-argparse-cli>=1.11.1",
"sphinx-autodoc-typehints!=1.23.4,>=1.23.3",
"sphinx-autodoc-typehints!=1.23.4,>=1.24",
"sphinx-copybutton>=0.5.2",
"sphinx-inline-tabs>=2023.4.21",
"sphinxcontrib-towncrier>=0.2.1a0",
Expand All @@ -80,15 +79,15 @@ optional-dependencies.testing = [
"distlib>=0.3.7",
"flaky>=3.7",
"hatch-vcs>=0.3",
"hatchling>=1.17.1",
"hatchling>=1.18",
"psutil>=5.9.5",
"pytest>=7.4",
"pytest-cov>=4.1",
"pytest-mock>=3.11.1",
"pytest-xdist>=3.3.1",
"re-assert>=1.1",
'time-machine>=2.10; implementation_name != "pypy"',
"wheel>=0.40",
'time-machine>=2.12; implementation_name != "pypy"',
"wheel>=0.41.1",
]
urls.Documentation = "https://tox.wiki"
urls.Homepage = "http://tox.readthedocs.org"
Expand All @@ -109,7 +108,7 @@ line-length = 120
[tool.ruff]
select = ["ALL"]
line-length = 120
target-version = "py37"
target-version = "py38"
isort = {known-first-party = ["tox", "tests"], required-imports = ["from __future__ import annotations"]}
ignore = [
"INP001", # no implicit namespaces here
Expand Down
7 changes: 1 addition & 6 deletions src/tox/config/cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,14 @@
import sys
from argparse import SUPPRESS, Action, ArgumentDefaultsHelpFormatter, ArgumentParser, Namespace
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Sequence, Tuple, Type, TypeVar, cast
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Literal, Optional, Sequence, Tuple, Type, TypeVar, cast

from tox.config.loader.str_convert import StrConvert
from tox.plugin import NAME

from .env_var import get_env_var
from .ini import IniConfig

if sys.version_info >= (3, 8): # pragma: no cover (py38+)
from typing import Literal
else: # pragma: no cover (py38+)
from typing_extensions import Literal

if TYPE_CHECKING:
from tox.session.state import State

Expand Down
10 changes: 7 additions & 3 deletions src/tox/config/loader/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@ def __repr__(self) -> str:
def __str__(self) -> str:
return f"{self.namespace}{'.' if self.namespace else ''}{self.key}={self.value}"

def __eq__(self, other: Any) -> bool:
def __eq__(self, other: object) -> bool:
if type(self) != type(other):
return False
return (self.namespace, self.key, self.value) == (other.namespace, other.key, other.value)
return (self.namespace, self.key, self.value) == (
other.namespace, # type: ignore[attr-defined]
other.key, # type: ignore[attr-defined]
other.value, # type: ignore[attr-defined]
)

def __ne__(self, other: Any) -> bool:
def __ne__(self, other: object) -> bool:
return not (self == other)


Expand Down
9 changes: 1 addition & 8 deletions src/tox/config/loader/convert.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
from __future__ import annotations

import sys
from abc import ABC, abstractmethod
from collections import OrderedDict
from pathlib import Path
from typing import Any, Callable, Dict, Generic, Iterator, List, Optional, Set, TypeVar, Union, cast
from typing import Any, Callable, Dict, Generic, Iterator, List, Literal, Optional, Set, TypeVar, Union, cast

from tox.config.types import Command, EnvList

if sys.version_info >= (3, 8): # pragma: no cover (py38+)
from typing import Literal
else: # pragma: no cover (py38+)
from typing_extensions import Literal


_NO_MAPPING = object()
T = TypeVar("T")
V = TypeVar("V")
Expand Down
2 changes: 1 addition & 1 deletion src/tox/config/loader/ini/replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def __init__(self, expr: Sequence[MatchArg], term_pos: int | None = None) -> Non
def __repr__(self) -> str:
return f"MatchExpression(expr={self.expr!r}, term_pos={self.term_pos!r})"

def __eq__(self, other: Any) -> bool:
def __eq__(self, other: object) -> bool:
if isinstance(other, type(self)):
return self.expr == other.expr
return NotImplemented
Expand Down
14 changes: 10 additions & 4 deletions src/tox/config/loader/section.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
from __future__ import annotations

from typing import Any, TypeVar
from typing import TYPE_CHECKING

_Section = TypeVar("_Section", bound="Section")
if TYPE_CHECKING:
import sys

if sys.version_info >= (3, 11): # pragma: no cover (py311+)
from typing import Self
else: # pragma: no cover (<py311)
from typing_extensions import Self


class Section:
Expand All @@ -15,7 +21,7 @@ def __init__(self, prefix: str | None, name: str) -> None:
self._name = name

@classmethod
def from_key(cls: type[_Section], key: str) -> _Section:
def from_key(cls: type[Self], key: str) -> Self:
"""
Create a section from a section key.

Expand Down Expand Up @@ -50,7 +56,7 @@ def __str__(self) -> str:
def __repr__(self) -> str:
return f"{self.__class__.__name__}(prefix={self._prefix!r}, name={self._name!r})"

def __eq__(self, other: Any) -> bool:
def __eq__(self, other: object) -> bool:
return isinstance(other, self.__class__) and (self._prefix, self._name) == (
other._prefix,
other.name,
Expand Down
17 changes: 9 additions & 8 deletions src/tox/config/of_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from abc import ABC, abstractmethod
from itertools import product
from typing import TYPE_CHECKING, Any, Callable, Generic, Iterable, TypeVar, cast
from typing import TYPE_CHECKING, Callable, Generic, Iterable, TypeVar, cast

from tox.config.loader.api import ConfigLoadArgs, Loader

Expand All @@ -27,10 +27,10 @@ def __init__(self, keys: Iterable[str], desc: str) -> None:
def __call__(self, conf: Config, loaders: list[Loader[T]], args: ConfigLoadArgs) -> T:
raise NotImplementedError

def __eq__(self, o: Any) -> bool:
return type(self) == type(o) and (self.keys, self.desc) == (o.keys, o.desc)
def __eq__(self, o: object) -> bool:
return type(self) == type(o) and (self.keys, self.desc) == (o.keys, o.desc) # type: ignore[attr-defined]

def __ne__(self, o: Any) -> bool:
def __ne__(self, o: object) -> bool:
return not (self == o)


Expand All @@ -54,8 +54,8 @@ def __call__(
) -> T:
return self.value() if callable(self.value) else self.value

def __eq__(self, o: Any) -> bool:
return type(self) == type(o) and super().__eq__(o) and self.value == o.value
def __eq__(self, o: object) -> bool:
return type(self) == type(o) and super().__eq__(o) and self.value == o.value # type: ignore[attr-defined]


_PLACE_HOLDER = object()
Expand Down Expand Up @@ -112,11 +112,12 @@ def __repr__(self) -> str:
values = ((k, v) for k, v in vars(self).items() if k != "post_process" and v is not None)
return f"{type(self).__name__}({', '.join(f'{k}={v}' for k, v in values)})"

def __eq__(self, o: Any) -> bool:
def __eq__(self, o: object) -> bool:
return (
type(self) == type(o)
and super().__eq__(o)
and (self.of_type, self.default, self.post_process) == (o.of_type, o.default, o.post_process)
and (self.of_type, self.default, self.post_process)
== (o.of_type, o.default, o.post_process) # type: ignore[attr-defined]
)


Expand Down
17 changes: 10 additions & 7 deletions src/tox/config/types.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from collections import OrderedDict
from typing import Any, Iterator, Sequence
from typing import Iterator, Sequence

from tox.execute.request import shell_cmd

Expand All @@ -21,10 +21,13 @@ def __init__(self, args: list[str]) -> None:
def __repr__(self) -> str:
return f"{type(self).__name__}(args={(['-'] if self.ignore_exit_code else [])+ self.args!r})"

def __eq__(self, other: Any) -> bool:
return type(self) == type(other) and (self.args, self.ignore_exit_code) == (other.args, other.ignore_exit_code)
def __eq__(self, other: object) -> bool:
return type(self) == type(other) and (self.args, self.ignore_exit_code) == (
other.args, # type: ignore[attr-defined]
other.ignore_exit_code, # type: ignore[attr-defined]
)

def __ne__(self, other: Any) -> bool:
def __ne__(self, other: object) -> bool:
return not (self == other)

@property
Expand All @@ -47,10 +50,10 @@ def __init__(self, envs: Sequence[str]) -> None:
def __repr__(self) -> str:
return f"{type(self).__name__}({self.envs!r})"

def __eq__(self, other: Any) -> bool:
return type(self) == type(other) and self.envs == other.envs
def __eq__(self, other: object) -> bool:
return type(self) == type(other) and self.envs == other.envs # type: ignore[attr-defined]

def __ne__(self, other: Any) -> bool:
def __ne__(self, other: object) -> bool:
return not (self == other)

def __iter__(self) -> Iterator[str]:
Expand Down
9 changes: 8 additions & 1 deletion src/tox/execute/local_sub_process/read_via_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@
from typing import TYPE_CHECKING, Callable

if TYPE_CHECKING:
import sys
from types import TracebackType

if sys.version_info >= (3, 11): # pragma: no cover (py311+)
from typing import Self
else: # pragma: no cover (<py311)
from typing_extensions import Self


WAIT_GENERAL = 0.05 # stop thread join every so often (give chance to a signal interrupt)


Expand All @@ -19,7 +26,7 @@ def __init__(self, file_no: int, handler: Callable[[bytes], None], name: str, dr
self.handler = handler
self._on_exit_drain = drain

def __enter__(self) -> ReadViaThread:
def __enter__(self) -> Self:
self.thread.start()
return self

Expand Down
8 changes: 7 additions & 1 deletion src/tox/execute/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@
from colorama import Fore

if TYPE_CHECKING:
import sys
from types import TracebackType

if sys.version_info >= (3, 11): # pragma: no cover (py311+)
from typing import Self
else: # pragma: no cover (<py311)
from typing_extensions import Self


class SyncWrite:
"""
Expand All @@ -33,7 +39,7 @@ def __init__(self, name: str, target: IO[bytes] | None, color: str | None = None
def __repr__(self) -> str:
return f"{self.__class__.__name__}(name={self.name!r}, target={self._target!r}, color={self._color!r})"

def __enter__(self) -> SyncWrite:
def __enter__(self) -> Self:
if self._target_enabled:
self._start()
return self
Expand Down
6 changes: 1 addition & 5 deletions src/tox/provision.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import json
import logging
import sys
from importlib.metadata import PackageNotFoundError, distribution
from pathlib import Path
from typing import TYPE_CHECKING, List, cast

Expand All @@ -19,11 +20,6 @@
from tox.tox_env.python.pip.req_file import PythonDeps
from tox.tox_env.python.runner import PythonRun

if sys.version_info >= (3, 8): # pragma: no cover (py38+)
from importlib.metadata import PackageNotFoundError, distribution
else: # pragma: no cover (py38+)
from importlib_metadata import PackageNotFoundError, distribution

if TYPE_CHECKING:
from argparse import ArgumentParser

Expand Down