Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
790b60b
MAINT: bump the lock group with 11 updates
dependabot[bot] Jul 1, 2026
15001d0
MAINT: implement pre-commit autofixes
pre-commit-ci[bot] Jul 1, 2026
f9deb9f
MAINT: upgrade lock files
web-flow Jul 1, 2026
1633cbc
MAINT: implement pre-commit autofixes
pre-commit-ci[bot] Jul 1, 2026
c9d9d19
MAINT: upgrade lock files
redeboer Jul 5, 2026
e12b003
MAINT: addres `mypy` linting issues
redeboer Jul 5, 2026
211175c
MAINT: group `docnb-force` under doc group
redeboer Jul 5, 2026
482d2bc
ENH: handle both `particle` v0 and v1
redeboer Jul 5, 2026
fa12ba2
Merge branch 'main' into dependabot/lock-b80f3de47f
redeboer Jul 5, 2026
8fea657
DX: switch to `ty` as type checker
redeboer Jul 5, 2026
9422aaa
MAINT: address `ty` linting issues
redeboer Jul 5, 2026
bdeb58b
MAINT: upgrade lock files
web-flow Jul 5, 2026
1a31a75
MAINT: implement updates from formatters
web-flow Jul 5, 2026
422eaa5
MAINT: remove `pyright` comments
redeboer Jul 5, 2026
23157a4
Merge branch 'main' into dependabot/lock-b80f3de47f
redeboer Jul 9, 2026
6ea389f
MAINT: upgrade lock files
redeboer Jul 9, 2026
3e871cc
MAINT: address `ty` linting issues
redeboer Jul 9, 2026
9099fc3
MAINT: install and implement ComPWA/policy@25e781a
redeboer Jul 9, 2026
3fc538a
DX: switch to Tombi as TOML formatter
redeboer Jul 17, 2026
259c77c
MAINT: upgrade lock files
redeboer Jul 17, 2026
efb075b
MAINT: implement pre-commit autofixes
pre-commit-ci[bot] Jul 17, 2026
b13f2bc
MAINT: address linting issues
redeboer Jul 17, 2026
e5e6416
ENH: revert signatures from `Any`
redeboer Jul 17, 2026
c3df485
ENH: improve signature with `TypeForm`
redeboer Jul 17, 2026
aeb2438
MAINT: upgrade lock files
web-flow Jul 17, 2026
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
6 changes: 1 addition & 5 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@
".pre-commit-config.yaml",
".prettierignore",
".readthedocs.yml",
".taplo.toml",
".vscode/*",
"CITATION.cff",
"codecov.yml",
"docs/conf.py",
"pyproject.toml",
"typings"
"pyproject.toml"
],
"ignoreWords": [
"adrs",
Expand Down Expand Up @@ -117,7 +115,6 @@
"pylance",
"pypi",
"pyproject",
"pyright",
"pytestconfig",
"rightarrow",
"risch",
Expand Down Expand Up @@ -186,7 +183,6 @@
"lineshape",
"lineshapes",
"mathbb",
"mypy",
"nishijima",
"pydot",
"PyPA",
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ version.py
.coverage.*
.ipynb_checkpoints/
.jupyter_ystore.db
.mypy*/
.pytest_cache/
.virtual_documents/
__pycache__/
Expand Down Expand Up @@ -56,4 +55,3 @@ CLAUDE.md
!.vscode/*.json
!.zenodo.json
!codecov.yml
!pyrightconfig.json
70 changes: 28 additions & 42 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ ci:
autoupdate_schedule: quarterly
skip:
- check-jsonschema
- mypy
- pyright
- tombi-format
- tombi-lint
- ty
- uv-lock

repos:
Expand All @@ -15,22 +16,9 @@ repos:
- id: check-useless-excludes

- repo: https://github.com/ComPWA/policy
rev: 0.8.13
rev: 0.9.1
hooks:
- id: check-dev-files
args:
- --doc-apt-packages=graphviz
- --repo-name=qrules
- --repo-title=QRules
- --type-checker=mypy
- --type-checker=pyright
- id: colab-toc-visible
- id: fix-nbformat-version
- id: remove-empty-tags
- id: set-nb-cells
args: [--autolink-concat]
- id: set-nb-display-name
- id: strip-nb-whitespace

- repo: https://github.com/kynan/nbstripout
rev: 0.9.1
Expand Down Expand Up @@ -60,8 +48,19 @@ repos:
metadata.varInspector
metadata.vscode

- repo: https://github.com/ComPWA/nbhooks
rev: 0.0.1
hooks:
- id: colab-toc-visible
- id: fix-nbformat-version
- id: remove-empty-tags
- id: set-nb-cells
args: [--autolink-concat]
- id: set-nb-display-name
- id: strip-nb-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.20
rev: v0.15.22
hooks:
- id: ruff-check
args: [--fix]
Expand Down Expand Up @@ -92,23 +91,18 @@ repos:
args: ["--django"]
- id: trailing-whitespace

- repo: https://github.com/tombi-toml/tombi-pre-commit
rev: v1.2.0
hooks:
- id: tombi-format
- id: tombi-lint
args: [--error-on-warnings]

- repo: https://github.com/ComPWA/prettier-pre-commit
rev: v3.8.1
hooks:
- id: prettier

- repo: https://github.com/ComPWA/taplo-pre-commit
rev: v0.9.3
hooks:
- id: taplo-format

- repo: https://github.com/pappasam/toml-sort
rev: v0.24.4
hooks:
- id: toml-sort
args:
- --in-place

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.37.4
hooks:
Expand Down Expand Up @@ -139,21 +133,13 @@ repos:
.*\.py
)$

- repo: local
hooks:
- id: mypy
name: mypy
entry: mypy
language: system
require_serial: true
types: [python]

- repo: https://github.com/ComPWA/pyright-pre-commit
rev: v1.1.407
- repo: https://github.com/astral-sh/ty-pre-commit
rev: v0.0.60
hooks:
- id: pyright
- id: ty
args: [--group=types, --no-default-groups]

- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.11.26
rev: 0.11.29
hooks:
- id: uv-lock
22 changes: 0 additions & 22 deletions .taplo.toml

This file was deleted.

9 changes: 5 additions & 4 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"recommendations": [
"astral-sh.ty",
"charliermarsh.ruff",
"christian-kohler.path-intellisense",
"eamodio.gitlens",
Expand All @@ -10,9 +11,7 @@
"github.vscode-pull-request-github",
"joaompinto.vscode-graphviz",
"mhutchie.git-graph",
"ms-python.mypy-type-checker",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-toolsai.jupyter",
"ms-toolsai.vscode-jupyter-cell-tags",
"ms-vscode.live-server",
Expand All @@ -21,20 +20,22 @@
"soulcode.vscode-unwanted-extensions",
"stkb.rewrap",
"streetsidesoftware.code-spell-checker",
"tamasfe.even-better-toml",
"tombi-toml.tombi",
"yzhang.markdown-all-in-one"
],
"unwantedRecommendations": [
"astral-sh.ty",
"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",
"ms-python.vscode-pylance",
"ms-toolsai.vscode-jupyter-slideshow",
"ryanluker.vscode-coverage-gutters",
"tamasfe.even-better-toml",
"travisillig.vscode-json-stable-stringify",
"tyriar.sort-lines"
]
Expand Down
9 changes: 6 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.rulers": [88]
},
"[toml]": {
"editor.defaultFormatter": "tombi-toml.tombi"
},
"[yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
Expand All @@ -44,14 +47,11 @@
],
"livePreview.defaultPreviewPath": "docs/_build/html",
"multiDiffEditor.experimental.enabled": true,
"mypy-type-checker.args": ["--config-file=${workspaceFolder}/pyproject.toml"],
"notebook.codeActionsOnSave": {
"notebook.source.organizeImports": "explicit"
},
"notebook.formatOnSave.enabled": true,
"notebook.gotoSymbols.showAllSymbols": true,
"python.analysis.autoImportCompletions": false,
"python.analysis.inlayHints.pytestParameters": true,
"python.defaultInterpreterPath": ".venv/bin/python",
"python.terminal.activateEnvironment": false,
"python.testing.pytestArgs": ["--numprocesses=auto"],
Expand All @@ -69,6 +69,9 @@
"telemetry.telemetryLevel": "off",
"testing.coverageToolbarEnabled": true,
"testing.showCoverageInExplorer": true,
"ty.completions.autoImport": false,
"ty.diagnosticMode": "workspace",
"ty.importStrategy": "fromEnvironment",
"yaml.schemas": {
"./src/qrules/particle-validation.json": ["*particle*.y*ml"],
"https://citation-file-format.github.io/1.2.0/schema.json": "CITATION.cff",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
[![Documentation](https://readthedocs.org/projects/qrules/badge/?version=latest)](https://qrules.readthedocs.io)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/ComPWA/qrules/main.svg)](https://results.pre-commit.ci/latest/github/ComPWA/qrules/main)
[![CI](https://github.com/ComPWA/qrules/actions/workflows/ci.yml/badge.svg)](https://github.com/ComPWA/qrules/actions/workflows/ci.yml)
[![Type-checked with mypy](https://mypy-lang.org/static/mypy_badge.svg)](https://mypy.readthedocs.io)
[![Test coverage](https://codecov.io/gh/ComPWA/qrules/branch/main/graph/badge.svg)](https://codecov.io/gh/ComPWA/qrules)
[![Spelling checked](https://img.shields.io/badge/cspell-checked-brightgreen.svg)](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![ty](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ty/main/assets/badge/v0.json)](https://github.com/astral-sh/ty)
[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)

QRules is a Python package for **validating and generating particle reactions** using
Expand Down
11 changes: 5 additions & 6 deletions docs/_extend_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
This small script is used by ``conf.py`` to dynamically modify docstrings.
"""

# pyright: reportMissingImports=false
from __future__ import annotations

import inspect
Expand Down Expand Up @@ -78,7 +77,7 @@ def extend_create_n_body_topology() -> None:
)


def extend_Topology() -> None: # noqa: N802
def extend_Topology() -> None: # ruff:ignore[invalid-function-name]
from qrules.topology import Topology, create_isobar_topologies

topologies = create_isobar_topologies(number_of_final_states=3)
Expand All @@ -102,21 +101,21 @@ def _append_to_docstring(class_type: Callable | type, appended_text: str) -> Non
_IMAGE_DIR = "_images"


def _graphviz_to_image( # noqa: PLR0917
def _graphviz_to_image( # ruff:ignore[too-many-positional-arguments]
dot: str,
options: dict[str, str] | None = None,
format: str = "svg",
indent: int = 0,
caption: str = "",
label: str = "",
) -> str:
import graphviz # type: ignore[import]
import graphviz

if options is None:
options = {}
global _GRAPHVIZ_COUNTER # noqa: PLW0603
global _GRAPHVIZ_COUNTER # ruff:ignore[global-statement]
output_file = f"graphviz_{_GRAPHVIZ_COUNTER}"
_GRAPHVIZ_COUNTER += 1 # pyright: ignore[reportConstantRedefinition]
_GRAPHVIZ_COUNTER += 1
graphviz.Source(dot).render(f"{_IMAGE_DIR}/{output_file}", format=format)
restructuredtext = "\n"
if label:
Expand Down
5 changes: 3 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from qrules.quantum_numbers import EdgeQuantumNumbers, NodeQuantumNumbers

sys.path.insert(0, os.path.abspath("."))
from _extend_docstrings import extend_docstrings # noqa: PLC2701
from _extend_docstrings import extend_docstrings # ruff:ignore[import-private-name]


def __get_newtypes(some_type: type) -> list:
Expand Down Expand Up @@ -251,7 +251,6 @@ def __get_newtypes(some_type: type) -> list:
"graphviz": ("https://graphviz.readthedocs.io/en/stable", None),
"IPython": (f"https://ipython.readthedocs.io/en/{pin('IPython')}", None),
"jsonschema": ("https://python-jsonschema.readthedocs.io/en/stable", None),
"mypy": ("https://mypy.readthedocs.io/en/stable", None),
"python": ("https://docs.python.org/3", None),
}
linkcheck_anchors = False
Expand Down Expand Up @@ -285,11 +284,13 @@ def __get_newtypes(some_type: type) -> list:
nb_execution_timeout = -1
nb_output_stderr = "remove"
nitpick_ignore = [
("py:class", "qrules.conservation_rules._RuleClass"),
("py:class", "StrPath"),
]
nitpick_ignore_regex = [
(r"py:(class|obj)", "json.encoder.JSONEncoder"),
(r"py:(class|obj)", r"frozendict(\.frozendict)?"),
(r"py:(class|obj)", r"qrules\.quantum_numbers\._QuantumNumber_co"),
(r"py:(class|obj)", r"qrules\.topology\.EdgeType"),
(r"py:(class|obj)", r"qrules\.topology\.KT"),
(r"py:(class|obj)", r"qrules\.topology\.NewEdgeType"),
Expand Down
15 changes: 10 additions & 5 deletions docs/usage/conservation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
},
"outputs": [],
"source": [
"from fractions import Fraction\n",
"\n",
"import attrs\n",
"import graphviz\n",
"from IPython.display import display\n",
Expand All @@ -35,7 +37,7 @@
" spin_conservation,\n",
" spin_magnitude_conservation,\n",
")\n",
"from qrules.quantum_numbers import Parity"
"from qrules.quantum_numbers import EdgeQuantumNumbers, NodeQuantumNumbers, Parity"
]
},
{
Expand Down Expand Up @@ -68,9 +70,12 @@
"outputs": [],
"source": [
"parity_conservation(\n",
" ingoing_edge_qns=[Parity(-1)],\n",
" outgoing_edge_qns=[Parity(+1), Parity(+1)],\n",
" l_magnitude=1,\n",
" ingoing_edge_qns=[EdgeQuantumNumbers.parity(Parity(-1))],\n",
" outgoing_edge_qns=[\n",
" EdgeQuantumNumbers.parity(Parity(+1)),\n",
" EdgeQuantumNumbers.parity(Parity(+1)),\n",
" ],\n",
" l_magnitude=NodeQuantumNumbers.l_magnitude(Fraction(1)),\n",
")"
]
},
Expand Down Expand Up @@ -370,7 +375,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.12"
"version": "3.13.14"
}
},
"nbformat": 4,
Expand Down
Loading
Loading