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

Lines changed: 5 additions & 8 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 34 additions & 28 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 4 additions & 3 deletions
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

Lines changed: 4 additions & 3 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 5 additions & 5 deletions
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

Lines changed: 1 addition & 0 deletions
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

0 commit comments

Comments
 (0)