diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 87e4c54..1e521bb 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -24,7 +24,6 @@ jobs: - "3.11" - "3.10" - "3.9" - - "3.8" - type - dev - pkg_meta @@ -33,7 +32,7 @@ jobs: with: fetch-depth: 0 - name: Install the latest version of uv - uses: astral-sh/setup-uv@v3 + uses: astral-sh/setup-uv@v5 with: enable-cache: true cache-dependency-glob: "pyproject.toml" diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 21eca2f..b081400 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -14,7 +14,7 @@ jobs: with: fetch-depth: 0 - name: Install the latest version of uv - uses: astral-sh/setup-uv@v3 + uses: astral-sh/setup-uv@v5 with: enable-cache: true cache-dependency-glob: "pyproject.toml" @@ -43,6 +43,6 @@ jobs: name: ${{ env.dists-artifact-name }} path: dist/ - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@v1.10.1 + uses: pypa/gh-action-pypi-publish@v1.12.3 with: attestations: true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9891190..9200d50 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,11 +1,11 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.29.2 + rev: 0.31.0 hooks: - id: check-github-workflows args: ["--verbose"] @@ -13,24 +13,24 @@ repos: rev: v2.3.0 hooks: - id: codespell - additional_dependencies: ["tomli>=2.0.1"] + additional_dependencies: ["tomli>=2.2.1"] - repo: https://github.com/tox-dev/tox-ini-fmt - rev: "1.4.0" + rev: "1.4.1" hooks: - id: tox-ini-fmt args: ["-p", "fix"] - repo: https://github.com/tox-dev/pyproject-fmt - rev: "2.2.3" + rev: "v2.5.0" hooks: - id: pyproject-fmt - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.6.5" + rev: "v0.9.2" hooks: - id: ruff-format - id: ruff args: ["--fix", "--unsafe-fixes", "--exit-non-zero-on-fix"] - repo: https://github.com/rbubley/mirrors-prettier - rev: "v3.3.3" + rev: "v3.4.2" hooks: - id: prettier args: ["--print-width=120", "--prose-wrap=always"] diff --git a/pyproject.toml b/pyproject.toml index 8d15539..fa15da3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ build-backend = "hatchling.build" requires = [ "hatch-vcs>=0.4", - "hatchling>=1.25", + "hatchling>=1.27", ] [project] @@ -20,7 +20,7 @@ license = "MIT" maintainers = [ { name = "Bernát Gábor", email = "gaborjbernat@gmail.com" }, ] -requires-python = ">=3.8" +requires-python = ">=3.9" classifiers = [ "Development Status :: 5 - Production/Stable", "Framework :: tox", @@ -30,7 +30,6 @@ classifiers = [ "Operating System :: Microsoft :: Windows", "Operating System :: POSIX", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -44,12 +43,12 @@ dynamic = [ "version", ] dependencies = [ - "packaging>=24.1", + "packaging>=24.2", ] optional-dependencies.testing = [ "covdefaults>=2.3", - "pytest>=8.3.2", - "pytest-cov>=5", + "pytest>=8.3.4", + "pytest-cov>=6", ] urls.Documentation = "https://tox.wiki" urls.Homepage = "https://github.com/tox-dev/tox-ini-fmt/blob/main/README.md#tox-ini-fmt" @@ -71,7 +70,6 @@ build.targets.sdist.include = [ version.source = "vcs" [tool.ruff] -target-version = "py38" line-length = 120 format.preview = true format.docstring-code-line-length = 100 @@ -80,7 +78,6 @@ lint.select = [ "ALL", ] lint.ignore = [ - "ANN101", # Missing type annotation for `self` in method "COM812", # Conflict with formatter "CPY", # No copyright statements "D203", # `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible diff --git a/src/tox_ini_fmt/__main__.py b/src/tox_ini_fmt/__main__.py index 2e815df..754846c 100644 --- a/src/tox_ini_fmt/__main__.py +++ b/src/tox_ini_fmt/__main__.py @@ -5,11 +5,14 @@ import difflib import sys from pathlib import Path -from typing import Iterable, Sequence +from typing import TYPE_CHECKING from tox_ini_fmt.cli import cli_args from tox_ini_fmt.formatter import format_tox_ini +if TYPE_CHECKING: + from collections.abc import Iterable, Sequence + GREEN = "\u001b[32m" RED = "\u001b[31m" RESET = "\u001b[0m" diff --git a/src/tox_ini_fmt/cli.py b/src/tox_ini_fmt/cli.py index 2a37e58..3f85869 100644 --- a/src/tox_ini_fmt/cli.py +++ b/src/tox_ini_fmt/cli.py @@ -5,7 +5,10 @@ import os from argparse import Action, ArgumentParser, ArgumentTypeError, Namespace from pathlib import Path -from typing import Any, Sequence +from typing import TYPE_CHECKING, Any + +if TYPE_CHECKING: + from collections.abc import Sequence class ToxIniFmtNamespace(Namespace): diff --git a/src/tox_ini_fmt/formatter/test_env.py b/src/tox_ini_fmt/formatter/test_env.py index 4dc654f..d9c4686 100644 --- a/src/tox_ini_fmt/formatter/test_env.py +++ b/src/tox_ini_fmt/formatter/test_env.py @@ -3,11 +3,12 @@ from __future__ import annotations from functools import partial -from typing import TYPE_CHECKING, Callable, Mapping +from typing import TYPE_CHECKING, Callable from .util import collect_multi_line, fix_and_reorder, fmt_list, to_boolean, to_list_of_env_values, to_py_dependencies if TYPE_CHECKING: + from collections.abc import Mapping from configparser import ConfigParser diff --git a/src/tox_ini_fmt/formatter/tox_section.py b/src/tox_ini_fmt/formatter/tox_section.py index a1384ea..a6df6c7 100644 --- a/src/tox_ini_fmt/formatter/tox_section.py +++ b/src/tox_ini_fmt/formatter/tox_section.py @@ -3,7 +3,7 @@ from __future__ import annotations from functools import partial -from typing import TYPE_CHECKING, Callable, Mapping +from typing import TYPE_CHECKING, Callable from packaging.requirements import Requirement from packaging.version import Version @@ -12,6 +12,7 @@ from .util import collect_multi_line, fix_and_reorder, to_boolean, to_list_of_env_values, to_py_dependencies if TYPE_CHECKING: + from collections.abc import Mapping from configparser import ConfigParser, SectionProxy @@ -63,15 +64,15 @@ def _handle_min_version(tox: SectionProxy) -> None: normalize=lambda groups: {k: requires(v) for k, v in groups.items()}, )[0] ] - for _at, entry in enumerate(tox_requires): + for at, entry in enumerate(tox_requires): # noqa: B007 # false positive if entry.name == "tox": break else: - _at = -1 - if _at == -1: + at = -1 + if at == -1: tox_requires.append(Requirement(f"tox>={min_version}")) else: - specifiers = list(tox_requires[_at].specifier) + specifiers = list(tox_requires[at].specifier) if len(specifiers) == 0 or Version(specifiers[0].version) < Version(min_version): - tox_requires[_at] = Requirement(f"tox>={min_version}") + tox_requires[at] = Requirement(f"tox>={min_version}") tox["requires"] = "\n".join(str(i) for i in tox_requires) diff --git a/src/tox_ini_fmt/formatter/util.py b/src/tox_ini_fmt/formatter/util.py index 06f77dc..5485ac1 100644 --- a/src/tox_ini_fmt/formatter/util.py +++ b/src/tox_ini_fmt/formatter/util.py @@ -6,11 +6,12 @@ import re from collections import defaultdict from functools import partial -from typing import TYPE_CHECKING, Callable, Mapping, TypedDict, cast +from typing import TYPE_CHECKING, Callable, TypedDict, cast from .requires import requires if TYPE_CHECKING: + from collections.abc import Mapping from configparser import ConfigParser @@ -104,7 +105,7 @@ def to_list_of_env_values(pin_toxenvs: list[str], payload: str) -> str: within_braces = False envs = [i.strip() for i in brace_str[1:].split(",")] order_env_list(envs, pin_toxenvs) - cur_str += f'{{{", ".join(envs)}}}' + cur_str += f"{{{', '.join(envs)}}}" brace_str = "" continue elif char in {",", "\n"}: @@ -145,7 +146,7 @@ def _get_py_version(pin_toxenvs: list[str], env_list: str) -> tuple[int, ...]: if element in pin_toxenvs: return len(element) - pin_toxenvs.index(element), 0 if match := _TOX_ENV_MATCHER.fullmatch(element): - got = cast(_ToxMatch, {k: (v if k == "name" else int(v or 0)) for k, v in match.groupdict().items()}) + got = cast("_ToxMatch", {k: (v if k == "name" else int(v or 0)) for k, v in match.groupdict().items()}) main = {"py": 0, "pypy": -1}.get(got.get("name") or "", -2) version: list[int] = [got["major"], got["minor"]] if got["major"] else [got["version"]] return main, *version diff --git a/tests/formatter/test_test_env.py b/tests/formatter/test_test_env.py index 1a1b8c4..4b86086 100644 --- a/tests/formatter/test_test_env.py +++ b/tests/formatter/test_test_env.py @@ -142,10 +142,7 @@ def test_format_test_env_ref( # noqa: PLR0913 post: str, expected: str, ) -> None: - text = ( - f"[testenv]\n{key}={before}\n[testenv:py]" - f"\n{key}=\n {pre}\n {{[testenv:x]X}}\n {{[testenv]{key}}}\n {post}\n" - ) + text = f"[testenv]\n{key}={before}\n[testenv:py]\n{key}=\n {pre}\n {{[testenv:x]X}}\n {{[testenv]{key}}}\n {post}\n" tox_ini.write_text(text) outcome = format_tox_ini(tox_ini) expected = f"[tox]\nrequires =\n tox>=4.2\n\n[testenv]\n{key} ={before}\n\n[testenv:py]\n{key} ={expected}\n" diff --git a/tox.ini b/tox.ini index a70e732..8a32dce 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] requires = - tox>=4.2 - tox-uv>=1.11.3 + tox>=4.23.2 + tox-uv>=1.19.1 env_list = fix 3.13 @@ -9,7 +9,6 @@ env_list = 3.11 3.10 3.9 - 3.8 type pkg_meta skip_missing_interpreters = true @@ -37,14 +36,14 @@ 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-uv>=4.1.1 + pre-commit-uv>=4.1.4 commands = pre-commit run --all-files --show-diff-on-failure [testenv:type] description = run type check on code base deps = - mypy==1.11.2 + mypy==1.14.1 commands = mypy src mypy tests @@ -53,9 +52,9 @@ commands = description = check that the long description is valid skip_install = true deps = - check-wheel-contents>=0.6 - twine>=5.1.1 - uv>=0.4.10 + check-wheel-contents>=0.6.1 + twine>=6.0.1 + uv>=0.5.21 commands = uv build --sdist --wheel --out-dir {env_tmp_dir} . twine check {env_tmp_dir}{/}*