Skip to content

Commit

Permalink
FIX: define dev dependencies as dependency groups (#144)
Browse files Browse the repository at this point in the history
* FIX: remove `pre-commit-uv` and `tox` from environment
* DX: move `nbmake` to `dev` dependencies
* DX: run `pyright` in `tox -e sty` job
* MAINT: apply Ruff fixes
* MAINT: clean up dependencies
* MAINT: update lock files
  • Loading branch information
redeboer authored Oct 28, 2024
1 parent d070064 commit 09cbf7d
Show file tree
Hide file tree
Showing 9 changed files with 373 additions and 534 deletions.
6 changes: 4 additions & 2 deletions .binder/postBuild
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ set -ex
curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.cargo/env
uv export \
--extra jupyter \
--extra notebooks \
--group jupyter \
--group notebooks \
--no-dev \
> requirements.txt
uv pip install \
--requirement requirements.txt \
--system
rm requirements.txt
uv cache clean
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ on:

jobs:
doc:
uses: ComPWA/actions/.github/workflows/ci-docs.yml@v2
uses: ComPWA/actions/.github/workflows/ci-docs.yml@v2.1
permissions:
pages: write
id-token: write
Expand All @@ -37,7 +37,7 @@ jobs:
gh-pages: true
specific-pip-packages: ${{ inputs.specific-pip-packages }}
pytest:
uses: ComPWA/actions/.github/workflows/pytest.yml@v2
uses: ComPWA/actions/.github/workflows/pytest.yml@v2.1
with:
coverage-target: ampform_dpd
macos-python-version: "3.9"
Expand All @@ -46,4 +46,4 @@ jobs:
if: inputs.specific-pip-packages == ''
secrets:
token: ${{ secrets.PAT }}
uses: ComPWA/actions/.github/workflows/pre-commit.yml@v2
uses: ComPWA/actions/.github/workflows/pre-commit.yml@v2.1
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
- id: check-useless-excludes

- repo: https://github.com/ComPWA/policy
rev: 0.5.0
rev: 0.5.5
hooks:
- id: check-dev-files
args:
Expand Down Expand Up @@ -53,7 +53,7 @@ repos:
metadata.vscode
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.0
rev: v0.7.1
hooks:
- id: ruff
args: [--fix]
Expand Down Expand Up @@ -94,7 +94,7 @@ repos:
- --in-place

- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v8.15.1
rev: v8.15.2
hooks:
- id: cspell

Expand All @@ -120,11 +120,11 @@ repos:
- python

- repo: https://github.com/ComPWA/pyright-pre-commit
rev: v1.1.385
rev: v1.1.386
hooks:
- id: pyright

- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.4.24
rev: 0.4.27
hooks:
- id: uv-lock
6 changes: 5 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ build:
pixi global install graphviz uv
- |-
export UV_LINK_MODE=copy
uv run --extra doc --locked --with tox \
uv run \
--group doc \
--locked \
--no-dev \
--with tox \
tox -e doc
mkdir -p $READTHEDOCS_OUTPUT
mv docs/_build/html $READTHEDOCS_OUTPUT
4 changes: 2 additions & 2 deletions docs/comparison/d2kkk.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@
"ax_t1.set_xlabel(Rf\"$\\theta({final_state[2].latex}, {final_state[3].latex})$\")\n",
"ax_t2.set_xlabel(Rf\"$\\theta({final_state[1].latex}, {final_state[3].latex})$\")\n",
"ax_t3.set_xlabel(Rf\"$\\theta({final_state[1].latex}, {final_state[2].latex})$\")\n",
"fig.suptitle(f'Selected resonances: ${\", \".join(resonance_selector.value)}$')\n",
"fig.suptitle(f\"Selected resonances: ${', '.join(resonance_selector.value)}$\")\n",
"fig.tight_layout()\n",
"\n",
"lines = None\n",
Expand Down Expand Up @@ -678,7 +678,7 @@
" kwargs.pop(\"hide_expressions\")\n",
" kwargs.pop(\"simplify_expressions\")\n",
" selected_resonances = list(resonance_selector.value)\n",
" fig.suptitle(f'Selected resonances: ${\", \".join(selected_resonances)}$')\n",
" fig.suptitle(f\"Selected resonances: ${', '.join(selected_resonances)}$\")\n",
" dpd_pars = {k: int(v) for k, v in kwargs.items() if k in dpd_func.parameters}\n",
" ampform_pars = {\n",
" k: int(v) for k, v in kwargs.items() if k in ampform_func.parameters\n",
Expand Down
4 changes: 2 additions & 2 deletions docs/comparison/jpsi2phipipi.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@
"ax_t1.set_xlabel(Rf\"$\\theta({final_state[2].latex}, {final_state[3].latex})$\")\n",
"ax_t2.set_xlabel(Rf\"$\\theta({final_state[1].latex}, {final_state[3].latex})$\")\n",
"ax_t3.set_xlabel(Rf\"$\\theta({final_state[1].latex}, {final_state[2].latex})$\")\n",
"fig.suptitle(f'Selected resonances: ${\", \".join(resonance_selector.value)}$')\n",
"fig.suptitle(f\"Selected resonances: ${', '.join(resonance_selector.value)}$\")\n",
"fig.tight_layout()\n",
"\n",
"lines = None\n",
Expand Down Expand Up @@ -664,7 +664,7 @@
" kwargs.pop(\"hide_expressions\")\n",
" kwargs.pop(\"simplify_expressions\")\n",
" selected_resonances = list(resonance_selector.value)\n",
" fig.suptitle(f'Selected resonances: ${\", \".join(selected_resonances)}$')\n",
" fig.suptitle(f\"Selected resonances: ${', '.join(selected_resonances)}$\")\n",
" dpd_pars = {k: int(v) for k, v in kwargs.items() if k in dpd_func.parameters}\n",
" ampform_pars = {\n",
" k: int(v) for k, v in kwargs.items() if k in ampform_func.parameters\n",
Expand Down
4 changes: 2 additions & 2 deletions docs/comparison/jpsi2pipipi.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@
"ax_t1.set_xlabel(Rf\"$\\theta({final_state[2].latex}, {final_state[3].latex})$\")\n",
"ax_t2.set_xlabel(Rf\"$\\theta({final_state[1].latex}, {final_state[3].latex})$\")\n",
"ax_t3.set_xlabel(Rf\"$\\theta({final_state[1].latex}, {final_state[2].latex})$\")\n",
"fig.suptitle(f'Selected resonances: ${\", \".join(resonance_selector.value)}$')\n",
"fig.suptitle(f\"Selected resonances: ${', '.join(resonance_selector.value)}$\")\n",
"fig.tight_layout()\n",
"\n",
"lines = None\n",
Expand Down Expand Up @@ -664,7 +664,7 @@
" kwargs.pop(\"hide_expressions\")\n",
" kwargs.pop(\"simplify_expressions\")\n",
" selected_resonances = list(resonance_selector.value)\n",
" fig.suptitle(f'Selected resonances: ${\", \".join(selected_resonances)}$')\n",
" fig.suptitle(f\"Selected resonances: ${', '.join(selected_resonances)}$\")\n",
" dpd_pars = {k: int(v) for k, v in kwargs.items() if k in dpd_func.parameters}\n",
" ampform_pars = {\n",
" k: int(v) for k, v in kwargs.items() if k in ampform_func.parameters\n",
Expand Down
71 changes: 28 additions & 43 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dependencies = [
"ampform >=0.15.1", # aslatex with keyword arguments
"attrs >=20.1.0", # on_setattr and https://www.attrs.org/en/stable/api.html#next-gen
"cloudpickle",
"numpy~=1.0",
"qrules >=0.10.0",
"sympy >=1.10", # module sympy.printing.numpy and array expressions with shape kwarg
"tensorwaves[jax]",
Expand All @@ -40,16 +41,30 @@ name = "ampform-dpd"
requires-python = ">=3.9"

[project.optional-dependencies]
numba = ["tensorwaves[numba]"]
tf = ["tensorwaves[tf]"]

[project.readme]
content-type = "text/markdown"
file = "README.md"

[project.urls]
Changelog = "https://github.com/ComPWA/ampform-dpd/releases"
Documentation = "https://compwa.github.io/ampform-dpd"
Source = "https://github.com/ComPWA/ampform-dpd"
Tracker = "https://github.com/ComPWA/ampform-dpd/issues"

[dependency-groups]
dev = [
"ampform-dpd[doc]",
"ampform-dpd[jupyter]",
"ampform-dpd[sty]",
"ampform-dpd[test]",
"nbmake",
"ruff",
"sphinx-autobuild",
"tox",
{include-group = "doc"},
{include-group = "jupyter"},
{include-group = "style"},
{include-group = "test"},
]
doc = [
"ampform-dpd[notebooks]",
"myst-nb",
"sphinx-api-relink",
"sphinx-book-theme",
Expand All @@ -59,20 +74,17 @@ doc = [
"sphinx-pybtex-etal-style",
"sphinx-togglebutton",
"sphinxcontrib-bibtex",
]
jax = [
"numpy==1.*",
"tensorwaves[jax]",
{include-group = "notebooks"},
]
jupyter = [
"ampform-dpd[doc]",
"jupyterlab",
"jupyterlab-code-formatter >=3.0.0",
"jupyterlab-code-formatter",
"jupyterlab-git",
"jupyterlab-lsp",
"jupyterlab-myst",
"python-lsp-ruff",
"python-lsp-server[rope]",
{include-group = "notebooks"},
]
notebooks = [
"graphviz",
Expand All @@ -83,46 +95,20 @@ notebooks = [
"tensorwaves[phsp]",
"tqdm",
]
numba = [
"tensorwaves[numba]",
]
sty = [
"ampform-dpd[types]",
style = [
"mypy",
"pre-commit-uv",
"ruff",
]
tensorflow = [
"ampform-dpd[tf]",
{include-group = "types"},
]
test = [
"nbmake",
"numpy",
"pytest",
"pytest-cov",
"pytest-xdist",
]
tf = [
"tensorwaves[tf]",
]
types = [
"docutils",
"pybtex",
"pytest",
"sphinx",
"sphinx-api-relink",
]

[project.readme]
content-type = "text/markdown"
file = "README.md"

[project.urls]
Changelog = "https://github.com/ComPWA/ampform-dpd/releases"
Documentation = "https://compwa.github.io/ampform-dpd"
Source = "https://github.com/ComPWA/ampform-dpd"
Tracker = "https://github.com/ComPWA/ampform-dpd/issues"

[tool.setuptools]
include-package-data = false
package-dir = {"" = "src"}
Expand Down Expand Up @@ -185,6 +171,8 @@ reportUnusedFunction = true
reportUnusedImport = true
reportUnusedVariable = true
typeCheckingMode = "strict"
venv = ".venv"
venvPath = "."

[tool.pytest.ini_options]
addopts = [
Expand Down Expand Up @@ -480,7 +468,4 @@ allowlist_externals =
commands =
pre-commit run --all-files {posargs}
description = Perform all linting, formatting, and spelling checks
setenv =
{[testenv]setenv}
SKIP = pyright
"""
Loading

0 comments on commit 09cbf7d

Please sign in to comment.