Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#3267)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] committed Apr 23, 2024
1 parent 0e5a3db commit 822c9d0
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 18 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Expand Up @@ -5,7 +5,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.28.1
rev: 0.28.2
hooks:
- id: check-github-workflows
args: [ "--verbose" ]
Expand All @@ -20,12 +20,12 @@ repos:
- id: tox-ini-fmt
args: ["-p", "fix"]
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "1.7.0"
rev: "1.8.0"
hooks:
- id: pyproject-fmt
additional_dependencies: ["tox>=4.12.1"]
additional_dependencies: ["tox>=4.14.2"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.3.5"
rev: "v0.4.1"
hooks:
- id: ruff-format
- id: ruff
Expand All @@ -34,7 +34,7 @@ repos:
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies: [black==23.12.1]
additional_dependencies: [black==24.4]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
Expand Down
4 changes: 2 additions & 2 deletions src/tox/config/loader/convert.py
Expand Up @@ -64,13 +64,13 @@ def _to_typing(self, raw: T, of_type: type[V], factory: Factory[V]) -> V: # noq
elif origin == Union: # handle Optional values
args: list[type[Any]] = of_type.__args__ # type: ignore[attr-defined]
none = type(None)
if len(args) == 2 and none in args: # type: ignore[comparison-overlap] # noqa: PLR2004
if len(args) == 2 and none in args: # noqa: PLR2004
if isinstance(raw, str):
raw = raw.strip() # type: ignore[assignment]
if not raw:
result = None
else:
new_type = next(i for i in args if i != none) # type: ignore[comparison-overlap] # pragma: no cover
new_type = next(i for i in args if i != none) # pragma: no cover
result = self.to(raw, new_type, factory)
elif origin in {Literal, type(Literal)}:
choice = of_type.__args__ # type: ignore[attr-defined]
Expand Down
2 changes: 1 addition & 1 deletion src/tox/session/cmd/show_config.py
Expand Up @@ -95,7 +95,7 @@ def print_key_value(is_colored: bool, key: str, value: str, multi_line: bool = F


def print_conf(is_colored: bool, conf: ConfigSet, keys: Iterable[str]) -> None: # noqa: FBT001
for key in keys if keys else conf:
for key in keys or conf:
if key not in conf:
continue
key = conf.primary_key(key) # noqa: PLW2901
Expand Down
5 changes: 4 additions & 1 deletion src/tox/tox_env/python/pip/pip_install.py
@@ -1,6 +1,7 @@
from __future__ import annotations

import logging
import operator
from collections import defaultdict
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable, Sequence
Expand Down Expand Up @@ -132,7 +133,9 @@ def _install_requirement_file(self, arguments: PythonDeps, section: str, of_type
if not eq: # pragma: no branch
if old is not None:
self._recreate_if_diff("install flag(s)", new_options, old["options"], lambda i: i)
self._recreate_if_diff("constraint(s)", new_constraints, old["constraints"], lambda i: i[3:])
self._recreate_if_diff(
"constraint(s)", new_constraints, old["constraints"], operator.itemgetter(slice(3, None))
)
missing_requirement = set(old["requirements"]) - set(new_requirements)
if missing_requirement:
msg = f"requirements removed: {' '.join(missing_requirement)}"
Expand Down
2 changes: 1 addition & 1 deletion src/tox/util/cpu.py
Expand Up @@ -10,7 +10,7 @@ def auto_detect_cpus() -> int:
n: int | None = multiprocessing.cpu_count()
except NotImplementedError:
n = None
return n if n else 1
return n or 1


__all__ = ("auto_detect_cpus",)
6 changes: 4 additions & 2 deletions tests/util/test_ci.py
@@ -1,5 +1,7 @@
from __future__ import annotations

import operator

import pytest

from tox.util.ci import _ENV_VARS, is_ci # noqa: PLC2701
Expand All @@ -22,7 +24,7 @@
"TEAMCITY_VERSION": None, # TeamCity
"TRAVIS": "true", # Travis CI
}.items(),
ids=lambda v: v[0],
ids=operator.itemgetter(0),
)
def test_is_ci(env_var: tuple[str, str | None], monkeypatch: pytest.MonkeyPatch) -> None:
for var in _ENV_VARS:
Expand All @@ -41,7 +43,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],
ids=operator.itemgetter(0),
)
def test_is_ci_bad_set(env_var: tuple[str, str], monkeypatch: pytest.MonkeyPatch) -> None:
for var in _ENV_VARS:
Expand Down
12 changes: 6 additions & 6 deletions tox.ini
Expand Up @@ -40,7 +40,7 @@ commands =
description = format the code base to adhere to our styles, and complain about what we cannot do automatically
skip_install = true
deps =
pre-commit>=3.6
pre-commit>=3.7
pass_env =
{[testenv]passenv}
PROGRAMDATA
Expand All @@ -51,7 +51,7 @@ commands =
[testenv:type]
description = run type check on code base
deps =
mypy==1.8
mypy==1.9
types-cachetools>=5.3.0.7
types-chardet>=5.0.4.6
commands =
Expand All @@ -71,9 +71,9 @@ commands =
description = check that the long description is valid
skip_install = true
deps =
build[virtualenv]>=1.0.3
build[virtualenv]>=1.2.1
check-wheel-contents>=0.6
twine>=4.0.2
twine>=5
commands =
python -m build -o {envtmpdir} -s -w .
twine check {envtmpdir}{/}*
Expand All @@ -83,8 +83,8 @@ commands =
description = do a release, required posarg of the version number
skip_install = true
deps =
gitpython>=3.1.41
packaging>=23.2
gitpython>=3.1.43
packaging>=24
towncrier>=23.11
commands =
python {toxinidir}/tasks/release.py --version {posargs}
Expand Down

0 comments on commit 822c9d0

Please sign in to comment.