Skip to content

Commit adafd3d

Browse files
committed
Use a fully locked test environment & dependency groups
1 parent 9c3b379 commit adafd3d

File tree

4 files changed

+1705
-35
lines changed

4 files changed

+1705
-35
lines changed

.pre-commit-config.yaml

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@ ci:
44

55
repos:
66
- repo: https://github.com/astral-sh/ruff-pre-commit
7-
rev: v0.6.9
7+
rev: v0.7.2
88
hooks:
99
- id: ruff
1010
args: [--fix, --exit-non-zero-on-fix]
1111
- id: ruff-format
1212

13+
- repo: https://github.com/astral-sh/uv-pre-commit
14+
rev: 0.4.29
15+
hooks:
16+
- id: uv-lock
17+
1318
- repo: https://github.com/econchick/interrogate
1419
rev: 1.7.0
1520
hooks:

pyproject.toml

+23-17
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,42 @@ classifiers = [
2828
dependencies = []
2929
dynamic = ["version", "readme"]
3030

31-
[project.optional-dependencies]
31+
[project.urls]
32+
Documentation = "https://www.attrs.org/"
33+
Changelog = "https://www.attrs.org/en/stable/changelog.html"
34+
GitHub = "https://github.com/python-attrs/attrs"
35+
Funding = "https://github.com/sponsors/hynek"
36+
Tidelift = "https://tidelift.com/subscription/pkg/pypi-attrs?utm_source=pypi-attrs&utm_medium=pypi"
37+
38+
39+
[dependency-groups]
3240
tests-mypy = [
3341
'pytest-mypy-plugins; platform_python_implementation == "CPython" and python_version >= "3.9"',
3442
# Since the mypy error messages keep changing, we have to keep updating this
3543
# pin.
3644
'mypy>=1.11.1; platform_python_implementation == "CPython" and python_version >= "3.9"',
3745
]
3846
tests = [
47+
{ include-group = "tests-mypy" },
3948
# For regression test to ensure cloudpickle compat doesn't break.
4049
'cloudpickle; platform_python_implementation == "CPython"',
4150
"hypothesis",
4251
"pympler",
4352
# 4.3.0 dropped last use of `convert`
4453
"pytest>=4.3.0",
4554
"pytest-xdist[psutil]",
46-
"attrs[tests-mypy]",
4755
]
4856
cov = [
49-
"attrs[tests]",
57+
{ include-group = "tests" },
5058
# Ensure coverage is new enough for `source_pkgs`.
5159
"coverage[toml]>=5.3",
5260
]
53-
benchmark = ["pytest-codspeed", "pytest-xdist[psutil]", "attrs[tests]"]
61+
pyright = ["pyright<1.1.380", { include-group = "tests" }]
62+
benchmark = [
63+
{ include-group = "tests" },
64+
"pytest-codspeed",
65+
"pytest-xdist[psutil]",
66+
]
5467
docs = [
5568
"cogapp",
5669
"furo",
@@ -59,17 +72,10 @@ docs = [
5972
"sphinx-notfound-page",
6073
"sphinxcontrib-towncrier",
6174
# See https://github.com/sphinx-contrib/sphinxcontrib-towncrier/issues/92
62-
# Pin also present in tox.ini
6375
"towncrier<24.7",
6476
]
65-
dev = ["attrs[tests]", "pre-commit-uv"]
66-
67-
[project.urls]
68-
Documentation = "https://www.attrs.org/"
69-
Changelog = "https://www.attrs.org/en/stable/changelog.html"
70-
GitHub = "https://github.com/python-attrs/attrs"
71-
Funding = "https://github.com/sponsors/hynek"
72-
Tidelift = "https://tidelift.com/subscription/pkg/pypi-attrs?utm_source=pypi-attrs&utm_medium=pypi"
77+
docs-watch = [{ include-group = "docs" }, "watchfiles"]
78+
dev = [{ include-group = "tests" }]
7379

7480

7581
[tool.hatch.version]
@@ -244,10 +250,10 @@ ignore = [
244250
"src/*/*.pyi" = ["ALL"] # TODO
245251
"tests/test_annotations.py" = ["FA100"]
246252
"tests/typing_example.py" = [
247-
"E741", # ambiguous variable names don't matter in type checks
248-
"B018", # useless expressions aren't useless in type checks
249-
"B015", # pointless comparison in type checks aren't pointless
250-
"UP037", # we test some older syntaxes on purpose
253+
"E741", # ambiguous variable names don't matter in type checks
254+
"B018", # useless expressions aren't useless in type checks
255+
"B015", # pointless comparison in type checks aren't pointless
256+
"UP037", # we test some older syntaxes on purpose
251257
]
252258

253259
[tool.ruff.lint.isort]

tox.ini

+18-17
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ pass_env = SETUPTOOLS_SCM_PRETEND_VERSION
1616

1717

1818
[testenv]
19+
runner = uv-venv-lock-runner
1920
package = wheel
2021
wheel_build_env = .pkg
21-
extras =
22+
dependency_groups =
2223
tests: tests
2324
mypy: tests-mypy
2425
commands =
@@ -27,7 +28,7 @@ commands =
2728
mypy: mypy src/attrs/__init__.pyi src/attr/__init__.pyi src/attr/_typing_compat.pyi src/attr/_version_info.pyi src/attr/converters.pyi src/attr/exceptions.pyi src/attr/filters.pyi src/attr/setters.pyi src/attr/validators.pyi
2829

2930
[testenv:py3{8,10,13}-tests]
30-
extras = cov
31+
dependency_groups = cov
3132
# Python 3.6+ has a number of compile-time warnings on invalid string escapes.
3233
# PYTHONWARNINGS=d makes them visible during the tox run.
3334
set_env =
@@ -40,17 +41,17 @@ commands = coverage run -m pytest {posargs:-n auto --dist loadfile}
4041
[testenv:coverage-report]
4142
# Keep base_python in-sync with .python-version-default
4243
base_python = py313
43-
# Keep depends in-sync with testenv above that has cov extra.
44+
# Keep depends in-sync with testenv above that has the cov dependency group.
4445
depends = py3{8,10,13}-tests
4546
skip_install = true
46-
deps = coverage[toml]>=5.3
47+
dependency_groups = cov
4748
commands =
4849
coverage combine
4950
coverage report
5051

5152

5253
[testenv:codspeed]
53-
extras = benchmark
54+
dependency_groups = benchmark
5455
pass_env =
5556
CODSPEED_TOKEN
5657
CODSPEED_ENV
@@ -61,65 +62,65 @@ commands = pytest --codspeed -n auto bench/test_benchmarks.py
6162

6263

6364
[testenv:docs]
65+
runner = uv-venv-lock-runner
6466
# Keep base_python in-sync with ci.yml/docs and .readthedocs.yaml.
6567
base_python = py312
66-
extras = docs
68+
dependency_groups = docs
6769
commands =
6870
sphinx-build -n -T -W -b html -d {envtmpdir}/doctrees docs docs/_build/html
6971
sphinx-build -n -T -W -b doctest -d {envtmpdir}/doctrees docs docs/_build/html
7072

7173

7274
[testenv:docs-watch]
73-
package = editable
7475
base_python = {[testenv:docs]base_python}
75-
extras = {[testenv:docs]extras}
76-
deps = watchfiles
76+
dependency_groups = docs-watch
7777
commands =
7878
watchfiles \
7979
--ignore-paths docs/_build/ \
8080
'sphinx-build -W -n --jobs auto -b html -d {envtmpdir}/doctrees docs docs/_build/html' \
81+
README.md \
8182
src \
8283
docs
8384

8485

8586
[testenv:docs-linkcheck]
86-
package = editable
8787
base_python = {[testenv:docs]base_python}
88-
extras = {[testenv:docs]extras}
88+
dependency_groups = {[testenv:docs]dependency_groups}
8989
commands = sphinx-build -W -b linkcheck -d {envtmpdir}/doctrees docs docs/_build/html
9090

9191

9292
[testenv:docs-sponsors]
93+
runner = uv-venv-runner
94+
skip_install = true
9395
description = Ensure sponsor logos are up to date.
9496
deps = cogapp
9597
commands = cog -rP README.md docs/index.md
9698

9799

98100
[testenv:pre-commit]
101+
runner = uv-venv-runner
99102
skip_install = true
100103
deps = pre-commit-uv
101104
commands = pre-commit run --all-files
102105

103106

104107
[testenv:changelog]
105-
# See https://github.com/sphinx-contrib/sphinxcontrib-towncrier/issues/92
106-
# Pin also present in pyproject.toml
107-
deps = towncrier<24.7
108+
dependency_groups = docs
108109
skip_install = true
109110
commands =
110111
towncrier --version
111112
towncrier build --version main --draft
112113

113114

114115
[testenv:pyright]
115-
extras = tests
116-
deps = pyright<1.1.380
116+
dependency_groups = pyright
117117
commands = pytest tests/test_pyright.py -vv
118118

119119

120120
[testenv:docset]
121+
runner = uv-venv-runner
121122
deps = doc2dash
122-
extras = docs
123+
dependency_groups = docs
123124
allowlist_externals =
124125
rm
125126
cp

0 commit comments

Comments
 (0)