Skip to content

Commit 659f714

Browse files
authored
Fix the CI (#3183)
1 parent 8406971 commit 659f714

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+260
-186
lines changed

.pre-commit-config.yaml

+5-8
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ repos:
44
hooks:
55
- id: end-of-file-fixer
66
- id: trailing-whitespace
7-
- repo: https://github.com/astral-sh/ruff-pre-commit
8-
rev: v0.1.11
9-
hooks:
10-
- id: ruff-format
117
- repo: https://github.com/codespell-project/codespell
128
rev: v2.2.6
139
hooks:
@@ -21,20 +17,21 @@ repos:
2117
- id: tox-ini-fmt
2218
args: ["-p", "fix"]
2319
- repo: https://github.com/tox-dev/pyproject-fmt
24-
rev: 1.5.3
20+
rev: 1.6.0
2521
hooks:
2622
- id: pyproject-fmt
2723
additional_dependencies: ["tox>=4.11.4"]
2824
- repo: https://github.com/asottile/blacken-docs
2925
rev: 1.16.0
3026
hooks:
3127
- id: blacken-docs
32-
additional_dependencies: [black==23.11]
28+
additional_dependencies: [black==23.12.1]
3329
- repo: https://github.com/astral-sh/ruff-pre-commit
34-
rev: v0.1.11
30+
rev: v0.1.12
3531
hooks:
32+
- id: ruff-format
3633
- id: ruff
37-
args: [--fix, --exit-non-zero-on-fix, --unsafe-fixes]
34+
args: ["--fix", "--unsafe-fixes", "--exit-non-zero-on-fix"]
3835
- repo: https://github.com/pre-commit/pygrep-hooks
3936
rev: v1.10.0
4037
hooks:

docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def resolve_xref( # noqa: PLR0913
129129
tox_cfg = SourceFileLoader("tox_conf", str(here / "tox_conf.py")).load_module().ToxConfig
130130
app.add_directive(tox_cfg.name, tox_cfg)
131131

132-
def check_uri(self: ExternalLinksChecker, refnode: reference) -> None: #
132+
def check_uri(self: ExternalLinksChecker, refnode: reference) -> None:
133133
if refnode.document.attributes["source"].endswith("index.rst"):
134134
return None # do not use for the index file
135135
return prev_check(self, refnode)

pyproject.toml

+34-28
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
build-backend = "hatchling.build"
33
requires = [
44
"hatch-vcs>=0.4",
5-
"hatchling>=1.18",
5+
"hatchling>=1.21",
66
]
77

88
[project]
@@ -51,13 +51,13 @@ dependencies = [
5151
"chardet>=5.2",
5252
"colorama>=0.4.6",
5353
"filelock>=3.13.1",
54-
'importlib-metadata>=7; python_version < "3.8"',
54+
'importlib-metadata>=7.0.1; python_version < "3.8"',
5555
"packaging>=23.2",
5656
"platformdirs>=4.1",
5757
"pluggy>=1.3",
5858
"pyproject-api>=1.6.1",
5959
'tomli>=2.0.1; python_version < "3.11"',
60-
'typing-extensions>=4.8; python_version < "3.8"',
60+
'typing-extensions>=4.9; python_version < "3.8"',
6161
"virtualenv>=20.25",
6262
]
6363
optional-dependencies.docs = [
@@ -75,13 +75,13 @@ optional-dependencies.testing = [
7575
"covdefaults>=2.3",
7676
"detect-test-pollution>=1.2",
7777
"devpi-process>=1",
78-
"diff-cover>=8.0.1",
79-
"distlib>=0.3.7",
78+
"diff-cover>=8.0.2",
79+
"distlib>=0.3.8",
8080
"flaky>=3.7",
8181
"hatch-vcs>=0.4",
82-
"hatchling>=1.18",
83-
"psutil>=5.9.6",
84-
"pytest>=7.4.3",
82+
"hatchling>=1.21",
83+
"psutil>=5.9.7",
84+
"pytest>=7.4.4",
8585
"pytest-cov>=4.1",
8686
"pytest-mock>=3.12",
8787
"pytest-xdist>=3.5",
@@ -106,34 +106,40 @@ version.source = "vcs"
106106
select = ["ALL"]
107107
line-length = 120
108108
target-version = "py38"
109-
isort = {known-first-party = ["tox", "tests"], required-imports = ["from __future__ import annotations"]}
109+
isort = { known-first-party = ["tox", "tests"], required-imports = ["from __future__ import annotations"] }
110110
ignore = [
111+
"CPY", # No copyright header
111112
"INP001", # no implicit namespaces here
112-
"D", # ignore documentation for now
113+
"D", # ignore documentation for now
113114
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed in `arg`"
114115
"ANN101", # Missing type annotation for `self` in method
115116
"ANN102", # Missing type annotation for `cls` in classmethod"
116-
"D203", # `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible
117-
"D212", # `multi-line-summary-first-line` (D212) and `multi-line-summary-second-line` (D213) are incompatible
118-
"S104", # Possible binding to all interface
119-
"COM812", # conflicts with formatter
120-
"COM819", # conflicts with formatter
121-
"E501", # conflicts with formatter
122-
"ISC001", # conflicts with formatter
123-
"Q000", # conflicts with formatter
124-
"Q001", # conflicts with formatter
125-
"Q002", # conflicts with formatter
126-
"Q003", # conflicts with formatter
127-
"W191", # conflicts with formatter
117+
"D203", # `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible
118+
"D212", # `multi-line-summary-first-line` (D212) and `multi-line-summary-second-line` (D213) are incompatible
119+
"S104", # Possible binding to all interfaces
120+
"COM812", # conflicts with formatter
121+
"COM819", # conflicts with formatter
122+
"E501", # conflicts with formatter
123+
"ISC001", # conflicts with formatter
124+
"Q000", # conflicts with formatter
125+
"Q001", # conflicts with formatter
126+
"Q002", # conflicts with formatter
127+
"Q003", # conflicts with formatter
128+
"W191", # conflicts with formatter
129+
"S404", # Using subprocess is alright.
130+
"PLR0914", ## Too many local variables
131+
"PLR0917", ## Too many positional arguments
128132
]
133+
format.preview = true
134+
lint.preview = true
129135
[tool.ruff.per-file-ignores]
130136
"tests/**/*.py" = [
131-
"S101", # asserts allowed in tests...
132-
"FBT", # don"t care about booleans as positional arguments in tests
133-
"INP001", # no implicit namespace
134-
"D", # don"t care about documentation in tests
135-
"S603", # `subprocess` call: check for execution of untrusted input
136-
"PLR2004", # Magic value used in comparison, consider replacing with a constant variable
137+
"S101", # asserts allowed in tests...
138+
"FBT", # don"t care about booleans as positional arguments in tests
139+
"INP001", # no implicit namespace
140+
"D", # don't care about documentation in tests
141+
"S603", # `subprocess` call: check for execution of untrusted input
142+
"PLR2004", # Magic value used in comparison, consider replacing with a constant variable
137143
]
138144

139145
[tool.pytest.ini_options]

src/tox/config/cli/env_var.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Provides configuration values from the environment variables."""
2+
23
from __future__ import annotations
34

45
import logging
@@ -24,7 +25,7 @@ def get_env_var(key: str, of_type: type[Any]) -> tuple[Any, str] | None:
2425
value = os.environ[environ_key]
2526
origin = getattr(of_type, "__origin__", of_type.__class__)
2627
try:
27-
if origin in (list, List):
28+
if origin in {list, List}:
2829
entry_type = of_type.__args__[0]
2930
result = [CONVERT.to(raw=v, of_type=entry_type, factory=None) for v in value.split(";")]
3031
else:

src/tox/config/cli/ini.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Provides configuration values from tox.ini files."""
2+
23
from __future__ import annotations
34

45
import logging

src/tox/config/cli/parse.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""This module pulls together this package: create and parse CLI arguments for tox."""
2+
23
from __future__ import annotations
34

45
import os
@@ -51,7 +52,7 @@ def _get_base(args: Sequence[str]) -> tuple[int, ToxHandler, Source]:
5152
... # ignore parse errors, such as -va raises ignored explicit argument 'a'
5253
guess_verbosity = parsed.verbosity
5354
handler = setup_report(guess_verbosity, parsed.is_colored)
54-
from tox.plugin.manager import MANAGER # load the plugin system right after we set up report
55+
from tox.plugin.manager import MANAGER # load the plugin system right after we set up report # noqa: PLC0415
5556

5657
source = discover_source(parsed.config_file, parsed.root_dir)
5758

@@ -71,7 +72,7 @@ def _get_all(args: Sequence[str]) -> tuple[Parsed, dict[str, Callable[[State], i
7172
def _get_parser() -> ToxParser:
7273
tox_parser = ToxParser.core() # load the core options
7374
# plus options setup by plugins
74-
from tox.plugin.manager import MANAGER
75+
from tox.plugin.manager import MANAGER # noqa: PLC0415
7576

7677
MANAGER.tox_add_option(tox_parser)
7778
tox_parser.fix_defaults()
@@ -80,7 +81,7 @@ def _get_parser() -> ToxParser:
8081

8182
def _get_parser_doc() -> ToxParser:
8283
# trigger register of tox env types (during normal run we call this later to handle plugins)
83-
from tox.plugin.manager import MANAGER # pragma: no cover
84+
from tox.plugin.manager import MANAGER # pragma: no cover # noqa: PLC0415
8485

8586
MANAGER.load_plugins(Path.cwd())
8687

src/tox/config/cli/parser.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Customize argparse logic for tox (also contains the base options)."""
2+
23
from __future__ import annotations
34

45
import argparse
@@ -181,7 +182,7 @@ def add_command(
181182

182183
def add_argument_group(self, *args: Any, **kwargs: Any) -> Any:
183184
result = super().add_argument_group(*args, **kwargs)
184-
if self.of_cmd is None and args not in (("positional arguments",), ("optional arguments",)):
185+
if self.of_cmd is None and args not in {("positional arguments",), ("optional arguments",)}:
185186

186187
def add_mutually_exclusive_group(**e_kwargs: Any) -> Any:
187188
def add_argument(*a_args: str, of_type: type[Any] | None = None, **a_kwargs: Any) -> Action:
@@ -249,7 +250,7 @@ def parse_known_args( # type: ignore[override]
249250
cmd_at = None
250251
if cmd_at is not None: # if we found a command move it to the start
251252
args = args[cmd_at], *args[:cmd_at], *args[cmd_at + 1 :]
252-
elif args not in (("--help",), ("-h",)) and (self._cmd is not None and "legacy" in self._cmd.choices):
253+
elif tuple(args) not in {("--help",), ("-h",)} and (self._cmd is not None and "legacy" in self._cmd.choices):
253254
# on help no mangling needed, and we also want to insert once we have legacy to insert
254255
args = "legacy", *args
255256
result = Parsed() if namespace is None else namespace
@@ -258,7 +259,7 @@ def parse_known_args( # type: ignore[override]
258259

259260

260261
def add_verbosity_flags(parser: ArgumentParser) -> None:
261-
from tox.report import LEVELS
262+
from tox.report import LEVELS # noqa: PLC0415
262263

263264
level_map = "|".join(f"{c}={logging.getLevelName(level)}" for c, level in sorted(LEVELS.items()))
264265
verbosity_group = parser.add_argument_group("verbosity")

src/tox/config/loader/api.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from .section import Section
1717

1818

19-
class Override:
19+
class Override: # noqa: PLW1641
2020
"""An override for config definitions."""
2121

2222
def __init__(self, value: str) -> None:
@@ -127,7 +127,7 @@ def load( # noqa: PLR0913
127127
:param args: the config load arguments
128128
:return: the converted type
129129
"""
130-
from tox.config.set_env import SetEnv
130+
from tox.config.set_env import SetEnv # noqa: PLC0415
131131

132132
override = self.overrides.get(key)
133133
if override:

src/tox/config/loader/convert.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def to(self, raw: T, of_type: type[V], factory: Factory[V]) -> V: # noqa: PLR09
2727
:return: the converted type
2828
"""
2929
from_module = getattr(of_type, "__module__", None)
30-
if from_module in ("typing", "typing_extensions"):
30+
if from_module in {"typing", "typing_extensions"}:
3131
return self._to_typing(raw, of_type, factory)
3232
if issubclass(of_type, Path):
3333
return self.to_path(raw) # type: ignore[return-value]
@@ -49,13 +49,13 @@ def to(self, raw: T, of_type: type[V], factory: Factory[V]) -> V: # noqa: PLR09
4949
def _to_typing(self, raw: T, of_type: type[V], factory: Factory[V]) -> V: # noqa: C901
5050
origin = getattr(of_type, "__origin__", of_type.__class__)
5151
result: Any = _NO_MAPPING
52-
if origin in (list, List):
52+
if origin in {list, List}:
5353
entry_type = of_type.__args__[0] # type: ignore[attr-defined]
5454
result = [self.to(i, entry_type, factory) for i in self.to_list(raw, entry_type)]
55-
elif origin in (set, Set):
55+
elif origin in {set, Set}:
5656
entry_type = of_type.__args__[0] # type: ignore[attr-defined]
5757
result = {self.to(i, entry_type, factory) for i in self.to_set(raw, entry_type)}
58-
elif origin in (dict, Dict):
58+
elif origin in {dict, Dict}:
5959
key_type, value_type = of_type.__args__[0], of_type.__args__[1] # type: ignore[attr-defined]
6060
result = OrderedDict(
6161
(self.to(k, key_type, factory), self.to(v, value_type, factory))
@@ -72,7 +72,7 @@ def _to_typing(self, raw: T, of_type: type[V], factory: Factory[V]) -> V: # noq
7272
else:
7373
new_type = next(i for i in args if i != none) # type: ignore[comparison-overlap] # pragma: no cover
7474
result = self.to(raw, new_type, factory)
75-
elif origin in (Literal, type(Literal)):
75+
elif origin in {Literal, type(Literal)}:
7676
choice = of_type.__args__ # type: ignore[attr-defined]
7777
if raw not in choice:
7878
msg = f"{raw} must be one of {choice}"

src/tox/config/loader/ini/factor.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Expand tox factor expressions to tox environment list."""
2+
23
from __future__ import annotations
34

45
import re

src/tox/config/loader/ini/replace.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Apply value substitution (replacement) on tox strings."""
2+
23
from __future__ import annotations
34

45
import logging
@@ -57,7 +58,7 @@ def replace(conf: Config, loader: IniLoader, value: str, args: ConfigLoadArgs, d
5758
return Replacer(conf, loader, conf_args=args, depth=depth).join(find_replace_expr(value))
5859

5960

60-
class MatchExpression:
61+
class MatchExpression: # noqa: PLW1641
6162
"""An expression that is handled specially by the Replacer."""
6263

6364
def __init__(self, expr: Sequence[MatchArg], term_pos: int | None = None) -> None:

src/tox/config/loader/section.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from typing_extensions import Self
1212

1313

14-
class Section:
14+
class Section: # noqa: PLW1641
1515
"""tox configuration section."""
1616

1717
SEP = ":" #: string used to separate the prefix and the section in the key

src/tox/config/loader/str_convert.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Convert string configuration values to tox python configuration objects."""
2+
23
from __future__ import annotations
34

45
import shlex
@@ -65,7 +66,7 @@ def _win32_process_path_backslash(value: str, escape: str, special_chars: str) -
6566
if last_char == escape:
6667
continue
6768
next_char = value[ix + 1 : ix + 2]
68-
if next_char not in (escape, *special_chars):
69+
if next_char not in {escape, *special_chars}:
6970
result.append(escape) # escape escapes that are not themselves escaping a special character
7071
return "".join(result)
7172

@@ -109,7 +110,7 @@ def to_command(value: str) -> Command:
109110

110111
@staticmethod
111112
def to_env_list(value: str) -> EnvList:
112-
from tox.config.loader.ini.factor import extend_factors
113+
from tox.config.loader.ini.factor import extend_factors # noqa: PLC0415
113114

114115
elements = list(chain.from_iterable(extend_factors(expr) for expr in value.split("\n")))
115116
return EnvList(elements)

src/tox/config/of_type.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Group together configuration values (such as base tox configuration, tox environment configs)."""
2+
23
from __future__ import annotations
34

45
from abc import ABC, abstractmethod
@@ -16,7 +17,7 @@
1617
V = TypeVar("V")
1718

1819

19-
class ConfigDefinition(ABC, Generic[T]):
20+
class ConfigDefinition(ABC, Generic[T]): # noqa: PLW1641
2021
"""Abstract base class for configuration definitions."""
2122

2223
def __init__(self, keys: Iterable[str], desc: str) -> None:
@@ -34,7 +35,7 @@ def __ne__(self, o: object) -> bool:
3435
return not (self == o)
3536

3637

37-
class ConfigConstantDefinition(ConfigDefinition[T]):
38+
class ConfigConstantDefinition(ConfigDefinition[T]): # noqa: PLW1641
3839
"""A configuration definition whose value is defined upfront (such as the tox environment name)."""
3940

4041
def __init__(
@@ -61,7 +62,7 @@ def __eq__(self, o: object) -> bool:
6162
_PLACE_HOLDER = object()
6263

6364

64-
class ConfigDynamicDefinition(ConfigDefinition[T]):
65+
class ConfigDynamicDefinition(ConfigDefinition[T]): # noqa: PLW1641
6566
"""A configuration definition that comes from a source (such as in memory, an ini file, a toml file, etc.)."""
6667

6768
def __init__( # noqa: PLR0913

src/tox/config/set_env.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def __init__(self, raw: str, name: str, env_name: str | None, root: Path) -> Non
1818
self._env_files: list[str] = []
1919
self._replacer: Replacer = lambda s, c: s # noqa: ARG005
2020
self._name, self._env_name, self._root = name, env_name, root
21-
from .loader.ini.replace import MatchExpression, find_replace_expr
21+
from .loader.ini.replace import MatchExpression, find_replace_expr # noqa: PLC0415
2222

2323
for line in raw.splitlines():
2424
if line.strip():
@@ -82,7 +82,7 @@ def load(self, item: str, args: ConfigLoadArgs | None = None) -> str:
8282
return result
8383

8484
def __contains__(self, item: object) -> bool:
85-
return isinstance(item, str) and item in self.__iter__()
85+
return isinstance(item, str) and item in iter(self)
8686

8787
def __iter__(self) -> Iterator[str]:
8888
# start with the materialized ones, maybe we don't need to materialize the raw ones

0 commit comments

Comments
 (0)