Skip to content

Commit a786ea7

Browse files
authored
Merge stable into main (#2922)
2 parents af73ce4 + 2e1c742 commit a786ea7

21 files changed

Lines changed: 1380 additions & 499 deletions

.github/workflows/lock.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
permissions:
1111
issues: write
1212
pull-requests: write
13+
discussions: write
1314
concurrency:
1415
group: lock
1516
jobs:

.github/workflows/pre-commit.yaml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,19 @@ jobs:
77
main:
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
11-
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
12-
with:
13-
python-version: 3.x
14-
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
15-
- uses: pre-commit-ci/lite-action@5d6cc0eb514c891a40562a58a8e71576c5c7fb43 # v1.1.0
16-
if: ${{ !cancelled() }}
10+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
11+
- uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1
12+
with:
13+
enable-cache: true
14+
prune-cache: false
15+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
16+
id: setup-python
17+
with:
18+
python-version-file: pyproject.toml
19+
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
20+
with:
21+
path: ~/.cache/pre-commit
22+
key: pre-commit|${{ hashFiles('pyproject.toml', '.pre-commit-config.yaml') }}
23+
- run: uv run --locked --group pre-commit pre-commit run --show-diff-on-failure --color=always --all-files
24+
- uses: pre-commit-ci/lite-action@5d6cc0eb514c891a40562a58a8e71576c5c7fb43 # v1.1.0
25+
if: ${{ !cancelled() }}

.github/workflows/publish.yaml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
name: Publish
22
on:
33
push:
4-
tags:
5-
- '*'
4+
tags: ['*']
65
jobs:
76
build:
87
runs-on: ubuntu-latest
98
outputs:
109
hash: ${{ steps.hash.outputs.hash }}
1110
steps:
1211
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
12+
- uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1
13+
with:
14+
enable-cache: true
15+
prune-cache: false
1316
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
1417
with:
15-
python-version: '3.x'
16-
cache: pip
17-
cache-dependency-path: requirements*/*.txt
18-
- run: pip install -r requirements/build.txt
19-
# Use the commit date instead of the current date during the build.
18+
python-version-file: pyproject.toml
2019
- run: echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
21-
- run: python -m build
22-
# Generate hashes used for provenance.
20+
- run: uv build
2321
- name: generate hash
2422
id: hash
2523
run: cd dist && echo "hash=$(sha256sum * | base64 -w0)" >> $GITHUB_OUTPUT
@@ -37,8 +35,6 @@ jobs:
3735
with:
3836
base64-subjects: ${{ needs.build.outputs.hash }}
3937
create-release:
40-
# Upload the sdist, wheels, and provenance to a GitHub release. They remain
41-
# available as build artifacts for a while as well.
4238
needs: [provenance]
4339
runs-on: ubuntu-latest
4440
permissions:
@@ -54,8 +50,6 @@ jobs:
5450
GH_TOKEN: ${{ github.token }}
5551
publish-pypi:
5652
needs: [provenance]
57-
# Wait for approval before attempting to upload to PyPI. This allows reviewing the
58-
# files in the draft release.
5953
environment:
6054
name: publish
6155
url: https://pypi.org/project/click/${{ github.ref_name }}

.github/workflows/tests.yaml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name: Tests
22
on:
3+
pull_request:
4+
paths-ignore: ['docs/**', 'README.md']
35
push:
46
branches: [main, stable]
5-
paths-ignore: ['docs/**', '*.md', '*.rst']
6-
pull_request:
7-
paths-ignore: [ 'docs/**', '*.md', '*.rst' ]
7+
paths-ignore: ['docs/**', 'README.md']
88
jobs:
99
tests:
1010
name: ${{ matrix.name || matrix.python }}
@@ -14,35 +14,36 @@ jobs:
1414
matrix:
1515
include:
1616
- {python: '3.13'}
17+
- {name: Windows, python: '3.13', os: windows-latest}
18+
- {name: Mac, python: '3.13', os: macos-latest}
1719
- {python: '3.12'}
18-
- {name: Windows, python: '3.12', os: windows-latest}
19-
- {name: Mac, python: '3.12', os: macos-latest}
2020
- {python: '3.11'}
2121
- {python: '3.10'}
22-
- {name: PyPy, python: 'pypy-3.11', tox: pypy311}
22+
- {name: PyPy, python: 'pypy-3.11', tox: pypy3.11}
2323
steps:
2424
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
25+
- uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1
26+
with:
27+
enable-cache: true
28+
prune-cache: false
2529
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
2630
with:
2731
python-version: ${{ matrix.python }}
28-
allow-prereleases: true
29-
cache: pip
30-
cache-dependency-path: requirements*/*.txt
31-
- run: pip install tox
32-
- run: tox run -e ${{ matrix.tox || format('py{0}', matrix.python) }}
32+
- run: uv run --locked tox run -e ${{ matrix.tox || format('py{0}', matrix.python) }}
3333
typing:
3434
runs-on: ubuntu-latest
3535
steps:
3636
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
37+
- uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1
38+
with:
39+
enable-cache: true
40+
prune-cache: false
3741
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
3842
with:
39-
python-version: '3.x'
40-
cache: pip
41-
cache-dependency-path: requirements*/*.txt
43+
python-version-file: pyproject.toml
4244
- name: cache mypy
4345
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
4446
with:
4547
path: ./.mypy_cache
4648
key: mypy|${{ hashFiles('pyproject.toml') }}
47-
- run: pip install tox
48-
- run: tox run -e typing
49+
- run: uv run --locked tox run -e typing

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
.idea/
22
.vscode/
3-
.venv*/
4-
venv*/
5-
.env*/
6-
env*/
73
__pycache__/
84
dist/
95
.coverage*

.pre-commit-config.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.11.9
3+
rev: 24e02b24b8ab2b7c76225602d13fa60e12d114e6 # frozen: v0.11.9
44
hooks:
55
- id: ruff
66
- id: ruff-format
7+
- repo: https://github.com/astral-sh/uv-pre-commit
8+
rev: 14ac15b122e538e407d036ff45e3895b7cf4a2bf # frozen: 0.7.3
9+
hooks:
10+
- id: uv-lock
711
- repo: https://github.com/pre-commit/pre-commit-hooks
8-
rev: v5.0.0
12+
rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0
913
hooks:
1014
- id: check-merge-conflict
1115
- id: debug-statements

.readthedocs.yaml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
version: 2
22
build:
3-
os: ubuntu-22.04
3+
os: ubuntu-24.04
44
tools:
5-
python: '3.12'
6-
python:
7-
install:
8-
- requirements: requirements/docs.txt
9-
- method: pip
10-
path: .
11-
sphinx:
12-
builder: dirhtml
13-
configuration: docs/conf.py
14-
fail_on_warning: true
5+
python: '3.13'
6+
commands:
7+
- asdf plugin add uv
8+
- asdf install uv latest
9+
- asdf global uv latest
10+
- uv run --group docs sphinx-build -W -b dirhtml docs $READTHEDOCS_OUTPUT/html

pyproject.toml

Lines changed: 114 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,42 @@ dependencies = [
2121
[project.urls]
2222
Donate = "https://palletsprojects.com/donate"
2323
Documentation = "https://click.palletsprojects.com/"
24-
Changes = "https://click.palletsprojects.com/changes/"
24+
Changes = "https://click.palletsprojects.com/page/changes/"
2525
Source = "https://github.com/pallets/click/"
2626
Chat = "https://discord.gg/pallets"
2727

28+
[dependency-groups]
29+
dev = [
30+
"ruff",
31+
"tox",
32+
"tox-uv",
33+
]
34+
docs = [
35+
"myst-parser",
36+
"pallets-sphinx-themes",
37+
"sphinx",
38+
"sphinx-tabs",
39+
"sphinxcontrib-log-cabinet",
40+
]
41+
docs-auto = [
42+
"sphinx-autobuild",
43+
]
44+
gha-update = [
45+
"gha-update ; python_full_version >= '3.12'",
46+
]
47+
pre-commit = [
48+
"pre-commit",
49+
"pre-commit-uv",
50+
]
51+
tests = [
52+
"pytest",
53+
]
54+
typing = [
55+
"mypy",
56+
"pyright",
57+
"pytest",
58+
]
59+
2860
[build-system]
2961
requires = ["flit_core<4"]
3062
build-backend = "flit_core.buildapi"
@@ -35,15 +67,17 @@ name = "click"
3567
[tool.flit.sdist]
3668
include = [
3769
"docs/",
38-
"requirements/",
3970
"tests/",
4071
"CHANGES.rst",
41-
"tox.ini",
72+
"uv.lock"
4273
]
4374
exclude = [
4475
"docs/_build/",
4576
]
4677

78+
[tool.uv]
79+
default-groups = ["dev", "pre-commit", "tests", "typing"]
80+
4781
[tool.pytest.ini_options]
4882
testpaths = ["tests"]
4983
filterwarnings = [
@@ -57,9 +91,16 @@ source = ["click", "tests"]
5791
[tool.coverage.paths]
5892
source = ["src", "*/site-packages"]
5993

94+
[tool.coverage.report]
95+
exclude_also = [
96+
"if t.TYPE_CHECKING",
97+
"raise NotImplementedError",
98+
": \\.{3}",
99+
]
100+
60101
[tool.mypy]
61102
python_version = "3.10"
62-
files = ["src/click", "tests/typing"]
103+
files = ["src", "tests/typing"]
63104
show_error_codes = true
64105
pretty = true
65106
strict = true
@@ -72,7 +113,7 @@ ignore_missing_imports = true
72113

73114
[tool.pyright]
74115
pythonVersion = "3.10"
75-
include = ["src/click", "tests/typing"]
116+
include = ["src", "tests/typing"]
76117
typeCheckingMode = "basic"
77118

78119
[tool.ruff]
@@ -92,7 +133,7 @@ select = [
92133
"W", # pycodestyle warning
93134
]
94135
ignore = [
95-
"UP038", # keep isinstance tuples
136+
"UP038", # keep isinstance tuple
96137
]
97138

98139
[tool.ruff.lint.isort]
@@ -103,3 +144,70 @@ order-by-type = false
103144
tag-only = [
104145
"slsa-framework/slsa-github-generator",
105146
]
147+
148+
[tool.tox]
149+
env_list = [
150+
"py3.13", "py3.12", "py3.11", "py3.10",
151+
"pypy3.11",
152+
"style",
153+
"typing",
154+
"docs",
155+
]
156+
157+
[tool.tox.env_run_base]
158+
description = "pytest on latest dependency versions"
159+
runner = "uv-venv-lock-runner"
160+
package = "wheel"
161+
wheel_build_env = ".pkg"
162+
constrain_package_deps = true
163+
use_frozen_constraints = true
164+
dependency_groups = ["tests"]
165+
commands = [[
166+
"pytest", "-v", "--tb=short", "--basetemp={env_tmp_dir}",
167+
{replace = "posargs", default = [], extend = true},
168+
]]
169+
170+
[tool.tox.env.style]
171+
description = "run all pre-commit hooks on all files"
172+
dependency_groups = ["pre-commit"]
173+
skip_install = true
174+
commands = [["pre-commit", "run", "--all-files"]]
175+
176+
[tool.tox.env.typing]
177+
description = "run static type checkers"
178+
dependency_groups = ["typing"]
179+
commands = [
180+
["mypy"],
181+
]
182+
183+
[tool.tox.env.docs]
184+
description = "build docs"
185+
dependency_groups = ["docs"]
186+
commands = [["sphinx-build", "-E", "-W", "-b", "dirhtml", "docs", "docs/_build/dirhtml"]]
187+
188+
[tool.tox.env.docs-auto]
189+
description = "continuously rebuild docs and start a local server"
190+
dependency_groups = ["docs", "docs-auto"]
191+
commands = [["sphinx-autobuild", "-W", "-b", "dirhtml", "--watch", "src", "docs", "docs/_build/dirhtml"]]
192+
193+
[tool.tox.env.update-actions]
194+
description = "update GitHub Actions pins"
195+
labels = ["update"]
196+
dependency_groups = ["gha-update"]
197+
skip_install = true
198+
commands = [["gha-update"]]
199+
200+
[tool.tox.env.update-pre_commit]
201+
description = "update pre-commit pins"
202+
labels = ["update"]
203+
dependency_groups = ["pre-commit"]
204+
skip_install = true
205+
commands = [["pre-commit", "autoupdate", "--freeze", "-j4"]]
206+
207+
[tool.tox.env.update-requirements]
208+
description = "update uv lock"
209+
labels = ["update"]
210+
dependency_groups = []
211+
no_default_groups = true
212+
skip_install = true
213+
commands = [["uv", "lock", {replace = "posargs", default = ["-U"], extend = true}]]

requirements/build.in

Lines changed: 0 additions & 1 deletion
This file was deleted.

requirements/build.txt

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

0 commit comments

Comments
 (0)