Skip to content

Commit e3c8a77

Browse files
committed
✨ Use uv in still more places
1 parent a527164 commit e3c8a77

12 files changed

Lines changed: 76 additions & 75 deletions

File tree

.pre-commit-config.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,20 @@ repos:
1919
- id: end-of-file-fixer
2020
- id: trailing-whitespace
2121
- repo: https://github.com/python-jsonschema/check-jsonschema
22-
rev: 0.31.1
22+
rev: 0.33.2
2323
hooks:
2424
- id: check-dependabot
2525
- id: check-github-workflows
2626
- repo: https://github.com/charliermarsh/ruff-pre-commit
27-
rev: v0.9.6
27+
rev: v0.12.3
2828
hooks:
29-
- id: ruff
29+
- id: ruff-check
3030
args:
3131
- --fix
32+
- --unsafe-fixes
33+
- --show-fixes
3234
- id: ruff-format
33-
- repo: https://github.com/pre-commit/mirrors-prettier
34-
rev: v4.0.0-alpha.8
35+
- repo: https://github.com/rbubley/mirrors-prettier
36+
rev: v3.6.2
3537
hooks:
3638
- id: prettier
37-
additional_dependencies: ["prettier@3.1.0"]

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ cookiecutter gh:sgraaf/cookiecutter-python-cli-app
2121

2222
<!-- TODO: mention optional use of rich, choice of licenses, git and venv initialization -->
2323

