Skip to content

Commit

Permalink
MAINT: autoupdate pre-commit hooks (#37)
Browse files Browse the repository at this point in the history
* DX: add `*.egg-info/` to `.gitignore
* DX: implement `.envrc` for `direnv`
* DX: modernise dev setup with latest ComPWA policy
* DX: switch to Ruff as formatter and linter
* ENH: compile constraint files with `uv pip compile`
* FIX: do not format notebooks with Prettier
* MAINT: address Ruff issues
* MAINT: apply Ruff formatting
* MAINT: remove redundant notebook cell metadata
  • Loading branch information
pre-commit-ci[bot] authored Aug 7, 2024
1 parent 00335e3 commit f90f3dc
Show file tree
Hide file tree
Showing 21 changed files with 291 additions and 379 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
layout anaconda
6 changes: 3 additions & 3 deletions .github/workflows/constraints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: "3.8"
- run: pip install pip-tools
- run: pip-compile --no-annotate --strip-extras --upgrade binder/requirements.in
- run: pip-compile --no-annotate --strip-extras --upgrade requirements.in
- run: pip install uv
- run: uv pip compile binder/requirements.in -o binder/requirements.txt --no-annotate --strip-extras --upgrade
- run: uv pip compile requirements.in -o requirements.txt --no-annotate --strip-extras --upgrade
- uses: actions/upload-artifact@v4
with:
name: pip-constraints
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.csv
*.egg-info/
.ipynb_checkpoints/
.tox/
condaenv.*.requirements.txt
Expand Down
35 changes: 13 additions & 22 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ repos:
- |
cell.attachments
cell.metadata.code_folding
cell.metadata.editable
cell.metadata.id
cell.metadata.pycharm
cell.metadata.slideshow
cell.metadata.user_expressions
metadata.celltoolbar
metadata.colab.name
Expand All @@ -37,7 +39,7 @@ repos:
metadata.vscode
- repo: https://github.com/ComPWA/policy
rev: 0.3.4
rev: 0.3.18
hooks:
- id: check-dev-files
args:
Expand All @@ -46,24 +48,23 @@ repos:
- --no-gitpod
- --no-prettierrc
- --no-pypi
- --no-python
- --no-ruff
- --no-version-branches
- --repo-name=ComPWA-demo
- --repo-title="ComPWA demos"
- id: colab-toc-visible
- id: remove-empty-tags

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.8.5
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.6
hooks:
- id: nbqa-flake8
- id: nbqa-isort
- id: nbqa-pyupgrade
args:
- --py36-plus
- id: ruff
args: [--fix]
types_or: [python, pyi, jupyter]
- id: ruff-format
types_or: [python, pyi, jupyter]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-case-conflict
- id: check-json
Expand All @@ -79,11 +80,6 @@ repos:
- id: mixed-line-ending
- id: trailing-whitespace

- repo: https://github.com/asottile/blacken-docs
rev: 1.16.0
hooks:
- id: blacken-docs

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
Expand All @@ -101,13 +97,8 @@ repos:
args:
- --in-place

- repo: https://github.com/psf/black
rev: 24.3.0
hooks:
- id: black-jupyter

- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v8.6.1
rev: v8.13.1
hooks:
- id: cspell

Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.ipynb
8 changes: 5 additions & 3 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
"recommendations": [
"charliermarsh.ruff",
"eamodio.gitlens",
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"github.vscode-github-actions",
"ms-python.black-formatter",
"ms-python.flake8",
"ms-python.isort",
"ms-python.python",
"ms-vsliveshare.vsliveshare",
"redhat.vscode-yaml",
Expand All @@ -20,6 +18,10 @@
"bungcip.better-toml",
"davidanson.vscode-markdownlint",
"garaioag.garaio-vscode-unwanted-recommendations",
"ms-python.black-formatter",
"ms-python.flake8",
"ms-python.isort",
"ms-python.mypy-type-checker",
"ms-python.pylint",
"travisillig.vscode-json-stable-stringify",
"tyriar.sort-lines"
Expand Down
19 changes: 12 additions & 7 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
"editor.formatOnSave": false
},
"[git-commit]": {
"editor.rulers": [
72
],
"editor.rulers": [72],
"rewrap.wrappingColumn": 72
},
"[ipynb]": {
Expand All @@ -24,7 +22,8 @@
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
},
"editor.defaultFormatter": "charliermarsh.ruff"
},
"[yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
Expand All @@ -33,15 +32,21 @@
"diffEditor.experimental.showMoves": true,
"editor.formatOnSave": true,
"git.rebaseWhenSync": true,
"github-actions.workflows.pinned.workflows": [
".github/workflows/ci.yml"
],
"github-actions.workflows.pinned.workflows": [".github/workflows/ci.yml"],
"gitlens.telemetry.enabled": false,
"multiDiffEditor.experimental.enabled": true,
"notebook.codeActionsOnSave": {
"notebook.source.organizeImports": "explicit"
},
"notebook.formatOnSave.enabled": true,
"python.analysis.autoImportCompletions": false,
"python.languageServer": "Pylance",
"python.terminal.activateEnvironment": false,
"python.testing.unittestEnabled": false,
"redhat.telemetry.enabled": false,
"rewrap.wrappingColumn": 88,
"ruff.enable": true,
"ruff.importStrategy": "fromEnvironment",
"ruff.organizeImports": true,
"telemetry.telemetryLevel": "off"
}
20 changes: 6 additions & 14 deletions 2021.11.29/ampform.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
},
{
"cell_type": "markdown",
"metadata": {
"tags": []
},
"metadata": {},
"source": [
"## Install dependencies"
]
Expand All @@ -44,8 +42,7 @@
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": []
}
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -131,9 +128,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"metadata": {},
"outputs": [],
"source": [
"dot = qrules.io.asdot(reaction, collapse_graphs=True, render_final_state_id=True)\n",
Expand Down Expand Up @@ -177,8 +172,7 @@
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": []
}
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -215,8 +209,7 @@
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": []
}
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -262,8 +255,7 @@
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": []
}
},
"outputs": [],
"source": [
Expand Down
11 changes: 3 additions & 8 deletions 2021.11.29/qrules.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"metadata": {},
"outputs": [],
"source": [
"%load_ext autoreload\n",
Expand Down Expand Up @@ -73,9 +71,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"metadata": {},
"outputs": [],
"source": [
"dot = qrules.io.asdot(reaction, collapse_graphs=True)\n",
Expand All @@ -95,8 +91,7 @@
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": []
}
},
"outputs": [],
"source": [
Expand Down
34 changes: 11 additions & 23 deletions 2021.11.29/tensorwaves-0.3.4.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,15 @@
},
{
"cell_type": "markdown",
"metadata": {
"tags": []
},
"metadata": {},
"source": [
"## Install dependencies"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"metadata": {},
"outputs": [],
"source": [
"%pip install -q ampform[viz]==0.11.* tensorwaves[jax]==0.3.4 tensorflow==2.7.*"
Expand All @@ -46,8 +42,7 @@
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": []
}
},
"outputs": [],
"source": [
Expand All @@ -60,7 +55,7 @@
"\n",
"import ampform\n",
"import graphviz\n",
"import matplotlib\n",
"import matplotlib as mpl\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import qrules\n",
Expand All @@ -82,7 +77,7 @@
"tf.get_logger().setLevel(\"WARNING\")\n",
"warnings.filterwarnings(\"ignore\")\n",
"\n",
"matplotlib.rcParams.update({\"font.size\": 14})\n",
"mpl.rcParams.update({\"font.size\": 14})\n",
"np_config.enable_numpy_behavior()\n",
"\n",
"has_tf_gpu = bool(tf.config.list_physical_devices(\"GPU\"))\n",
Expand All @@ -104,8 +99,7 @@
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": []
}
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -202,8 +196,7 @@
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": []
}
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -248,9 +241,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"metadata": {},
"outputs": [],
"source": [
"template = SympyModel(\n",
Expand Down Expand Up @@ -288,8 +279,7 @@
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": []
}
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -355,8 +345,7 @@
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": []
}
},
"outputs": [],
"source": [
Expand All @@ -377,8 +366,7 @@
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": []
}
},
"outputs": [],
"source": [
Expand Down
Loading

0 comments on commit f90f3dc

Please sign in to comment.