Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions {{cookiecutter.package_name}}/.github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get install graphviz
- name: Check RST conformity with doc8
run: uvx -p ${{ "{{" }} matrix.python-version {{ "}}" }} {{ cookiecutter.__runner_uv }} doc8
- name: Lint documentation
run: uvx -p ${{ "{{" }} matrix.python-version {{ "}}" }} {{ cookiecutter.__runner_uv }} docs-lint
- name: Check docstring coverage
run: uvx -p ${{ "{{" }} matrix.python-version {{ "}}" }} {{ cookiecutter.__runner_uv }} docstr-coverage
- name: Check documentation build with Sphinx
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.package_name}}/.readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ build:
- asdf install uv latest
- asdf global uv latest
- uv venv $READTHEDOCS_VIRTUALENV_PATH
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH uv pip install .[docs]
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH uv pip install --group docs .
- python -m sphinx -T -b html -d docs/_build/doctrees -D language=en docs/source $READTHEDOCS_OUTPUT/html
44 changes: 43 additions & 1 deletion {{cookiecutter.package_name}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ dependencies = [
"typing-extensions",
]

[project.optional-dependencies]
# see https://peps.python.org/pep-0735/ and https://docs.astral.sh/uv/concepts/dependencies/#dependency-groups
[dependency-groups]
tests = [
"pytest",
"coverage[toml]",
Expand All @@ -78,6 +79,47 @@ docs = [
# If you uncomment this, don't forget to do the same in docs/conf.py
# texext
]
lint = [
"ruff",
]
typing = [
"mypy",
"pydantic",
# You will probably have to add additional type stubs here, especially if you're using tox-uv
]
docs-lint = [
{ include-group = "docs" },
"doc8",
]
format-docs = [
{ include-group = "docs" },
"docstrfmt",
]
doctests = [
"xdoctest",
"pygments",
]
pyroma = [
"pyroma",
"pygments",
]
# follow https://github.com/astral-sh/uv/issues/6298 for switching to a uv-based version bump workflow
bump = [
"bump-my-version",
]
build = [
"uv",
"uv-build",
]
release = [
{ include-group = "build" },
"uv",
"keyring",
]

# see https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#dependencies-optional-dependencies
# [project.optional-dependencies]


# See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#urls
# and also https://packaging.python.org/en/latest/specifications/well-known-project-urls/
Expand Down
92 changes: 41 additions & 51 deletions {{cookiecutter.package_name}}/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ commands =
coverage run -p -m pytest --durations=20 {posargs:tests}
coverage combine
coverage xml
extras =
# See the [project.optional-dependencies] entry in pyproject.toml for "tests"
# See the [dependency-groups] entry in pyproject.toml for "tests"
dependency_groups =
tests

[testenv:coverage-clean]
Expand All @@ -53,10 +53,8 @@ description = Test that documentation examples run properly.
commands =
# note that the package name is required for discovery
xdoctest -m src/{{cookiecutter.package_name}}
deps =
xdoctest
pygments
# you might need to add additional deps/extras to make this work for your code
dependency_groups =
doctests

[testenv:treon]
description = Test that notebooks can run to completion
Expand All @@ -67,8 +65,8 @@ deps =

[testenv:format]
description = Format the code in a deterministic way using ruff. Note that ruff check should come before ruff format when using --fix (ref: https://github.com/astral-sh/ruff-pre-commit/blob/main/README.md)
deps =
ruff
dependency_groups =
lint
skip_install = true
commands =
ruff check --fix
Expand All @@ -78,8 +76,9 @@ commands =
description = Run documentation linters.
# note that this doesn't work with sphinx-click
# or any other extension that adds extra directives
deps =
docstrfmt
# See the [dependency-groups] entry in pyproject.toml for "rstfmt"
dependency_groups =
format-docs
skip_install = true
commands =
docstrfmt src/ tests/ docs/ --no-docstring-trailing-line
Expand All @@ -95,8 +94,8 @@ commands =
[testenv:lint]
description = Check code quality using ruff and other tools.
skip_install = true
deps =
ruff
dependency_groups =
lint
commands =
ruff check
ruff format --check
Expand All @@ -111,27 +110,22 @@ commands =
npx --yes prettier --check --prose-wrap always "**/*.md"

[testenv:pyroma]
deps =
pygments
dependency_groups =
pyroma
skip_install = true
commands = pyroma --min=10 .
description = Run the pyroma tool to check the package friendliness of the project.

[testenv:mypy]
description = Run the mypy tool to check static typing on the project. Installs the package to make sure all type stubs get recognized.
deps =
mypy
pydantic
# You will probably have to add additional type stubs here, especially if you're using tox-uv
dependency_groups =
typing
commands = mypy --ignore-missing-imports --strict src/ tests/

[testenv:doc8]
[testenv:docs-lint]
skip_install = true
deps =
doc8
extras =
docs
dependency_groups =
docs-lint
commands =
doc8 docs/source/
description = Run the doc8 tool to check the style of the RST files in the project docs.
Expand All @@ -146,8 +140,8 @@ commands =

[testenv:docs]
description = Build the documentation locally, allowing warnings.
extras =
# See the [project.optional-dependencies] entry in pyproject.toml for "docs"
dependency_groups =
# See the [dependency-groups] entry in pyproject.toml for "docs"
docs
# You might need to add additional extras if your documentation covers it
commands =
Expand All @@ -156,8 +150,8 @@ commands =
[testenv:docs-test]
description = Test building the documentation in an isolated environment. Warnings are considered as errors via -W.
changedir = docs
extras =
{[testenv:docs]extras}
dependency_groups =
{[testenv:docs]dependency_groups}
commands =
mkdir -p {envtmpdir}
cp -r source {envtmpdir}/source
Expand Down Expand Up @@ -185,22 +179,21 @@ description = Bump the version number
commands = bump-my-version bump {posargs}
skip_install = true
passenv = HOME
deps =
bump-my-version
dependency_groups =
bump

[testenv:bumpversion-release]
description = Remove the -dev tag from the version
commands = bump-my-version bump release --tag
skip_install = true
passenv = HOME
deps =
bump-my-version
dependency_groups =
bump

[testenv:build]
skip_install = true
deps =
uv
uv-build
dependency_groups =
build
commands =
uv build --sdist --wheel --no-build-isolation

Expand All @@ -222,20 +215,18 @@ commands =
[testenv:release]
description = Release the code to PyPI so users can pip install it, using credentials from keyring
skip_install = true
deps =
{[testenv:build]deps}
uv
keyring
dependency_groups =
release
commands =
{[testenv:build]commands}
uv publish --username __token__ --keyring-provider subprocess --publish-url https://upload.pypi.org/legacy/

[testenv:release-via-env]
description = Release the code to PyPI so users can pip install it, using credentials from the environment.
skip_install = true
deps =
{[testenv:build]deps}
uv
dependency_groups =
{[testenv:build]dependency_groups}
release
commands =
{[testenv:build]commands}
uv publish --publish-url https://upload.pypi.org/legacy/
Expand All @@ -250,9 +241,9 @@ description =
skip_install = true
passenv =
HOME
deps =
{[testenv:release]deps}
bump-my-version
dependency_groups =
bump
release
commands =
{[testenv:bumpversion-release]commands}
{[testenv:release]commands}
Expand Down Expand Up @@ -280,10 +271,8 @@ allowlist_externals =
[testenv:testrelease]
description = Release the code to the test PyPI site
skip_install = true
deps =
{[testenv:build]deps}
uv
keyring
dependency_groups =
release
commands =
{[testenv:build]commands}
uv publish --username __token__ --keyring-provider subprocess --publish-url https://test.pypi.org/legacy/
Expand All @@ -295,9 +284,10 @@ description =
skip_install = true
passenv =
HOME
deps =
{[testenv:testrelease]deps}
bump-my-version
dependency_groups =
{[testenv:testrelease]dependency_groups}
bump
release
commands =
{[testenv:bumpversion-release]commands}
{[testenv:testrelease]commands}
Expand Down