Skip to content

Commit

Permalink
Add 3.13 to CI and bump deps (#3339)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborbernat committed Sep 7, 2024
1 parent 9138e15 commit 9c6f835
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 47 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
fail-fast: false
matrix:
py:
- "3.13"
- "3.12"
- "3.11"
- "3.10"
Expand All @@ -43,6 +44,7 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.py }}
allow-prereleases: true
- name: Pick environment to run
run: |
import os; import platform; import sys; from pathlib import Path
Expand All @@ -52,7 +54,7 @@ jobs:
file_handler.write(env)
shell: python
- name: Setup test suite
run: tox r -vv --notest
run: tox r -vv --notest --skip-missing-interpreters false
- name: Run test suite
run: tox r --skip-pkg-install
env:
Expand Down Expand Up @@ -87,7 +89,7 @@ jobs:
python-version: "3.12"
- name: Install self-tox
run: python -m pip install .
- name: Setup check suite
run: tox r -vv --notest --skip-missing-interpreters false -e ${{ matrix.tox_env }}
- name: Run check for ${{ matrix.tox_env }}
run: tox r -e ${{ matrix.tox_env }}
env:
UPGRADE_ADVISORY: "yes"
run: tox r --skip-pkg-install -e ${{ matrix.tox_env }}
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ jobs:
with:
python-version: "3.12"
- name: Install build
run: python -m pip install build
run: python -m pip install build[uv]
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build package
run: pyproject-build
run: pyproject-build --installer uv
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repos:
- id: codespell
additional_dependencies: ["tomli>=2.0.1"]
- repo: https://github.com/tox-dev/tox-ini-fmt
rev: "1.3.1"
rev: "1.3.2"
hooks:
- id: tox-ini-fmt
args: ["-p", "fix"]
Expand All @@ -24,7 +24,7 @@ repos:
hooks:
- id: pyproject-fmt
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.6.3"
rev: "v0.6.4"
hooks:
- id: ruff-format
- id: ruff
Expand Down
24 changes: 12 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dynamic = [
"version",
]
dependencies = [
"cachetools>=5.4",
"cachetools>=5.5",
"chardet>=5.2",
"colorama>=0.4.6",
"filelock>=3.15.4",
Expand All @@ -62,17 +62,17 @@ dependencies = [
"virtualenv>=20.26.3",
]
optional-dependencies.docs = [
"furo>=2024.7.18",
"sphinx>=7.4.7",
"sphinx-argparse-cli>=1.16",
"sphinx-autodoc-typehints>=2.2.3",
"furo>=2024.8.6",
"sphinx>=8.0.2",
"sphinx-argparse-cli>=1.17",
"sphinx-autodoc-typehints>=2.4",
"sphinx-copybutton>=0.5.2",
"sphinx-inline-tabs>=2023.4.21",
"sphinxcontrib-towncrier>=0.2.1a0",
"towncrier>=23.11",
"towncrier>=24.8",
]
optional-dependencies.testing = [
"build[virtualenv]>=1.2.1",
"build[virtualenv]>=1.2.2",
"covdefaults>=2.3",
"detect-test-pollution>=1.2",
"devpi-process>=1",
Expand All @@ -87,9 +87,9 @@ optional-dependencies.testing = [
"pytest-mock>=3.14",
"pytest-xdist>=3.6.1",
"re-assert>=1.1",
"setuptools>=70.3",
"time-machine>=2.14.2; implementation_name!='pypy'",
"wheel>=0.43",
"setuptools>=74.1.2",
"time-machine>=2.15; implementation_name!='pypy'",
"wheel>=0.44",
]
urls.Documentation = "https://tox.wiki"
urls.Homepage = "http://tox.readthedocs.org"
Expand Down Expand Up @@ -141,10 +141,10 @@ lint.ignore = [
]
lint.per-file-ignores."tests/**/*.py" = [
"D", # don't care about documentation in tests
"FBT", # don"t care about booleans as positional arguments in tests
"FBT", # don't care about booleans as positional arguments in tests
"INP001", # no implicit namespace
"PLR2004", # Magic value used in comparison, consider replacing with a constant variable
"S101", # asserts allowed in tests...
"S101", # asserts allowed in tests
"S603", # `subprocess` call: check for execution of untrusted input
]
lint.isort = { known-first-party = [
Expand Down
31 changes: 16 additions & 15 deletions src/tox/config/loader/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import typing
from abc import ABC, abstractmethod
from collections import OrderedDict
from inspect import isclass
from pathlib import Path
from typing import Any, Callable, Dict, Generic, Iterator, List, Literal, Optional, Set, TypeVar, Union, cast

Expand All @@ -18,7 +19,7 @@
class Convert(ABC, Generic[T]):
"""A class that converts a raw type to a given tox (python) type."""

def to(self, raw: T, of_type: type[V], factory: Factory[V]) -> V: # noqa: PLR0911
def to(self, raw: T, of_type: type[V], factory: Factory[V]) -> V: # noqa: PLR0911, C901
"""
Convert given raw type to python type.
Expand All @@ -30,26 +31,26 @@ def to(self, raw: T, of_type: type[V], factory: Factory[V]) -> V: # noqa: PLR09
from_module = getattr(of_type, "__module__", None)
if from_module in {"typing", "typing_extensions"}:
return self._to_typing(raw, of_type, factory)
if issubclass(of_type, Path):
return self.to_path(raw) # type: ignore[return-value]
if issubclass(of_type, bool):
return self.to_bool(raw) # type: ignore[return-value]
if issubclass(of_type, Command):
return self.to_command(raw) # type: ignore[return-value]
if issubclass(of_type, EnvList):
return self.to_env_list(raw) # type: ignore[return-value]
if issubclass(of_type, str):
return self.to_str(raw) # type: ignore[return-value]
# python does not allow use of parametrized generics with isinstance,
# so we need to check for them.
if isclass(of_type):
if issubclass(of_type, Path):
return self.to_path(raw) # type: ignore[return-value]
if issubclass(of_type, bool):
return self.to_bool(raw) # type: ignore[return-value]
if issubclass(of_type, Command):
return self.to_command(raw) # type: ignore[return-value]
if issubclass(of_type, EnvList):
return self.to_env_list(raw) # type: ignore[return-value]
if issubclass(of_type, str):
return self.to_str(raw) # type: ignore[return-value]
# python does not allow use of parametrized generics with isinstance, so we need to check for them.
if hasattr(typing, "GenericAlias") and isinstance(of_type, typing.GenericAlias):
return list(self.to_list(raw, of_type=of_type)) # type: ignore[return-value]
if isinstance(raw, of_type): # already target type no need to transform it
# do it this late to allow normalization - e.g. string strip
return raw
return raw # type: ignore[no-any-return]
if factory:
return factory(raw)
return of_type(raw) # type: ignore[call-arg]
return of_type(raw) # type: ignore[no-any-return]

def _to_typing(self, raw: T, of_type: type[V], factory: Factory[V]) -> V: # noqa: C901
origin = getattr(of_type, "__origin__", of_type.__class__)
Expand Down
3 changes: 2 additions & 1 deletion src/tox/config/loader/str_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import shlex
import sys
from inspect import isclass
from itertools import chain
from pathlib import Path
from typing import TYPE_CHECKING, Any, Iterator
Expand All @@ -28,7 +29,7 @@ def to_path(value: str) -> Path:

@staticmethod
def to_list(value: str, of_type: type[Any]) -> Iterator[str]:
splitter = "\n" if issubclass(of_type, Command) or "\n" in value else ","
splitter = "\n" if (isclass(of_type) and issubclass(of_type, Command)) or "\n" in value else ","
splitter = splitter.replace("\r", "")
for token in value.split(splitter):
value = token.strip()
Expand Down
23 changes: 12 additions & 11 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ requires =
tox>=4.2
env_list =
fix
py312
py311
py310
py39
py38
cov
type
docs
3.13
3.12
3.11
3.10
3.9
3.8
pkg_meta
skip_missing_interpreters = true

Expand Down Expand Up @@ -40,7 +41,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.8
pre-commit-uv>=4.1
pass_env =
{[testenv]passenv}
PROGRAMDATA
Expand All @@ -51,8 +52,8 @@ commands =
[testenv:type]
description = run type check on code base
deps =
mypy==1.11
types-cachetools>=5.4.0.20240717
mypy==1.11.2
types-cachetools>=5.5.0.20240820
types-chardet>=5.0.4.6
commands =
mypy src/tox
Expand All @@ -71,11 +72,11 @@ commands =
description = check that the long description is valid
skip_install = true
deps =
build[virtualenv]>=1.2.1
build[uv]>=1.2.2
check-wheel-contents>=0.6
twine>=5.1.1
commands =
python -m build -o {envtmpdir} -s -w .
python -m build --installer uv -o {envtmpdir} -s -w .
twine check {envtmpdir}{/}*
check-wheel-contents --no-config {envtmpdir}

Expand All @@ -85,7 +86,7 @@ skip_install = true
deps =
gitpython>=3.1.43
packaging>=24.1
towncrier>=23.11
towncrier>=24.8
commands =
python {toxinidir}/tasks/release.py --version {posargs}

Expand Down

0 comments on commit 9c6f835

Please sign in to comment.