Skip to content

Commit c156ea3

Browse files
authored
FIX: define dev dependencies as dependency groups (#299)
* DX: run `pyright` in `tox -e sty` job * FIX: remove `pre-commit-uv` and `tox` from environment * MAINT: address Ruff issues * MAINT: update lock files
1 parent f610cf9 commit c156ea3

File tree

9 files changed

+361
-465
lines changed

9 files changed

+361
-465
lines changed

.binder/postBuild

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ set -ex
33
curl -LsSf https://astral.sh/uv/install.sh | sh
44
source $HOME/.cargo/env
55
uv export \
6-
--extra jupyter \
7-
--extra notebooks \
6+
--group jupyter \
7+
--group notebooks \
8+
--no-dev \
89
> requirements.txt
910
uv pip install \
1011
--requirement requirements.txt \
1112
--system
13+
rm requirements.txt
1214
uv cache clean

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ on:
2828

2929
jobs:
3030
doc:
31-
uses: ComPWA/actions/.github/workflows/ci-docs.yml@v2
31+
uses: ComPWA/actions/.github/workflows/ci-docs.yml@v2.1
3232
permissions:
3333
pages: write
3434
id-token: write
@@ -37,7 +37,7 @@ jobs:
3737
python-version: "3.9"
3838
specific-pip-packages: ${{ inputs.specific-pip-packages }}
3939
pytest:
40-
uses: ComPWA/actions/.github/workflows/pytest.yml@v2
40+
uses: ComPWA/actions/.github/workflows/pytest.yml@v2.1
4141
with:
4242
coverage-target: qrules
4343
macos-python-version: "3.9"
@@ -47,6 +47,6 @@ jobs:
4747
if: inputs.specific-pip-packages == ''
4848
secrets:
4949
token: ${{ secrets.PAT }}
50-
uses: ComPWA/actions/.github/workflows/pre-commit.yml@v2
50+
uses: ComPWA/actions/.github/workflows/pre-commit.yml@v2.1
5151
with:
5252
python-version: "3.9"

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ repos:
1414
- id: check-useless-excludes
1515

1616
- repo: https://github.com/ComPWA/policy
17-
rev: 0.5.0
17+
rev: 0.5.5
1818
hooks:
1919
- id: check-dev-files
2020
args:
@@ -61,7 +61,7 @@ repos:
6161
metadata.vscode
6262
6363
- repo: https://github.com/astral-sh/ruff-pre-commit
64-
rev: v0.7.0
64+
rev: v0.7.1
6565
hooks:
6666
- id: ruff
6767
args: [--fix]
@@ -123,7 +123,7 @@ repos:
123123
pass_filenames: false
124124

125125
- repo: https://github.com/streetsidesoftware/cspell-cli
126-
rev: v8.15.1
126+
rev: v8.15.2
127127
hooks:
128128
- id: cspell
129129

@@ -149,11 +149,11 @@ repos:
149149
- python
150150

151151
- repo: https://github.com/ComPWA/pyright-pre-commit
152-
rev: v1.1.385
152+
rev: v1.1.386
153153
hooks:
154154
- id: pyright
155155

156156
- repo: https://github.com/astral-sh/uv-pre-commit
157-
rev: 0.4.24
157+
rev: 0.4.28
158158
hooks:
159159
- id: uv-lock

.readthedocs.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ build:
1111
pixi global install graphviz uv
1212
- |-
1313
export UV_LINK_MODE=copy
14-
uv run --extra doc --locked --with tox \
14+
uv run \
15+
--group doc \
16+
--locked \
17+
--no-dev \
18+
--with tox \
1519
tox -e doc
1620
mkdir -p $READTHEDOCS_OUTPUT
1721
mv docs/_build/html $READTHEDOCS_OUTPUT

CONTRIBUTING.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,30 @@ cd qrules
1515
Now it's simply a matter of creating and activating the [virtual environment](https://docs.astral.sh/uv/pip/environments) with [`uv sync`](https://docs.astral.sh/uv/reference/cli/#uv-sync). The dependencies for the project are 'pinned' in each commit through the [`uv.lock` file](https://docs.astral.sh/uv/concepts/projects/#project-lockfile).
1616

1717
```shell
18-
uv sync
18+
uv sync --all-extras
1919
source .venv/bin/activate
2020
```
2121

22-
Formatting and linting checks are automatically performed when committing changes. This is done with [pre-commit](https://pre-commit.com). To install the hooks in your local repository, run [`pre-commit install`](https://pre-commit.com/#3-install-the-git-hook-scripts) **once**:
22+
Formatting and linting checks are automatically performed when committing changes. This is done with [pre-commit](https://pre-commit.com). To install the hooks in your local repository, run install `pre-commit` with `uv`:
23+
24+
```shell
25+
uv tool install pre-commit --with pre-commit-uv --force-reinstall
26+
```
27+
28+
and [`pre-commit install`](https://pre-commit.com/#3-install-the-git-hook-scripts) **once**:
2329

2430
```shell
2531
pre-commit install --install-hooks
2632
```
33+
34+
In addition, it may be handy to install `tox`:
35+
36+
```shell
37+
uv tool install tox --with tox-uv
38+
```
39+
40+
If the repository provides a Tox configuration under [`pyproject.toml`](./pyproject.toml), you can see which jobs it defines with:
41+
42+
```shell
43+
tox list
44+
```

docs/install.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ python3 -m pip install git+https://github.com/ComPWA/qrules@main
4747

4848
:::{include} ../CONTRIBUTING.md
4949
:start-after: **[compwa.github.io/develop](https://compwa.github.io/develop)**!
50+
:end-before: If the repository provides a Tox configuration
5051
:::
5152

5253
That's all! Have a look at {doc}`/usage` to try out the package. You can also have a look at {doc}`compwa:develop` for tips on how to work with this 'editable' developer setup!

pyproject.toml

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,29 @@ name = "qrules"
4949
requires-python = ">=3.9"
5050

5151
[project.optional-dependencies]
52-
all = [
53-
"qrules[viz]",
54-
]
52+
viz = ["graphviz"]
53+
54+
[project.readme]
55+
content-type = "text/markdown"
56+
file = "README.md"
57+
58+
[project.urls]
59+
Changelog = "https://github.com/ComPWA/qrules/releases"
60+
Documentation = "https://qrules.rtfd.io"
61+
Source = "https://github.com/ComPWA/qrules"
62+
Tracker = "https://github.com/ComPWA/qrules/issues"
63+
64+
[dependency-groups]
5565
dev = [
56-
"qrules[all]",
57-
"qrules[doc]",
58-
"qrules[jupyter]",
59-
"qrules[sty]",
60-
"qrules[test]",
66+
"ruff",
6167
"sphinx-autobuild",
62-
"tox",
68+
{include-group = "doc"},
69+
{include-group = "jupyter"},
70+
{include-group = "style"},
71+
{include-group = "test"},
6372
]
6473
doc = [
6574
"myst-nb",
66-
"qrules[notebooks]",
6775
"sphinx",
6876
"sphinx-api-relink",
6977
"sphinx-book-theme",
@@ -76,56 +84,41 @@ doc = [
7684
"sphinx-thebe",
7785
"sphinx-togglebutton",
7886
"sphinxcontrib-bibtex >=2",
87+
{include-group = "notebooks"},
7988
]
8089
jupyter = [
8190
"ipywidgets",
8291
"jupyterlab",
83-
"jupyterlab-code-formatter >=3.0.0",
92+
"jupyterlab-code-formatter",
8493
"jupyterlab-git",
8594
"jupyterlab-lsp",
8695
"jupyterlab-myst",
8796
"python-lsp-ruff",
8897
"python-lsp-server[rope]",
98+
{include-group = "notebooks"},
8999
]
90-
notebooks = [
91-
"qrules[viz]",
92-
]
93-
sty = [
100+
notebooks = ["qrules[viz]"]
101+
style = [
94102
"mypy",
95-
"pre-commit-uv",
96-
"qrules[types]",
97-
"ruff",
103+
{include-group = "types"},
98104
]
99105
test = [
100106
"ipython",
101107
"nbmake",
102-
"pydot <2", # problem with pydot.graph_from_dot_data
108+
"pydot <2",
103109
"pytest",
104110
"pytest-cov",
105111
"pytest-profiling",
106112
"pytest-xdist",
107113
]
108114
types = [
109115
"ipython",
110-
"pydot <2", # problem with pydot.graph_from_dot_data
116+
"pydot <2",
111117
"pytest",
112118
"sphinx-api-relink",
113119
"types-PyYAML",
114120
"types-setuptools",
115121
]
116-
viz = [
117-
"graphviz",
118-
]
119-
120-
[project.readme]
121-
content-type = "text/markdown"
122-
file = "README.md"
123-
124-
[project.urls]
125-
Changelog = "https://github.com/ComPWA/qrules/releases"
126-
Documentation = "https://qrules.rtfd.io"
127-
Source = "https://github.com/ComPWA/qrules"
128-
Tracker = "https://github.com/ComPWA/qrules/issues"
129122

130123
[tool.setuptools]
131124
include-package-data = false
@@ -242,6 +235,8 @@ reportUnusedFunction = true
242235
reportUnusedImport = true
243236
reportUnusedVariable = true
244237
typeCheckingMode = "strict"
238+
venv = ".venv"
239+
venvPath = "."
245240

246241
[tool.pytest.ini_options]
247242
addopts = [
@@ -512,8 +507,6 @@ allowlist_externals =
512507
commands =
513508
pre-commit run --all-files {posargs}
514509
description = Perform all linting, formatting, and spelling checks
515-
setenv =
516-
SKIP = pyright
517510
518511
[testenv:test]
519512
allowlist_externals =

src/qrules/transition.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,11 @@ def __init__( # noqa: C901, PLR0912, PLR0917
250250
self.__number_of_threads = NumberOfThreads.get()
251251
if interaction_type_settings is None:
252252
interaction_type_settings = {}
253-
if formalism not in set(SpinFormalism.__args__): # type: ignore[attr-defined]
253+
spin_formalisms = SpinFormalism.__args__ # type: ignore[attr-defined]
254+
if formalism not in set(spin_formalisms):
254255
msg = (
255256
f'Formalism "{formalism}" not implemented. Use one of'
256-
f" {', '.join(SpinFormalism.__args__)} instead." # type: ignore[attr-defined]
257+
f" {', '.join(spin_formalisms)} instead."
257258
)
258259
raise NotImplementedError(msg)
259260
self.__formalism = formalism

0 commit comments

Comments
 (0)