24-
- Beautiful and powerful command-line interfaces with [Click](https://click.palletsprojects.com/)
25-
- Linting with autofix (i.e. removing unused imports, formatting and Python syntax upgrades) with [ruff](https://beta.ruff.rs/docs/)
26-
- Code formatting with [ruff](https://beta.ruff.rs/docs/) and [Prettier](https://prettier.io/)
27-
- Static type-checking with [mypy](http://www.mypy-lang.org/)
28-
- Checks and fixes before every commit with [pre-commit](https://pre-commit.com/)
29-
- Testing with [pytest](https://docs.pytest.org/en/stable/index.html)
30-
- Project automation with [Nox](https://nox.thea.codes/en/stable/)
31-
- Extremely fast Python package and project management with [uv](https://docs.astral.sh/uv/)
32-
- Continuous Integration with [GitHub Actions](https://github.com/features/actions) and [pre-commit.ci](https://pre-commit.ci/)
33-
- Automated version updates for GitHub Actions with [Dependabot](https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot)
34-
- Documentation with [Sphinx](https://www.sphinx-doc.org/en/master/), [MyST](https://myst-parser.readthedocs.io/en/latest/), and [Read the Docs](https://readthedocs.org/) using the [Furo](https://pradyunsg.me/furo/) theme
35-
- Automated release builds and uploads to [PyPI](https://pypi.org/)
24+
- Beautiful and powerful command-line interfaces with [Click](https://click.palletsprojects.com/)
25+
- Linting with autofix (i.e. removing unused imports, formatting and Python syntax upgrades) with [ruff](https://beta.ruff.rs/docs/)
26+
- Code formatting with [ruff](https://beta.ruff.rs/docs/) and [Prettier](https://prettier.io/)
27+
- Static type-checking with [mypy](http://www.mypy-lang.org/)
28+
- Checks and fixes before every commit with [pre-commit](https://pre-commit.com/)
29+
- Testing with [pytest](https://docs.pytest.org/en/stable/index.html)
30+
- Project automation with [Nox](https://nox.thea.codes/en/stable/)
31+
- Extremely fast Python package and project management with [uv](https://docs.astral.sh/uv/)
32+
- Continuous Integration with [GitHub Actions](https://github.com/features/actions) and [pre-commit.ci](https://pre-commit.ci/)
33+
- Automated version updates for GitHub Actions with [Dependabot](https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot)
34+
- Documentation with [Sphinx](https://www.sphinx-doc.org/en/master/), [MyST](https://myst-parser.readthedocs.io/en/latest/), and [Read the Docs](https://readthedocs.org/) using the [Furo](https://pradyunsg.me/furo/) theme
35+
- Automated release builds and uploads to [PyPI](https://pypi.org/)
3636

3737
This template supports Python 3.9, 3.10, 3.11, 3.12 and 3.13.

cookiecutter.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"author": "",
88
"email": "",
99
"github_username": "",
10-
"version": "0.1.0",
10+
"version": "{% now 'utc', '%Y' %}.1.0",
1111
"copyright_year": "{% now 'utc', '%Y' %}",
1212
"license": [
1313
"mit",

{{ cookiecutter.app_name }}/.pre-commit-config.yaml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,33 @@ repos:
2121
- id: end-of-file-fixer
2222
- id: trailing-whitespace
2323
- repo: https://github.com/abravalheri/validate-pyproject
24-
rev: v0.23
24+
rev: v0.24.1
2525
hooks:
2626
- id: validate-pyproject
2727
- repo: https://github.com/python-jsonschema/check-jsonschema
28-
rev: 0.31.1
28+
rev: 0.33.2
2929
hooks:
3030
- id: check-dependabot
3131
- id: check-github-workflows
3232
- id: check-readthedocs
3333
- repo: https://github.com/charliermarsh/ruff-pre-commit
34-
rev: v0.9.6
34+
rev: v0.12.3
3535
hooks:
36-
- id: ruff
36+
- id: ruff-check
3737
args:
3838
- --fix
3939
- --unsafe-fixes
4040
- --show-fixes
4141
- id: ruff-format
4242
- repo: https://github.com/pre-commit/mirrors-mypy
43-
rev: v1.15.0
43+
rev: v1.16.1
4444
hooks:
4545
- id: mypy
4646
- repo: https://github.com/codespell-project/codespell
4747
rev: v2.4.1
4848
hooks:
4949
- id: codespell
50-
- repo: https://github.com/pre-commit/mirrors-prettier
51-
rev: v4.0.0-alpha.8
50+
- repo: https://github.com/rbubley/mirrors-prettier
51+
rev: v3.6.2
5252
hooks:
5353
- id: prettier
54-
additional_dependencies: ["prettier@3.1.0"]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Calendar Versioning](https://calver.org/).
6+
7+
The **first number** of the version is the year.
8+
The **second number** is incremented with each release, starting at 1 for each year.
9+
The **third number** is for emergencies when we need to start branches for older releases.
10+
11+
## Unreleased
12+
13+
### Added
14+
15+
- Initial release of {{ cookiecutter.friendly_name }}
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# Changelog
2-
3-
## {{ cookiecutter.version }} ({% now 'utc', '%Y-%m-%d' %})
4-
5-
### Changes
6-
7-
- Initial release of {{ cookiecutter.friendly_name }}
1+
```{include} ../CHANGELOG.md
2+
:relative-docs: docs/
3+
```

{{ cookiecutter.app_name }}/docs/conf.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
"""Sphinx configuration."""
22

3-
from __future__ import annotations
4-
5-
import sys
6-
from pathlib import Path
3+
from importlib import metadata
74
from typing import Any
85

9-
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
10-
import {{ cookiecutter.package_name }}
11-
126
# -- Project information -----------------------------------------------------
137
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
148

159
project = "{{ cookiecutter.friendly_name }}"
1610
copyright = "{{ cookiecutter.copyright_year }}, {{ cookiecutter.author }}"
1711
author = "{{ cookiecutter.author }}"
18-
release = {{ cookiecutter.package_name }}.__version__
12+
release = metadata.version("{{ cookiecutter.package_name }}")
13+
version = release.rsplit(".", 1)[0]
1914

2015
# -- General configuration ---------------------------------------------------
2116
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

{{ cookiecutter.app_name }}/noxfile.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import nox
55

66
nox.options.sessions = ["pre-commit", "tests", "docs"]
7-
nox.options.default_venv_backend = "uv|virtualenv"
8-
nox.options.reuse_existing_virtualenvs = True
7+
nox.options.default_venv_backend = "uv"
98
nox.options.error_on_external_run = True
9+
nox.needs_version = ">=2025.5.1"
1010

1111
ALL_PYTHON_VERSIONS = [
1212
# [[[cog
@@ -52,18 +52,22 @@ def dev(session: nox.Session) -> None:
5252
"--seed",
5353
"--prompt",
5454
"{{ cookiecutter.app_name }}",
55+
"--python",
56+
ALL_PYTHON_VERSIONS[0],
5557
str(VENV_DIR),
5658
external=True,
5759
silent=True,
5860
)
5961

60-
# install the current package in editable mode (along with its dependencies)
62+
# install the current package in editable mode (along with development dependencies)
6163
session.run(
6264
"uv",
6365
"pip",
6466
"install",
6567
"--editable",
66-
".[dev]",
68+
".",
69+
"--group",
70+
"dev",
6771
env={"VIRTUAL_ENV": str(VENV_DIR)},
6872
external=True,
6973
silent=True,
@@ -97,22 +101,23 @@ def pre_commit(session: nox.Session) -> None:
97101
@nox.session(python=ALL_PYTHON_VERSIONS, tags=["tests"])
98102
def tests(session: nox.Session) -> None:
99103
"""Run tests."""
100-
session.install(".[tests]")
104+
session.install(".", "--group", "tests")
101105
session.run("pytest", *session.posargs)
102106

103107

104108
@nox.session(python=DOCS_PYTHON_VERSION)
105109
def docs(session: nox.Session) -> None:
106110
"""Builds and tests the docs."""
107-
session.install(".[docs]")
111+
args = session.posargs or ["html", "doctest"]
112+
113+
session.install(".", "--group", "docs")
108114

109115
# create a temporary directory to store the doctrees
110116
tmp_dir = session.create_tmp()
111117

112-
for builder in ["html", "doctest"]:
113-
# fmt: off
118+
for builder in args:
114119
session.run(
115-
"python", "-m", "sphinx",
120+
"python", "-Im", "sphinx",
116121
"-T", # display full traceback when an exception occurs
117122
"-E", # rebuild the environment
118123
"-W", "--keep-going", # turn warnings into errors, but continue to the end of the build
@@ -121,9 +126,7 @@ def docs(session: nox.Session) -> None:
121126
"-D", "language=en", # set language
122127
str(DOCS_SOURCE_DIR), # source directory
123128
str(DOCS_BUILD_DIR), # output directory
124-
)
125-
# fmt: on
126-
session.run("python", "-m", "doctest", "README.md")
129+
) # fmt: skip
127130

128131

129132
@nox.session(name="docs-live", python=DOCS_PYTHON_VERSION)
@@ -137,8 +140,7 @@ def docs_live(session: nox.Session) -> None:
137140
]
138141
# fmt: on
139142

140-
session.install(".[docs]")
141-
session.install("sphinx-autobuild")
143+
session.install(".", "--group", "docs", "sphinx-autobuild")
142144

143145
session.run("sphinx-autobuild", *args)
144146

{{ cookiecutter.app_name }}/pyproject.toml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
[build-system]
2-
requires = ["setuptools"]
3-
build-backend = "setuptools.build_meta"
2+
requires = ["uv-build"]
3+
build-backend = "uv_build"
44

55
[project]
66
name = "{{ cookiecutter.app_name }}"
7+
version = "{{ cookiecutter.version }}"
78
description = "{{ cookiecutter.short_description }}"
89
authors = [{name = "{{ cookiecutter.author }}", email = "{{ cookiecutter.email }}"}]
910
readme = "README.md"
@@ -45,22 +46,21 @@ dependencies = [
4546
"rich_click",
4647
{%- endif %}
4748
]
48-
dynamic = ["version"]
4949

50-
[project.optional-dependencies]
50+
[dependency-groups]
5151
tests = [
5252
"pytest",
5353
]
5454
docs = [
5555
"furo",
5656
"myst-parser",
5757
"sphinx",
58-
"sphinx-autobuild",
5958
"sphinx-copybutton",
6059
"sphinxext-opengraph",
6160
]
6261
dev = [
63-
"{{ cookiecutter.app_name }}[tests,docs]",
62+
{ include-group = "tests" },
63+
{ include-group = "docs" },
6464
]
6565

6666
[project.urls]
@@ -70,10 +70,7 @@ Changelog = "https://{{ cookiecutter.app_name }}.readthedocs.io/en/stable/change
7070
"Issue Tracker" = "https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.app_name }}/issues"
7171

7272
[project.scripts]
73-
{{ cookiecutter.app_name }} = "{{ cookiecutter.package_name }}.cli:cli"
74-
75-
[tool.setuptools.dynamic]
76-
version = {attr = "{{ cookiecutter.package_name }}.__version__"}
73+
{{ cookiecutter.app_name }} = "{{ cookiecutter.package_name }}.__main__:cli"
7774

7875
[tool.ruff]
7976
lint.select = ["ALL"]
@@ -88,7 +85,6 @@ lint.ignore = [
8885
"INP", # flake8-no-pep420
8986
]
9087
src = ["src", "tests", "docs"]
91-
target-version = "py39" # the minimum Python version supported, used by pyupgrade
9288

9389
[tool.ruff.lint.per-file-ignores]
9490
"__init__.py" = [
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
"""{{ cookiecutter.short_description }}"""
2-
3-
__version__ = "{{ cookiecutter.version }}"

0 commit comments

Comments
 (0)