Skip to content

Commit ef58c22

Browse files
Run linter and type checker in CI
1 parent a295471 commit ef58c22

File tree

6 files changed

+170
-220
lines changed

6 files changed

+170
-220
lines changed

.github/workflows/ci.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,40 @@ jobs:
6161
name: coverage-data-${{ matrix.os }}-py${{ matrix.python-version }}
6262
path: ".coverage.*"
6363

64+
lint:
65+
name: Lint
66+
runs-on: ubuntu-latest
67+
needs: test
68+
steps:
69+
- name: Checkout code
70+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
71+
72+
- name: Set up Python
73+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
74+
75+
- name: Install uv
76+
uses: astral-sh/setup-uv@d9e0f98d3fc6adb07d1e3d37f3043649ddad06a1 # v6.5.0
77+
78+
- name: Run lint
79+
run: uvx --with tox-uv tox -e lint
80+
81+
typing:
82+
name: Type checks
83+
runs-on: ubuntu-latest
84+
needs: test
85+
steps:
86+
- name: Checkout code
87+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
88+
89+
- name: Set up Python
90+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
91+
92+
- name: Install uv
93+
uses: astral-sh/setup-uv@d9e0f98d3fc6adb07d1e3d37f3043649ddad06a1 # v6.5.0
94+
95+
- name: Run type checks
96+
run: uvx --with tox-uv tox -e typing
97+
6498
coverage:
6599
name: Coverage
66100
runs-on: ubuntu-latest

Makefile

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

pyproject.toml

Lines changed: 48 additions & 8 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"]
@@ -62,6 +69,7 @@ include = ["backoff"]
6269
min_version = "4.22"
6370
requires = [ "tox", "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,41 @@ 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+
99139
[tool.pytest.ini_options]
100140
filterwarnings = [
101141
"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)