Skip to content

Commit b7e5fa4

Browse files
Run linter and type checker in CI (#12)
* Run linter and type checker in CI * Use tox-gh to run multiple sessions
1 parent a295471 commit b7e5fa4

File tree

6 files changed

+148
-222
lines changed

6 files changed

+148
-222
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
uses: astral-sh/setup-uv@d9e0f98d3fc6adb07d1e3d37f3043649ddad06a1 # v6.5.0
5353

5454
- name: Run tests
55-
run: uvx --with tox-uv tox -e ${{ matrix.python-version }}
55+
run: uvx --with tox-gh --with tox-uv tox
5656

5757
- name: Upload coverage data
5858
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2

Makefile

Lines changed: 0 additions & 31 deletions
This file was deleted.

pyproject.toml

Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,25 @@ Repository = "https://github.com/python-backoff/backoff"
3939

4040
[dependency-groups]
4141
dev = [
42-
{ include-group = "tests" },
43-
"flake8>=4.0.1",
44-
"mypy>=0.942",
45-
"types-requests>=2.27.20",
42+
{ include-group = "lint" },
43+
{ include-group = "test" },
44+
{ include-group = "typing" },
45+
]
46+
lint = [
47+
"ruff>=0.12.9",
4648
]
47-
tests = [
49+
test = [
4850
"coverage>=7.2.7",
4951
"pytest>=7.1.2",
5052
"pytest-asyncio>=0.18.3",
5153
"requests>=2.26.0",
5254
"responses>=0.20.0",
5355
]
56+
typing = [
57+
{ include-group = "test" },
58+
"mypy>=0.942",
59+
"types-requests>=2.27.20",
60+
]
5461

5562
[tool.hatch.build.targets.sdist]
5663
include = ["backoff"]
@@ -60,8 +67,9 @@ include = ["backoff"]
6067

6168
[tool.tox]
6269
min_version = "4.22"
63-
requires = [ "tox", "tox-uv" ]
70+
requires = [ "tox", "tox-gh", "tox-uv" ]
6471
env_list = [
72+
"format",
6573
"3.7",
6674
"3.8",
6775
"3.9",
@@ -70,12 +78,16 @@ env_list = [
7078
"3.12",
7179
"3.13",
7280
"3.14",
81+
"lint",
82+
"typing",
7383
]
7484

7585
[tool.tox.env_run_base]
7686
description = "run unit tests"
77-
dependency_groups = [ "tests" ]
78-
commands = [ [ "coverage", "run", "-m", "pytest", { replace = "posargs", default = [ "tests" ], extend = true } ] ]
87+
dependency_groups = [ "test" ]
88+
commands = [
89+
[ "coverage", "run", "-m", "pytest", { replace = "posargs", default = [ "tests" ], extend = true } ],
90+
]
7991

8092
[tool.tox.env.coverage]
8193
description = "generate coverage report"
@@ -89,13 +101,51 @@ depends = [
89101
"3.13",
90102
"3.14",
91103
]
92-
dependency_groups = [ "tests" ]
104+
dependency_groups = [ "test" ]
93105
commands = [
94106
[ "coverage", "combine" ],
95107
[ "coverage", "report" ],
96108
[ "coverage", "xml" ],
97109
]
98110

111+
[tool.tox.env.format]
112+
description = "format code"
113+
dependency_groups = [ "lint" ]
114+
commands = [
115+
[ "ruff", "check", "--fix", { replace = "posargs", default = [ "backoff", "tests" ], extend = true } ],
116+
]
117+
118+
[tool.tox.env.lint]
119+
description = "lint code"
120+
dependency_groups = [ "lint" ]
121+
commands = [
122+
[ "ruff", "check", { replace = "posargs", default = [ "backoff", "tests" ], extend = true } ],
123+
]
124+
125+
[tool.tox.env.typing]
126+
description = "run type checking"
127+
dependency_groups = [ "typing" ]
128+
commands = [
129+
[
130+
"mypy",
131+
"--show-error-codes",
132+
{ replace = "posargs", default = [
133+
"backoff",
134+
"tests",
135+
], extend = true },
136+
],
137+
]
138+
139+
[tool.tox.gh.python]
140+
"3.14" = ["3.14", "lint", "typing"]
141+
"3.13" = ["3.13"]
142+
"3.12" = ["3.12"]
143+
"3.11" = ["3.11"]
144+
"3.10" = ["3.10"]
145+
"3.9" = ["3.9"]
146+
"3.8" = ["3.8"]
147+
"3.7" = ["3.7"]
148+
99149
[tool.pytest.ini_options]
100150
filterwarnings = [
101151
"error",

tests/test_backoff.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,9 @@ def __init__(self):
460460
loggers = [Logger() for _ in range(3)]
461461

462462
@backoff.on_predicate(backoff.constant,
463-
on_backoff=(l.backoffs.append for l in loggers),
464-
on_giveup=(l.giveups.append for l in loggers),
465-
on_success=(l.successes.append for l in loggers),
463+
on_backoff=(l.backoffs.append for l in loggers), # noqa: E741
464+
on_giveup=(l.giveups.append for l in loggers), # noqa: E741
465+
on_success=(l.successes.append for l in loggers), # noqa: E741
466466
max_tries=3,
467467
jitter=None,
468468
interval=0)

tests/test_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
from backoff.types import Details
44

55

6-
assert Details
6+
assert Details # type: ignore[truthy-function]

0 commit comments

Comments
 (0)