From e60ff895b4cf84be18291b6e4fe0ab516e75a493 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 7 Aug 2024 14:51:59 +0000 Subject: [PATCH] MAINT: update pip constraints and pre-commit (#276) * DX: add `.envrc` definition * DX: add `display` as allowed function name * DX: select `ALL` Ruff linting rules * MAINT: address Ruff linting issues * MAINT: ignore deprecation warning * MAINT: implement updates from pre-commit hooks --- .constraints/py3.10.txt | 93 ++++++++++---------- .constraints/py3.11.txt | 91 +++++++++---------- .constraints/py3.12.txt | 91 +++++++++---------- .constraints/py3.7.txt | 19 ++-- .constraints/py3.8.txt | 61 ++++++------- .constraints/py3.9.txt | 87 +++++++++--------- .envrc | 1 + .pre-commit-config.yaml | 10 +-- .vscode/settings.json | 4 + pyproject.toml | 63 ++++++------- src/qrules/argument_handling.py | 2 +- src/qrules/conservation_rules.py | 7 +- src/qrules/io/__init__.py | 2 +- src/qrules/io/_dict.py | 2 +- src/qrules/io/_dot.py | 2 +- src/qrules/particle.py | 53 +++++------ src/qrules/quantum_numbers.py | 2 +- src/qrules/solving.py | 40 ++++----- src/qrules/system_control.py | 9 +- src/qrules/topology.py | 9 +- tests/channels/test_jpsi_to_gamma_pi0_pi0.py | 2 +- tests/channels/test_nbody_reactions.py | 2 +- tests/channels/test_y_to_d0_d0bar_pi0_pi0.py | 2 +- tests/unit/test_parity_prefactor.py | 10 --- tests/unit/test_particle.py | 10 +-- tests/unit/test_system_control.py | 13 ++- 26 files changed, 319 insertions(+), 368 deletions(-) create mode 100644 .envrc diff --git a/.constraints/py3.10.txt b/.constraints/py3.10.txt index ca749015..1bc95693 100644 --- a/.constraints/py3.10.txt +++ b/.constraints/py3.10.txt @@ -1,36 +1,35 @@ # This file was autogenerated by uv via the following command: # uv pip compile pyproject.toml -o .constraints/py3.10.txt --all-extras --no-annotate --python-version=3.10 --no-emit-package setuptools accessible-pygments==0.0.5 -alabaster==0.7.16 +alabaster==1.0.0 anyio==4.4.0 argon2-cffi==23.1.0 argon2-cffi-bindings==21.2.0 arrow==1.3.0 asttokens==2.4.1 async-lru==2.0.4 -attrs==23.2.0 +attrs==24.2.0 babel==2.15.0 beautifulsoup4==4.12.3 -black==24.4.2 bleach==6.1.0 -cachetools==5.3.3 +cachetools==5.4.0 cattrs==23.2.3 -certifi==2024.6.2 -cffi==1.16.0 +certifi==2024.7.4 +cffi==1.17.0 cfgv==3.4.0 chardet==5.2.0 charset-normalizer==3.3.2 click==8.1.7 colorama==0.4.6 comm==0.2.2 -coverage==7.5.4 -debugpy==1.8.1 +coverage==7.6.1 +debugpy==1.8.5 decorator==5.1.1 defusedxml==0.7.1 distlib==0.3.8 docstring-to-markdown==0.15 docutils==0.21.2 -exceptiongroup==1.2.1 +exceptiongroup==1.2.2 execnet==2.1.1 executing==2.0.1 fastjsonschema==2.20.0 @@ -45,37 +44,36 @@ h11==0.14.0 hepunits==2.3.4 httpcore==1.0.5 httpx==0.27.0 -identify==2.5.36 +identify==2.6.0 idna==3.7 imagesize==1.4.1 -importlib-metadata==7.2.1 +importlib-metadata==8.2.0 iniconfig==2.0.0 -ipykernel==6.29.4 -ipython==8.25.0 +ipykernel==6.29.5 +ipython==8.26.0 ipywidgets==8.1.3 isoduration==20.11.0 -isort==5.13.2 jedi==0.19.1 jinja2==3.1.4 json5==0.9.25 jsonpointer==3.0.0 -jsonschema==4.22.0 +jsonschema==4.23.0 jsonschema-specifications==2023.12.1 jupyter-cache==1.0.0 jupyter-client==8.6.2 jupyter-core==5.7.2 jupyter-events==0.10.0 jupyter-lsp==2.2.5 -jupyter-server==2.14.1 +jupyter-server==2.14.2 jupyter-server-mathjax==0.2.6 jupyter-server-terminals==0.5.3 -jupyterlab==4.2.2 -jupyterlab-code-formatter==2.2.1 +jupyterlab==4.2.4 +jupyterlab-code-formatter==3.0.1 jupyterlab-git==0.50.1 jupyterlab-lsp==5.1.0 jupyterlab-myst==2.4.2 jupyterlab-pygments==0.3.0 -jupyterlab-server==2.27.2 +jupyterlab-server==2.27.3 jupyterlab-widgets==3.0.11 latexcodec==3.0.0 lsprotocol==2023.0.1 @@ -85,10 +83,10 @@ matplotlib-inline==0.1.7 mdit-py-plugins==0.4.1 mdurl==0.1.2 mistune==3.0.2 -mypy==1.10.0 +mypy==1.11.1 mypy-extensions==1.0.0 -myst-nb==1.1.0 -myst-parser==3.0.1 +myst-nb==1.1.1 +myst-parser==4.0.0 nbclient==0.6.8 nbconvert==7.16.4 nbdime==4.0.1 @@ -102,25 +100,24 @@ packaging==24.1 pandocfilters==1.5.1 parso==0.8.4 particle==0.24.0 -pathspec==0.12.1 pexpect==4.9.0 platformdirs==4.2.2 pluggy==1.5.0 -pre-commit==3.7.1 +pre-commit==3.8.0 prometheus-client==0.20.0 prompt-toolkit==3.0.47 psutil==6.0.0 ptyprocess==0.7.0 -pure-eval==0.2.2 +pure-eval==0.2.3 pybtex==0.24.0 pybtex-docutils==1.0.3 pycparser==2.22 -pydata-sphinx-theme==0.15.3 +pydata-sphinx-theme==0.15.4 pydot==1.4.2 pygments==2.18.0 pyparsing==3.1.2 pyproject-api==1.7.1 -pytest==8.2.2 +pytest==8.3.2 pytest-cov==5.0.0 pytest-profiling==1.7.0 pytest-xdist==3.6.1 @@ -128,70 +125,70 @@ python-constraint2==2.0.0b5 python-dateutil==2.9.0.post0 python-json-logger==2.0.7 python-lsp-jsonrpc==1.1.2 -python-lsp-ruff==2.2.1 +python-lsp-ruff==2.2.2 python-lsp-server==1.11.0 pytoolconfig==1.3.1 -pyyaml==6.0.1 -pyzmq==26.0.3 +pyyaml==6.0.2 +pyzmq==26.1.0 referencing==0.35.1 requests==2.32.3 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 rope==1.13.0 -rpds-py==0.18.1 -ruff==0.4.10 +rpds-py==0.20.0 +ruff==0.5.6 send2trash==1.8.3 six==1.16.0 smmap==5.0.1 sniffio==1.3.1 snowballstemmer==2.2.0 soupsieve==2.5 -sphinx==7.3.7 +sphinx==8.0.2 sphinx-api-relink==0.0.9 sphinx-autobuild==2024.4.16 sphinx-book-theme==1.1.3 sphinx-codeautolink==0.15.2 sphinx-comments==0.0.3 sphinx-copybutton==0.5.2 -sphinx-design==0.6.0 +sphinx-design==0.6.1 sphinx-hep-pdgref==0.2.0 sphinx-pybtex-etal-style==0.0.2 sphinx-thebe==0.3.1 sphinx-togglebutton==0.3.2 -sphinxcontrib-applehelp==1.0.8 +sphinxcontrib-applehelp==2.0.0 sphinxcontrib-bibtex==2.6.2 -sphinxcontrib-devhelp==1.0.6 -sphinxcontrib-htmlhelp==2.0.5 +sphinxcontrib-devhelp==2.0.0 +sphinxcontrib-htmlhelp==2.1.0 sphinxcontrib-jsmath==1.0.1 -sphinxcontrib-qthelp==1.0.7 -sphinxcontrib-serializinghtml==1.1.10 -sqlalchemy==2.0.31 +sphinxcontrib-qthelp==2.0.0 +sphinxcontrib-serializinghtml==2.0.0 +sqlalchemy==2.0.32 stack-data==0.6.3 -starlette==0.37.2 +starlette==0.38.2 tabulate==0.9.0 terminado==0.18.1 tinycss2==1.3.0 tomli==2.0.1 tornado==6.4.1 -tox==4.15.1 -tqdm==4.66.4 +tox==4.17.0 +tqdm==4.66.5 traitlets==5.14.3 types-python-dateutil==2.9.0.20240316 -types-pyyaml==6.0.12.20240311 -types-setuptools==70.0.0.20240524 +types-pyyaml==6.0.12.20240724 +types-setuptools==71.1.0.20240806 typing-extensions==4.12.2 ujson==5.10.0 uri-template==1.3.0 urllib3==2.2.2 -uvicorn==0.30.1 +uvicorn==0.30.5 virtualenv==20.26.3 -watchfiles==0.22.0 +watchfiles==0.23.0 wcwidth==0.2.13 webcolors==24.6.0 webencodings==0.5.1 websocket-client==1.8.0 websockets==12.0 -wheel==0.43.0 +wheel==0.44.0 widgetsnbextension==4.0.11 zipp==3.19.2 diff --git a/.constraints/py3.11.txt b/.constraints/py3.11.txt index 20a86e26..fd32efd0 100644 --- a/.constraints/py3.11.txt +++ b/.constraints/py3.11.txt @@ -1,30 +1,29 @@ # This file was autogenerated by uv via the following command: # uv pip compile pyproject.toml -o .constraints/py3.11.txt --all-extras --no-annotate --python-version=3.11 --no-emit-package setuptools accessible-pygments==0.0.5 -alabaster==0.7.16 +alabaster==1.0.0 anyio==4.4.0 argon2-cffi==23.1.0 argon2-cffi-bindings==21.2.0 arrow==1.3.0 asttokens==2.4.1 async-lru==2.0.4 -attrs==23.2.0 +attrs==24.2.0 babel==2.15.0 beautifulsoup4==4.12.3 -black==24.4.2 bleach==6.1.0 -cachetools==5.3.3 +cachetools==5.4.0 cattrs==23.2.3 -certifi==2024.6.2 -cffi==1.16.0 +certifi==2024.7.4 +cffi==1.17.0 cfgv==3.4.0 chardet==5.2.0 charset-normalizer==3.3.2 click==8.1.7 colorama==0.4.6 comm==0.2.2 -coverage==7.5.4 -debugpy==1.8.1 +coverage==7.6.1 +debugpy==1.8.5 decorator==5.1.1 defusedxml==0.7.1 distlib==0.3.8 @@ -44,37 +43,36 @@ h11==0.14.0 hepunits==2.3.4 httpcore==1.0.5 httpx==0.27.0 -identify==2.5.36 +identify==2.6.0 idna==3.7 imagesize==1.4.1 -importlib-metadata==7.2.1 +importlib-metadata==8.2.0 iniconfig==2.0.0 -ipykernel==6.29.4 -ipython==8.25.0 +ipykernel==6.29.5 +ipython==8.26.0 ipywidgets==8.1.3 isoduration==20.11.0 -isort==5.13.2 jedi==0.19.1 jinja2==3.1.4 json5==0.9.25 jsonpointer==3.0.0 -jsonschema==4.22.0 +jsonschema==4.23.0 jsonschema-specifications==2023.12.1 jupyter-cache==1.0.0 jupyter-client==8.6.2 jupyter-core==5.7.2 jupyter-events==0.10.0 jupyter-lsp==2.2.5 -jupyter-server==2.14.1 +jupyter-server==2.14.2 jupyter-server-mathjax==0.2.6 jupyter-server-terminals==0.5.3 -jupyterlab==4.2.2 -jupyterlab-code-formatter==2.2.1 +jupyterlab==4.2.4 +jupyterlab-code-formatter==3.0.1 jupyterlab-git==0.50.1 jupyterlab-lsp==5.1.0 jupyterlab-myst==2.4.2 jupyterlab-pygments==0.3.0 -jupyterlab-server==2.27.2 +jupyterlab-server==2.27.3 jupyterlab-widgets==3.0.11 latexcodec==3.0.0 lsprotocol==2023.0.1 @@ -84,10 +82,10 @@ matplotlib-inline==0.1.7 mdit-py-plugins==0.4.1 mdurl==0.1.2 mistune==3.0.2 -mypy==1.10.0 +mypy==1.11.1 mypy-extensions==1.0.0 -myst-nb==1.1.0 -myst-parser==3.0.1 +myst-nb==1.1.1 +myst-parser==4.0.0 nbclient==0.6.8 nbconvert==7.16.4 nbdime==4.0.1 @@ -101,25 +99,24 @@ packaging==24.1 pandocfilters==1.5.1 parso==0.8.4 particle==0.24.0 -pathspec==0.12.1 pexpect==4.9.0 platformdirs==4.2.2 pluggy==1.5.0 -pre-commit==3.7.1 +pre-commit==3.8.0 prometheus-client==0.20.0 prompt-toolkit==3.0.47 psutil==6.0.0 ptyprocess==0.7.0 -pure-eval==0.2.2 +pure-eval==0.2.3 pybtex==0.24.0 pybtex-docutils==1.0.3 pycparser==2.22 -pydata-sphinx-theme==0.15.3 +pydata-sphinx-theme==0.15.4 pydot==1.4.2 pygments==2.18.0 pyparsing==3.1.2 pyproject-api==1.7.1 -pytest==8.2.2 +pytest==8.3.2 pytest-cov==5.0.0 pytest-profiling==1.7.0 pytest-xdist==3.6.1 @@ -127,69 +124,69 @@ python-constraint2==2.0.0b5 python-dateutil==2.9.0.post0 python-json-logger==2.0.7 python-lsp-jsonrpc==1.1.2 -python-lsp-ruff==2.2.1 +python-lsp-ruff==2.2.2 python-lsp-server==1.11.0 pytoolconfig==1.3.1 -pyyaml==6.0.1 -pyzmq==26.0.3 +pyyaml==6.0.2 +pyzmq==26.1.0 referencing==0.35.1 requests==2.32.3 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 rope==1.13.0 -rpds-py==0.18.1 -ruff==0.4.10 +rpds-py==0.20.0 +ruff==0.5.6 send2trash==1.8.3 six==1.16.0 smmap==5.0.1 sniffio==1.3.1 snowballstemmer==2.2.0 soupsieve==2.5 -sphinx==7.3.7 +sphinx==8.0.2 sphinx-api-relink==0.0.9 sphinx-autobuild==2024.4.16 sphinx-book-theme==1.1.3 sphinx-codeautolink==0.15.2 sphinx-comments==0.0.3 sphinx-copybutton==0.5.2 -sphinx-design==0.6.0 +sphinx-design==0.6.1 sphinx-hep-pdgref==0.2.0 sphinx-pybtex-etal-style==0.0.2 sphinx-thebe==0.3.1 sphinx-togglebutton==0.3.2 -sphinxcontrib-applehelp==1.0.8 +sphinxcontrib-applehelp==2.0.0 sphinxcontrib-bibtex==2.6.2 -sphinxcontrib-devhelp==1.0.6 -sphinxcontrib-htmlhelp==2.0.5 +sphinxcontrib-devhelp==2.0.0 +sphinxcontrib-htmlhelp==2.1.0 sphinxcontrib-jsmath==1.0.1 -sphinxcontrib-qthelp==1.0.7 -sphinxcontrib-serializinghtml==1.1.10 -sqlalchemy==2.0.31 +sphinxcontrib-qthelp==2.0.0 +sphinxcontrib-serializinghtml==2.0.0 +sqlalchemy==2.0.32 stack-data==0.6.3 -starlette==0.37.2 +starlette==0.38.2 tabulate==0.9.0 terminado==0.18.1 tinycss2==1.3.0 tornado==6.4.1 -tox==4.15.1 -tqdm==4.66.4 +tox==4.17.0 +tqdm==4.66.5 traitlets==5.14.3 types-python-dateutil==2.9.0.20240316 -types-pyyaml==6.0.12.20240311 -types-setuptools==70.0.0.20240524 +types-pyyaml==6.0.12.20240724 +types-setuptools==71.1.0.20240806 typing-extensions==4.12.2 ujson==5.10.0 uri-template==1.3.0 urllib3==2.2.2 -uvicorn==0.30.1 +uvicorn==0.30.5 virtualenv==20.26.3 -watchfiles==0.22.0 +watchfiles==0.23.0 wcwidth==0.2.13 webcolors==24.6.0 webencodings==0.5.1 websocket-client==1.8.0 websockets==12.0 -wheel==0.43.0 +wheel==0.44.0 widgetsnbextension==4.0.11 zipp==3.19.2 diff --git a/.constraints/py3.12.txt b/.constraints/py3.12.txt index ef9fdc66..187c11d8 100644 --- a/.constraints/py3.12.txt +++ b/.constraints/py3.12.txt @@ -1,30 +1,29 @@ # This file was autogenerated by uv via the following command: # uv pip compile pyproject.toml -o .constraints/py3.12.txt --all-extras --no-annotate --python-version=3.12 --no-emit-package setuptools accessible-pygments==0.0.5 -alabaster==0.7.16 +alabaster==1.0.0 anyio==4.4.0 argon2-cffi==23.1.0 argon2-cffi-bindings==21.2.0 arrow==1.3.0 asttokens==2.4.1 async-lru==2.0.4 -attrs==23.2.0 +attrs==24.2.0 babel==2.15.0 beautifulsoup4==4.12.3 -black==24.4.2 bleach==6.1.0 -cachetools==5.3.3 +cachetools==5.4.0 cattrs==23.2.3 -certifi==2024.6.2 -cffi==1.16.0 +certifi==2024.7.4 +cffi==1.17.0 cfgv==3.4.0 chardet==5.2.0 charset-normalizer==3.3.2 click==8.1.7 colorama==0.4.6 comm==0.2.2 -coverage==7.5.4 -debugpy==1.8.1 +coverage==7.6.1 +debugpy==1.8.5 decorator==5.1.1 defusedxml==0.7.1 distlib==0.3.8 @@ -44,37 +43,36 @@ h11==0.14.0 hepunits==2.3.4 httpcore==1.0.5 httpx==0.27.0 -identify==2.5.36 +identify==2.6.0 idna==3.7 imagesize==1.4.1 -importlib-metadata==7.2.1 +importlib-metadata==8.2.0 iniconfig==2.0.0 -ipykernel==6.29.4 -ipython==8.25.0 +ipykernel==6.29.5 +ipython==8.26.0 ipywidgets==8.1.3 isoduration==20.11.0 -isort==5.13.2 jedi==0.19.1 jinja2==3.1.4 json5==0.9.25 jsonpointer==3.0.0 -jsonschema==4.22.0 +jsonschema==4.23.0 jsonschema-specifications==2023.12.1 jupyter-cache==1.0.0 jupyter-client==8.6.2 jupyter-core==5.7.2 jupyter-events==0.10.0 jupyter-lsp==2.2.5 -jupyter-server==2.14.1 +jupyter-server==2.14.2 jupyter-server-mathjax==0.2.6 jupyter-server-terminals==0.5.3 -jupyterlab==4.2.2 -jupyterlab-code-formatter==2.2.1 +jupyterlab==4.2.4 +jupyterlab-code-formatter==3.0.1 jupyterlab-git==0.50.1 jupyterlab-lsp==5.1.0 jupyterlab-myst==2.4.2 jupyterlab-pygments==0.3.0 -jupyterlab-server==2.27.2 +jupyterlab-server==2.27.3 jupyterlab-widgets==3.0.11 latexcodec==3.0.0 lsprotocol==2023.0.1 @@ -84,10 +82,10 @@ matplotlib-inline==0.1.7 mdit-py-plugins==0.4.1 mdurl==0.1.2 mistune==3.0.2 -mypy==1.10.0 +mypy==1.11.1 mypy-extensions==1.0.0 -myst-nb==1.1.0 -myst-parser==3.0.1 +myst-nb==1.1.1 +myst-parser==4.0.0 nbclient==0.6.8 nbconvert==7.16.4 nbdime==4.0.1 @@ -101,25 +99,24 @@ packaging==24.1 pandocfilters==1.5.1 parso==0.8.4 particle==0.24.0 -pathspec==0.12.1 pexpect==4.9.0 platformdirs==4.2.2 pluggy==1.5.0 -pre-commit==3.7.1 +pre-commit==3.8.0 prometheus-client==0.20.0 prompt-toolkit==3.0.47 psutil==6.0.0 ptyprocess==0.7.0 -pure-eval==0.2.2 +pure-eval==0.2.3 pybtex==0.24.0 pybtex-docutils==1.0.3 pycparser==2.22 -pydata-sphinx-theme==0.15.3 +pydata-sphinx-theme==0.15.4 pydot==1.4.2 pygments==2.18.0 pyparsing==3.1.2 pyproject-api==1.7.1 -pytest==8.2.2 +pytest==8.3.2 pytest-cov==5.0.0 pytest-profiling==1.7.0 pytest-xdist==3.6.1 @@ -127,69 +124,69 @@ python-constraint2==2.0.0b5 python-dateutil==2.9.0.post0 python-json-logger==2.0.7 python-lsp-jsonrpc==1.1.2 -python-lsp-ruff==2.2.1 +python-lsp-ruff==2.2.2 python-lsp-server==1.11.0 pytoolconfig==1.3.1 -pyyaml==6.0.1 -pyzmq==26.0.3 +pyyaml==6.0.2 +pyzmq==26.1.0 referencing==0.35.1 requests==2.32.3 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 rope==1.13.0 -rpds-py==0.18.1 -ruff==0.4.10 +rpds-py==0.20.0 +ruff==0.5.6 send2trash==1.8.3 six==1.16.0 smmap==5.0.1 sniffio==1.3.1 snowballstemmer==2.2.0 soupsieve==2.5 -sphinx==7.3.7 +sphinx==8.0.2 sphinx-api-relink==0.0.9 sphinx-autobuild==2024.4.16 sphinx-book-theme==1.1.3 sphinx-codeautolink==0.15.2 sphinx-comments==0.0.3 sphinx-copybutton==0.5.2 -sphinx-design==0.6.0 +sphinx-design==0.6.1 sphinx-hep-pdgref==0.2.0 sphinx-pybtex-etal-style==0.0.2 sphinx-thebe==0.3.1 sphinx-togglebutton==0.3.2 -sphinxcontrib-applehelp==1.0.8 +sphinxcontrib-applehelp==2.0.0 sphinxcontrib-bibtex==2.6.2 -sphinxcontrib-devhelp==1.0.6 -sphinxcontrib-htmlhelp==2.0.5 +sphinxcontrib-devhelp==2.0.0 +sphinxcontrib-htmlhelp==2.1.0 sphinxcontrib-jsmath==1.0.1 -sphinxcontrib-qthelp==1.0.7 -sphinxcontrib-serializinghtml==1.1.10 -sqlalchemy==2.0.31 +sphinxcontrib-qthelp==2.0.0 +sphinxcontrib-serializinghtml==2.0.0 +sqlalchemy==2.0.32 stack-data==0.6.3 -starlette==0.37.2 +starlette==0.38.2 tabulate==0.9.0 terminado==0.18.1 tinycss2==1.3.0 tornado==6.4.1 -tox==4.15.1 -tqdm==4.66.4 +tox==4.17.0 +tqdm==4.66.5 traitlets==5.14.3 types-python-dateutil==2.9.0.20240316 -types-pyyaml==6.0.12.20240311 -types-setuptools==70.0.0.20240524 +types-pyyaml==6.0.12.20240724 +types-setuptools==71.1.0.20240806 typing-extensions==4.12.2 ujson==5.10.0 uri-template==1.3.0 urllib3==2.2.2 -uvicorn==0.30.1 +uvicorn==0.30.5 virtualenv==20.26.3 -watchfiles==0.22.0 +watchfiles==0.23.0 wcwidth==0.2.13 webcolors==24.6.0 webencodings==0.5.1 websocket-client==1.8.0 websockets==12.0 -wheel==0.43.0 +wheel==0.44.0 widgetsnbextension==4.0.11 zipp==3.19.2 diff --git a/.constraints/py3.7.txt b/.constraints/py3.7.txt index 31191e08..da79b3a7 100644 --- a/.constraints/py3.7.txt +++ b/.constraints/py3.7.txt @@ -8,16 +8,15 @@ anyio==3.7.1 argon2-cffi==23.1.0 argon2-cffi-bindings==21.2.0 arrow==1.2.3 -attrs==23.2.0 +attrs==24.2.0 babel==2.14.0 backcall==0.2.0 beautifulsoup4==4.12.3 -black==23.3.0 bleach==6.0.0 cached-property==1.5.2 -cachetools==5.3.3 +cachetools==5.4.0 cattrs==23.1.2 -certifi==2024.6.2 +certifi==2024.7.4 cffi==1.15.1 cfgv==3.3.1 chardet==5.2.0 @@ -33,7 +32,7 @@ distlib==0.3.8 docstring-to-markdown==0.15 docutils==0.17.1 entrypoints==0.4 -exceptiongroup==1.2.1 +exceptiongroup==1.2.2 execnet==2.0.2 fastjsonschema==2.20.0 filelock==3.12.2 @@ -55,7 +54,6 @@ ipython==7.34.0 ipython-genutils==0.2.0 ipywidgets==8.1.3 isoduration==20.11.0 -isort==5.11.5 jedi==0.18.2 jinja2==3.1.4 json5==0.9.16 @@ -72,7 +70,7 @@ jupyter-server-mathjax==0.2.6 jupyter-server-ydoc==0.8.0 jupyter-ydoc==0.2.5 jupyterlab==3.6.7 -jupyterlab-code-formatter==2.2.1 +jupyterlab-code-formatter==3.0.1 jupyterlab-git==0.44.0 jupyterlab-lsp==3.10.2 jupyterlab-myst==1.2.0 @@ -106,7 +104,6 @@ packaging==24.0 pandocfilters==1.5.1 parso==0.8.4 particle==0.23.1 -pathspec==0.11.2 pexpect==4.9.0 pickleshare==0.7.5 pkgutil-resolve-name==1.3.10 @@ -140,7 +137,7 @@ python-lsp-server==1.7.4 pytoolconfig==1.3.0 pytz==2024.1 pyyaml==6.0.1 -pyzmq==26.0.3 +pyzmq==26.1.0 requests==2.31.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 @@ -171,14 +168,14 @@ sphinxcontrib-htmlhelp==2.0.0 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 -sqlalchemy==1.4.52 +sqlalchemy==1.4.53 tabulate==0.9.0 terminado==0.17.1 tinycss2==1.2.1 tomli==2.0.1 tornado==6.2 tox==4.8.0 -tqdm==4.66.4 +tqdm==4.66.5 traitlets==5.9.0 typed-ast==1.5.5 types-pyyaml==6.0.12.12 diff --git a/.constraints/py3.8.txt b/.constraints/py3.8.txt index d8528278..67b05998 100644 --- a/.constraints/py3.8.txt +++ b/.constraints/py3.8.txt @@ -8,30 +8,29 @@ argon2-cffi-bindings==21.2.0 arrow==1.3.0 asttokens==2.4.1 async-lru==2.0.4 -attrs==23.2.0 +attrs==24.2.0 babel==2.15.0 backcall==0.2.0 beautifulsoup4==4.12.3 -black==24.4.2 bleach==6.1.0 -cachetools==5.3.3 +cachetools==5.4.0 cattrs==23.2.3 -certifi==2024.6.2 -cffi==1.16.0 +certifi==2024.7.4 +cffi==1.17.0 cfgv==3.4.0 chardet==5.2.0 charset-normalizer==3.3.2 click==8.1.7 colorama==0.4.6 comm==0.2.2 -coverage==7.5.4 -debugpy==1.8.1 +coverage==7.6.1 +debugpy==1.8.5 decorator==5.1.1 defusedxml==0.7.1 distlib==0.3.8 docstring-to-markdown==0.15 docutils==0.17.1 -exceptiongroup==1.2.1 +exceptiongroup==1.2.2 execnet==2.1.1 executing==2.0.1 fastjsonschema==2.20.0 @@ -46,38 +45,37 @@ h11==0.14.0 hepunits==2.3.4 httpcore==1.0.5 httpx==0.27.0 -identify==2.5.36 +identify==2.6.0 idna==3.7 imagesize==1.4.1 -importlib-metadata==7.2.1 +importlib-metadata==8.2.0 importlib-resources==6.4.0 iniconfig==2.0.0 -ipykernel==6.29.4 +ipykernel==6.29.5 ipython==8.12.3 ipywidgets==8.1.3 isoduration==20.11.0 -isort==5.13.2 jedi==0.19.1 jinja2==3.1.4 json5==0.9.25 jsonpointer==3.0.0 -jsonschema==4.22.0 +jsonschema==4.23.0 jsonschema-specifications==2023.12.1 jupyter-cache==0.6.1 jupyter-client==8.6.2 jupyter-core==5.7.2 jupyter-events==0.10.0 jupyter-lsp==2.2.5 -jupyter-server==2.14.1 +jupyter-server==2.14.2 jupyter-server-mathjax==0.2.6 jupyter-server-terminals==0.5.3 -jupyterlab==4.2.2 -jupyterlab-code-formatter==2.2.1 +jupyterlab==4.2.4 +jupyterlab-code-formatter==3.0.1 jupyterlab-git==0.50.1 jupyterlab-lsp==5.1.0 jupyterlab-myst==2.4.2 jupyterlab-pygments==0.3.0 -jupyterlab-server==2.27.2 +jupyterlab-server==2.27.3 jupyterlab-widgets==3.0.11 latexcodec==3.0.0 livereload==2.7.0 @@ -88,7 +86,7 @@ matplotlib-inline==0.1.7 mdit-py-plugins==0.3.5 mdurl==0.1.2 mistune==3.0.2 -mypy==1.10.0 +mypy==1.11.1 mypy-extensions==1.0.0 myst-nb==0.17.2 myst-parser==0.18.1 @@ -105,7 +103,6 @@ packaging==24.1 pandocfilters==1.5.1 parso==0.8.4 particle==0.24.0 -pathspec==0.12.1 pexpect==4.9.0 pickleshare==0.7.5 pkgutil-resolve-name==1.3.10 @@ -116,7 +113,7 @@ prometheus-client==0.20.0 prompt-toolkit==3.0.47 psutil==6.0.0 ptyprocess==0.7.0 -pure-eval==0.2.2 +pure-eval==0.2.3 pybtex==0.24.0 pybtex-docutils==1.0.3 pycparser==2.22 @@ -125,7 +122,7 @@ pydot==1.4.2 pygments==2.18.0 pyparsing==3.1.2 pyproject-api==1.7.1 -pytest==8.2.2 +pytest==8.3.2 pytest-cov==5.0.0 pytest-profiling==1.7.0 pytest-xdist==3.6.1 @@ -133,19 +130,19 @@ python-constraint2==2.0.0b5 python-dateutil==2.9.0.post0 python-json-logger==2.0.7 python-lsp-jsonrpc==1.1.2 -python-lsp-ruff==2.2.1 +python-lsp-ruff==2.2.2 python-lsp-server==1.11.0 pytoolconfig==1.3.1 pytz==2024.1 -pyyaml==6.0.1 -pyzmq==26.0.3 +pyyaml==6.0.2 +pyzmq==26.1.0 referencing==0.35.1 requests==2.32.3 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 rope==1.13.0 -rpds-py==0.18.1 -ruff==0.4.10 +rpds-py==0.20.0 +ruff==0.5.6 send2trash==1.8.3 six==1.16.0 smmap==5.0.1 @@ -171,19 +168,19 @@ sphinxcontrib-htmlhelp==2.0.1 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 -sqlalchemy==2.0.31 +sqlalchemy==2.0.32 stack-data==0.6.3 tabulate==0.9.0 terminado==0.18.1 tinycss2==1.3.0 tomli==2.0.1 tornado==6.4.1 -tox==4.15.1 -tqdm==4.66.4 +tox==4.17.0 +tqdm==4.66.5 traitlets==5.14.3 types-python-dateutil==2.9.0.20240316 -types-pyyaml==6.0.12.20240311 -types-setuptools==70.0.0.20240524 +types-pyyaml==6.0.12.20240724 +types-setuptools==71.1.0.20240806 typing-extensions==4.12.2 ujson==5.10.0 uri-template==1.3.0 @@ -193,7 +190,7 @@ wcwidth==0.2.13 webcolors==24.6.0 webencodings==0.5.1 websocket-client==1.8.0 -wheel==0.43.0 +wheel==0.44.0 widgetsnbextension==4.0.11 zipp==3.19.2 diff --git a/.constraints/py3.9.txt b/.constraints/py3.9.txt index 0625d72f..608df10d 100644 --- a/.constraints/py3.9.txt +++ b/.constraints/py3.9.txt @@ -8,29 +8,28 @@ argon2-cffi-bindings==21.2.0 arrow==1.3.0 asttokens==2.4.1 async-lru==2.0.4 -attrs==23.2.0 +attrs==24.2.0 babel==2.15.0 beautifulsoup4==4.12.3 -black==24.4.2 bleach==6.1.0 -cachetools==5.3.3 +cachetools==5.4.0 cattrs==23.2.3 -certifi==2024.6.2 -cffi==1.16.0 +certifi==2024.7.4 +cffi==1.17.0 cfgv==3.4.0 chardet==5.2.0 charset-normalizer==3.3.2 click==8.1.7 colorama==0.4.6 comm==0.2.2 -coverage==7.5.4 -debugpy==1.8.1 +coverage==7.6.1 +debugpy==1.8.5 decorator==5.1.1 defusedxml==0.7.1 distlib==0.3.8 docstring-to-markdown==0.15 docutils==0.21.2 -exceptiongroup==1.2.1 +exceptiongroup==1.2.2 execnet==2.1.1 executing==2.0.1 fastjsonschema==2.20.0 @@ -45,37 +44,36 @@ h11==0.14.0 hepunits==2.3.4 httpcore==1.0.5 httpx==0.27.0 -identify==2.5.36 +identify==2.6.0 idna==3.7 imagesize==1.4.1 -importlib-metadata==7.2.1 +importlib-metadata==8.2.0 iniconfig==2.0.0 -ipykernel==6.29.4 +ipykernel==6.29.5 ipython==8.18.1 ipywidgets==8.1.3 isoduration==20.11.0 -isort==5.13.2 jedi==0.19.1 jinja2==3.1.4 json5==0.9.25 jsonpointer==3.0.0 -jsonschema==4.22.0 +jsonschema==4.23.0 jsonschema-specifications==2023.12.1 jupyter-cache==1.0.0 jupyter-client==8.6.2 jupyter-core==5.7.2 jupyter-events==0.10.0 jupyter-lsp==2.2.5 -jupyter-server==2.14.1 +jupyter-server==2.14.2 jupyter-server-mathjax==0.2.6 jupyter-server-terminals==0.5.3 -jupyterlab==4.2.2 -jupyterlab-code-formatter==2.2.1 +jupyterlab==4.2.4 +jupyterlab-code-formatter==3.0.1 jupyterlab-git==0.50.1 jupyterlab-lsp==5.1.0 jupyterlab-myst==2.4.2 jupyterlab-pygments==0.3.0 -jupyterlab-server==2.27.2 +jupyterlab-server==2.27.3 jupyterlab-widgets==3.0.11 latexcodec==3.0.0 lsprotocol==2023.0.1 @@ -85,9 +83,9 @@ matplotlib-inline==0.1.7 mdit-py-plugins==0.4.1 mdurl==0.1.2 mistune==3.0.2 -mypy==1.10.0 +mypy==1.11.1 mypy-extensions==1.0.0 -myst-nb==1.1.0 +myst-nb==1.1.1 myst-parser==3.0.1 nbclient==0.6.8 nbconvert==7.16.4 @@ -102,25 +100,24 @@ packaging==24.1 pandocfilters==1.5.1 parso==0.8.4 particle==0.24.0 -pathspec==0.12.1 pexpect==4.9.0 platformdirs==4.2.2 pluggy==1.5.0 -pre-commit==3.7.1 +pre-commit==3.8.0 prometheus-client==0.20.0 prompt-toolkit==3.0.47 psutil==6.0.0 ptyprocess==0.7.0 -pure-eval==0.2.2 +pure-eval==0.2.3 pybtex==0.24.0 pybtex-docutils==1.0.3 pycparser==2.22 -pydata-sphinx-theme==0.15.3 +pydata-sphinx-theme==0.15.4 pydot==1.4.2 pygments==2.18.0 pyparsing==3.1.2 pyproject-api==1.7.1 -pytest==8.2.2 +pytest==8.3.2 pytest-cov==5.0.0 pytest-profiling==1.7.0 pytest-xdist==3.6.1 @@ -128,70 +125,70 @@ python-constraint2==2.0.0b5 python-dateutil==2.9.0.post0 python-json-logger==2.0.7 python-lsp-jsonrpc==1.1.2 -python-lsp-ruff==2.2.1 +python-lsp-ruff==2.2.2 python-lsp-server==1.11.0 pytoolconfig==1.3.1 -pyyaml==6.0.1 -pyzmq==26.0.3 +pyyaml==6.0.2 +pyzmq==26.1.0 referencing==0.35.1 requests==2.32.3 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 rope==1.13.0 -rpds-py==0.18.1 -ruff==0.4.10 +rpds-py==0.20.0 +ruff==0.5.6 send2trash==1.8.3 six==1.16.0 smmap==5.0.1 sniffio==1.3.1 snowballstemmer==2.2.0 soupsieve==2.5 -sphinx==7.3.7 +sphinx==7.4.7 sphinx-api-relink==0.0.9 sphinx-autobuild==2024.4.16 sphinx-book-theme==1.1.3 sphinx-codeautolink==0.15.2 sphinx-comments==0.0.3 sphinx-copybutton==0.5.2 -sphinx-design==0.6.0 +sphinx-design==0.6.1 sphinx-hep-pdgref==0.2.0 sphinx-pybtex-etal-style==0.0.2 sphinx-thebe==0.3.1 sphinx-togglebutton==0.3.2 -sphinxcontrib-applehelp==1.0.8 +sphinxcontrib-applehelp==2.0.0 sphinxcontrib-bibtex==2.6.2 -sphinxcontrib-devhelp==1.0.6 -sphinxcontrib-htmlhelp==2.0.5 +sphinxcontrib-devhelp==2.0.0 +sphinxcontrib-htmlhelp==2.1.0 sphinxcontrib-jsmath==1.0.1 -sphinxcontrib-qthelp==1.0.7 -sphinxcontrib-serializinghtml==1.1.10 -sqlalchemy==2.0.31 +sphinxcontrib-qthelp==2.0.0 +sphinxcontrib-serializinghtml==2.0.0 +sqlalchemy==2.0.32 stack-data==0.6.3 -starlette==0.37.2 +starlette==0.38.2 tabulate==0.9.0 terminado==0.18.1 tinycss2==1.3.0 tomli==2.0.1 tornado==6.4.1 -tox==4.15.1 -tqdm==4.66.4 +tox==4.17.0 +tqdm==4.66.5 traitlets==5.14.3 types-python-dateutil==2.9.0.20240316 -types-pyyaml==6.0.12.20240311 -types-setuptools==70.0.0.20240524 +types-pyyaml==6.0.12.20240724 +types-setuptools==71.1.0.20240806 typing-extensions==4.12.2 ujson==5.10.0 uri-template==1.3.0 urllib3==2.2.2 -uvicorn==0.30.1 +uvicorn==0.30.5 virtualenv==20.26.3 -watchfiles==0.22.0 +watchfiles==0.23.0 wcwidth==0.2.13 webcolors==24.6.0 webencodings==0.5.1 websocket-client==1.8.0 websockets==12.0 -wheel==0.43.0 +wheel==0.44.0 widgetsnbextension==4.0.11 zipp==3.19.2 diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..cce3aa58 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +layout anaconda diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1f589aaa..234ffcd2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -42,7 +42,7 @@ repos: metadata.vscode - repo: https://github.com/ComPWA/policy - rev: 0.3.10 + rev: 0.3.18 hooks: - id: check-dev-files args: @@ -61,7 +61,7 @@ repos: - --extras-require=doc,viz - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.10 + rev: v0.5.6 hooks: - id: ruff args: [--fix] @@ -110,7 +110,7 @@ repos: - --in-place - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.28.5 + rev: 0.29.1 hooks: - id: check-jsonschema name: Check CITATION.cff @@ -123,7 +123,7 @@ repos: pass_filenames: false - repo: https://github.com/streetsidesoftware/cspell-cli - rev: v8.9.0 + rev: v8.13.1 hooks: - id: cspell @@ -149,6 +149,6 @@ repos: - python - repo: https://github.com/ComPWA/mirrors-pyright - rev: v1.1.368 + rev: v1.1.374 hooks: - id: pyright diff --git a/.vscode/settings.json b/.vscode/settings.json index ff712ff7..a5b46e91 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -33,6 +33,9 @@ "cSpell.enabled": true, "diffEditor.experimental.showMoves": true, "editor.formatOnSave": true, + "files.associations": { + "**/.constraints/py*.txt": "pip-requirements" + }, "files.watcherExclude": { "**/*_cache/**": true, "**/.eggs/**": true, @@ -64,6 +67,7 @@ "python.analysis.autoImportCompletions": false, "python.analysis.inlayHints.pytestParameters": true, "python.analysis.typeCheckingMode": "strict", + "python.terminal.activateEnvironment": false, "python.testing.pytestArgs": ["--color=no", "--no-cov"], "python.testing.pytestEnabled": true, "python.testing.unittestEnabled": false, diff --git a/pyproject.toml b/pyproject.toml index bea089fe..f836a7f9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -82,11 +82,9 @@ doc = [ 'sphinx-pybtex-etal-style', ] jupyter = [ - "black", "ipywidgets", - "isort", "jupyterlab", - "jupyterlab-code-formatter", + "jupyterlab-code-formatter >=3.0.0", "jupyterlab-lsp", "python-lsp-server[rope]", 'jupyterlab-git', @@ -256,6 +254,7 @@ addopts = [ ] filterwarnings = [ "error", + "ignore: The `hash` argument is deprecated in favor of `unsafe_hash` and will be removed in or after August 2025.:DeprecationWarning", "ignore:'importlib.abc.Traversable' is deprecated and slated for removal in Python 3.14:DeprecationWarning", "ignore:Passing a schema to Validator.iter_errors is deprecated.*:DeprecationWarning", "ignore:datetime.datetime.utcfromtimestamp\\(\\) is deprecated and scheduled for removal in a future version.*:DeprecationWarning", @@ -289,39 +288,10 @@ docstring-code-format = true line-ending = "lf" [tool.ruff.lint] -extend-select = [ - "A", - "B", - "BLE", - "C4", - "C90", - "D", - "EM", - "ERA", - "FA", - "I", - "ICN", - "INP", - "ISC", - "N", - "NPY", - "PGH", - "PIE", - "PL", - "Q", - "RET", - "RSE", - "RUF", - "S", - "SIM", - "T20", - "TCH", - "TID", - "TRY", - "UP", - "YTT", -] ignore = [ + "ANN401", + "COM812", + "CPY001", "D101", "D102", "D103", @@ -331,17 +301,32 @@ ignore = [ "D213", "D407", "D416", + "DOC", "E501", + "FBT00", + "FURB101", + "FURB103", + "FURB140", + "G004", "ISC001", "PLR0913", "PLR2004", "PLR5501", "PLW1514", "PLW2901", + "PT001", + "PTH", "SIM108", ] +select = ["ALL"] task-tags = ["cspell"] +[tool.ruff.lint.flake8-builtins] +builtins-ignorelist = ["display"] + +[tool.ruff.lint.flake8-comprehensions] +allow-dict-calls-with-keyword-arguments = true + [tool.ruff.lint.flake8-tidy-imports] ban-relative-imports = "all" @@ -350,15 +335,16 @@ split-on-trailing-comma = false [tool.ruff.lint.per-file-ignores] "*.ipynb" = [ + "ANN", "B018", "C90", "D", + "E303", "E402", "E703", "N806", "N816", "PLR09", - "PLR2004", "PLW0602", "PLW0603", "S101", @@ -379,19 +365,20 @@ split-on-trailing-comma = false "docs/conf.py" = [ "A001", "D100", + "FLY002", ] "setup.py" = ["D100"] "src/qrules/conservation_rules.py" = ["FA100"] "tests/*" = [ + "ANN", "D", "INP001", "PGH001", "PLC2701", - "PLR0913", - "PLR2004", "PLR6301", "S101", "S307", + "SLF001", "T20", ] diff --git a/src/qrules/argument_handling.py b/src/qrules/argument_handling.py index 8f3b7456..fcc214b6 100644 --- a/src/qrules/argument_handling.py +++ b/src/qrules/argument_handling.py @@ -80,7 +80,7 @@ def __call__( def _direct_qn_check( - qn_type: type[EdgeQuantumNumber] | type[NodeQuantumNumber], + qn_type: type[EdgeQuantumNumber | NodeQuantumNumber], ) -> Callable[[GraphElementPropertyMap], bool]: def wrapper(props: GraphElementPropertyMap) -> bool: return qn_type in props diff --git a/src/qrules/conservation_rules.py b/src/qrules/conservation_rules.py index bb1cc356..cf30bd0e 100644 --- a/src/qrules/conservation_rules.py +++ b/src/qrules/conservation_rules.py @@ -45,6 +45,7 @@ .. seealso:: :doc:`/usage/conservation` """ +import operator import sys from copy import deepcopy from functools import reduce @@ -113,7 +114,7 @@ def additive_quantum_number_rule( def decorator(rule_class: Any) -> EdgeQNConservationRule: def new_call( - self: Type[EdgeQNConservationRule], + self: Type[EdgeQNConservationRule], # noqa: ARG001 ingoing_edge_qns: List[quantum_number], # type: ignore[valid-type] outgoing_edge_qns: List[quantum_number], # type: ignore[valid-type] ) -> bool: @@ -259,7 +260,7 @@ def _get_c_parity_multiparticle( c_parities_part = [x.c_parity.value for x in part_qns if x.c_parity] # if all states have C parity defined, then just multiply them if len(c_parities_part) == len(part_qns): - return reduce(lambda x, y: x * y, c_parities_part, 1) + return reduce(operator.mul, c_parities_part, 1) # two particle case if len(part_qns) == 2: # noqa: SIM102 @@ -875,7 +876,7 @@ class MassEdgeInput: class MassConservation: """Mass conservation rule.""" - def __init__(self, width_factor: float): + def __init__(self, width_factor: float) -> None: self.__width_factor = width_factor def __call__( diff --git a/src/qrules/io/__init__.py b/src/qrules/io/__init__.py index 27efe3a6..06a28ac2 100644 --- a/src/qrules/io/__init__.py +++ b/src/qrules/io/__init__.py @@ -133,7 +133,7 @@ def load(filename: str | Path) -> object: class _IncreasedIndent(yaml.Dumper): - def increase_indent(self, flow: bool = False, indentless: bool = False) -> None: + def increase_indent(self, flow: bool = False, indentless: bool = False) -> None: # noqa: ARG002 return super().increase_indent(flow, False) def write_line_break(self, data: str | None = None) -> None: diff --git a/src/qrules/io/_dict.py b/src/qrules/io/_dict.py index 47b7bc72..3d52249f 100644 --- a/src/qrules/io/_dict.py +++ b/src/qrules/io/_dict.py @@ -28,7 +28,7 @@ def from_attrs_decorated(inst: Any) -> dict: ) -def _value_serializer(inst: type, field: attrs.Attribute, value: Any) -> Any: +def _value_serializer(inst: type, field: attrs.Attribute, value: Any) -> Any: # noqa: ARG001 if isinstance(value, abc.Mapping): if all(isinstance(p, Particle) for p in value.values()): return {k: v.name for k, v in value.items()} diff --git a/src/qrules/io/_dot.py b/src/qrules/io/_dot.py index f7ab24c1..e9ffd723 100644 --- a/src/qrules/io/_dot.py +++ b/src/qrules/io/_dot.py @@ -30,7 +30,7 @@ _LOGGER = logging.getLogger(__name__) -def _check_booleans(instance: GraphPrinter, attribute: Attribute, value: bool) -> None: +def _check_booleans(instance: GraphPrinter, attribute: Attribute, value: bool) -> None: # noqa: ARG001 if instance.strip_spin and instance.collapse_graphs: msg = "Cannot both strip spin and collapse graphs" raise ValueError(msg) diff --git a/src/qrules/particle.py b/src/qrules/particle.py index 9ddc931d..899b5449 100644 --- a/src/qrules/particle.py +++ b/src/qrules/particle.py @@ -13,6 +13,7 @@ import logging import re +import sys from collections import abc from difflib import get_close_matches from functools import total_ordering @@ -35,6 +36,10 @@ from qrules.conservation_rules import GellMannNishijimaInput, gellmann_nishijima from qrules.quantum_numbers import Parity, _to_fraction +if sys.version_info < (3, 11): + from typing_extensions import Self +else: + from typing import Self if TYPE_CHECKING: from IPython.lib.pretty import PrettyPrinter from particle import Particle as PdgDatabase @@ -289,7 +294,7 @@ def __iter__(self) -> Iterator[Particle]: def __len__(self) -> int: return len(self.__particles) - def __iadd__(self, other: Particle | ParticleCollection) -> ParticleCollection: + def __iadd__(self, other: Particle | ParticleCollection) -> Self: if isinstance(other, Particle): self.add(other) elif isinstance(other, ParticleCollection): @@ -422,35 +427,23 @@ def create_particle( # noqa: PLR0917 g_parity: int | None = None, ) -> Particle: return Particle( - name=name if name else template_particle.name, - pid=pid if pid else template_particle.pid, - latex=latex if latex else template_particle.latex, + name=name or template_particle.name, + pid=pid or template_particle.pid, + latex=latex or template_particle.latex, mass=mass if mass is not None else template_particle.mass, - width=width if width else template_particle.width, - spin=spin if spin else template_particle.spin, - charge=charge if charge else template_particle.charge, - strangeness=strangeness if strangeness else template_particle.strangeness, - charmness=charmness if charmness else template_particle.charmness, - bottomness=bottomness if bottomness else template_particle.bottomness, - topness=topness if topness else template_particle.topness, - baryon_number=( - baryon_number if baryon_number else template_particle.baryon_number - ), + width=width or template_particle.width, + spin=spin or template_particle.spin, + charge=charge or template_particle.charge, + strangeness=strangeness or template_particle.strangeness, + charmness=charmness or template_particle.charmness, + bottomness=bottomness or template_particle.bottomness, + topness=topness or template_particle.topness, + baryon_number=(baryon_number or template_particle.baryon_number), electron_lepton_number=( - electron_lepton_number - if electron_lepton_number - else template_particle.electron_lepton_number - ), - muon_lepton_number=( - muon_lepton_number - if muon_lepton_number - else template_particle.muon_lepton_number - ), - tau_lepton_number=( - tau_lepton_number - if tau_lepton_number - else template_particle.tau_lepton_number + electron_lepton_number or template_particle.electron_lepton_number ), + muon_lepton_number=(muon_lepton_number or template_particle.muon_lepton_number), + tau_lepton_number=(tau_lepton_number or template_particle.tau_lepton_number), isospin=template_particle.isospin if isospin is None else isospin, parity=template_particle.parity if parity is None else Parity(parity), c_parity=template_particle.c_parity if c_parity is None else Parity(c_parity), @@ -473,9 +466,9 @@ def create_antiparticle( else: parity = -template_particle.parity return Particle( - name=new_name if new_name else "anti-" + template_particle.name, + name=new_name or "anti-" + template_particle.name, pid=-template_particle.pid, - latex=new_latex if new_latex else Rf"\overline{{{template_particle.latex}}}", + latex=new_latex or Rf"\overline{{{template_particle.latex}}}", mass=template_particle.mass, width=template_particle.width, charge=-template_particle.charge, @@ -526,7 +519,7 @@ def load_pdg() -> ParticleCollection: } -def __sign(value: float | int) -> int: +def __sign(value: float) -> int: return int(copysign(1, value)) diff --git a/src/qrules/quantum_numbers.py b/src/qrules/quantum_numbers.py index 9db7fd8d..a1a4f63f 100644 --- a/src/qrules/quantum_numbers.py +++ b/src/qrules/quantum_numbers.py @@ -61,7 +61,7 @@ def __repr__(self) -> str: return f"{type(self).__name__}({_to_fraction(self.value)})" -def _to_fraction(value: float | int, render_plus: bool = False) -> str: +def _to_fraction(value: float, render_plus: bool = False) -> str: label = str(Fraction(value)) if render_plus and value > 0: return f"+{label}" diff --git a/src/qrules/solving.py b/src/qrules/solving.py index d2fc315d..73b22a50 100644 --- a/src/qrules/solving.py +++ b/src/qrules/solving.py @@ -10,6 +10,7 @@ import inspect import logging +import operator from abc import ABC, abstractmethod from collections import defaultdict from copy import copy @@ -125,15 +126,10 @@ def get_name(rule: Any) -> str: return rule return type(rule).__name__ - converted_dict = defaultdict(set) - for node_id, rule_set in rules.items(): - rule_name_set = set() - for rule_tuple in rule_set: - rule_name_set.add(get_name(rule_tuple)) - - converted_dict[node_id] = rule_name_set - - return converted_dict + return { + node_id: {get_name(rule) for rule in rule_set} + for node_id, rule_set in rules.items() + } @implement_pretty_repr @@ -239,11 +235,7 @@ def __get_candidate_states( state: GraphEdgePropertyMap, allowed_states: Iterable[GraphEdgePropertyMap], ) -> list[GraphEdgePropertyMap]: - candidates = [] - for candidate in allowed_states: - if __is_sub_mapping(state, candidate): - candidates.append(candidate) - return candidates + return [s for s in allowed_states if __is_sub_mapping(state, s)] def __is_sub_mapping( @@ -397,7 +389,7 @@ def _create_variable_containers( def _create_variable_string( element_id: int, - qn_type: type[EdgeQuantumNumber] | type[NodeQuantumNumber], + qn_type: type[EdgeQuantumNumber | NodeQuantumNumber], ) -> str: return str(element_id) + "-" + qn_type.__name__ @@ -423,7 +415,9 @@ class CSPSolver(Solver): wrapper class serves as an adapter. """ - def __init__(self, allowed_intermediate_states: Iterable[GraphEdgePropertyMap]): + def __init__( + self, allowed_intermediate_states: Iterable[GraphEdgePropertyMap] + ) -> None: self.__variables: set[_EdgeVariableInfo | _NodeVariableInfo] = set() self.__var_string_to_data: dict[str, _EdgeVariableInfo | _NodeVariableInfo] = {} self.__node_rules: dict[int, set[Rule]] = defaultdict(set) @@ -549,7 +543,9 @@ def get_rules_by_priority( for x in graph_element_settings.conservation_rules ] # then sort according to priority - sorted_list = sorted(priority_list, key=lambda x: x[1], reverse=True) + sorted_list = sorted( + priority_list, key=operator.itemgetter(1), reverse=True + ) # and strip away the priorities again return [x[0] for x in sorted_list] @@ -781,7 +777,7 @@ def rule_passes(self) -> dict[tuple[int, Rule], int]: _QNType = TypeVar("_QNType", EdgeQuantumNumber, NodeQuantumNumber) -class _GraphElementConstraint(Generic[_QNType], Constraint): +class _GraphElementConstraint(Constraint, Generic[_QNType]): """Wrapper class of the `~constraints.Constraint` class. This allows a customized definition of conservation rules, and hence a cleaner user @@ -836,9 +832,9 @@ def __initialize_variable_containers( def __call__( self, variables: set[str], - domains: dict, + domains: dict, # noqa: ARG002 assignments: dict, - forwardcheck: bool = False, + forwardcheck: bool = False, # noqa: ARG002 _unassigned: Variable = Unassigned, ) -> bool: """Perform the constraint checking. @@ -977,9 +973,9 @@ def _initialize_edge_container( def __call__( self, variables: set[str], - domains: dict, + domains: dict, # noqa: ARG002 assignments: dict, - forwardcheck: bool = False, + forwardcheck: bool = False, # noqa: ARG002 _unassigned: Variable = Unassigned, ) -> bool: """Perform the constraint checking. diff --git a/src/qrules/system_control.py b/src/qrules/system_control.py index f4c26799..0dfe4f63 100644 --- a/src/qrules/system_control.py +++ b/src/qrules/system_control.py @@ -3,6 +3,7 @@ from __future__ import annotations import logging +import operator from abc import ABC, abstractmethod from typing import TYPE_CHECKING, Callable, Dict, Iterable, List, Tuple @@ -160,7 +161,7 @@ def check( # noqa: PLR6301 self, in_states: list[ParticleWithSpin], out_states: list[ParticleWithSpin], - interactions: InteractionProperties, + interactions: InteractionProperties, # noqa: ARG002 ) -> list[InteractionType]: int_types = list(InteractionType) for particle, _ in in_states + out_states: @@ -177,7 +178,7 @@ def check( # noqa: PLR6301 self, in_states: list[ParticleWithSpin], out_states: list[ParticleWithSpin], - interactions: InteractionProperties, + interactions: InteractionProperties, # noqa: ARG002 ) -> list[InteractionType]: node_interaction_types = list(InteractionType) for particle, _ in in_states + out_states: @@ -253,7 +254,7 @@ def _check_equal_ignoring_qns( for graph in solutions: if isinstance(graph, MutableTransition) and graph.compare( ref_graph, - state_comparator=lambda e1, e2: e1 == e2, + state_comparator=operator.eq, interaction_comparator=interaction_comparator, ): found_graph = graph @@ -267,7 +268,7 @@ class NodePropertyComparator: def __init__( self, ignored_qn_list: set[type[NodeQuantumNumber]] | None = None ) -> None: - self.__ignored_qn_list = ignored_qn_list if ignored_qn_list else set() + self.__ignored_qn_list = ignored_qn_list or set() def __call__( self, diff --git a/src/qrules/topology.py b/src/qrules/topology.py index e8c9ffb7..f0b4c817 100644 --- a/src/qrules/topology.py +++ b/src/qrules/topology.py @@ -79,7 +79,7 @@ class FrozenDict(abc.Hashable, abc.Mapping, Generic[KT, VT]): :meth:`~object.__lt__` method. """ - def __init__(self, mapping: Mapping | None = None): + def __init__(self, mapping: Mapping | None = None) -> None: self.__mapping: dict[KT, VT] = {} if mapping is not None: self.__mapping = dict(mapping) @@ -753,7 +753,7 @@ def _attach_node_to_edges( ingoing_edge_ids: Iterable[int], ) -> tuple[MutableTopology, list[int]]: temp_graph = copy.deepcopy(graph[0]) - new_open_end_lines = list(copy.deepcopy(graph[1])) + new_open_end_lines = list(graph[1]) # add node new_node_id = len(temp_graph.nodes) @@ -775,10 +775,9 @@ def _attach_node_to_edges( ) temp_graph.add_edges(new_edge_ids) temp_graph.attach_edges_to_node_outgoing(new_edge_ids, new_node_id) - for edge_id in new_edge_ids: - new_open_end_lines.append(edge_id) + new_open_end_lines.extend(new_edge_ids) - return (temp_graph, new_open_end_lines) + return temp_graph, new_open_end_lines EdgeType = TypeVar("EdgeType") diff --git a/tests/channels/test_jpsi_to_gamma_pi0_pi0.py b/tests/channels/test_jpsi_to_gamma_pi0_pi0.py index 722e7237..31e79f9d 100644 --- a/tests/channels/test_jpsi_to_gamma_pi0_pi0.py +++ b/tests/channels/test_jpsi_to_gamma_pi0_pi0.py @@ -24,7 +24,7 @@ ), ], ) -@pytest.mark.slow() +@pytest.mark.slow def test_number_of_solutions( particle_database, allowed_intermediate_particles, diff --git a/tests/channels/test_nbody_reactions.py b/tests/channels/test_nbody_reactions.py index 6d34ea32..e854bfe9 100644 --- a/tests/channels/test_nbody_reactions.py +++ b/tests/channels/test_nbody_reactions.py @@ -18,7 +18,7 @@ def reduce_violated_rules( return reduced_violations -@pytest.mark.slow() +@pytest.mark.slow @pytest.mark.parametrize( ("test_input", "expected"), [ diff --git a/tests/channels/test_y_to_d0_d0bar_pi0_pi0.py b/tests/channels/test_y_to_d0_d0bar_pi0_pi0.py index 1d518311..11a72f4d 100644 --- a/tests/channels/test_y_to_d0_d0bar_pi0_pi0.py +++ b/tests/channels/test_y_to_d0_d0bar_pi0_pi0.py @@ -23,7 +23,7 @@ def test_simple(formalism, n_solutions, particle_database): assert len(reaction.transitions) == n_solutions -@pytest.mark.slow() +@pytest.mark.slow @pytest.mark.parametrize( ("formalism", "n_solutions"), [ diff --git a/tests/unit/test_parity_prefactor.py b/tests/unit/test_parity_prefactor.py index 1f143382..90b9aa48 100644 --- a/tests/unit/test_parity_prefactor.py +++ b/tests/unit/test_parity_prefactor.py @@ -19,7 +19,6 @@ class Input(NamedTuple): ( "test_input", "ingoing_state", - "related_component_names", "relative_parity_prefactor", ), [ @@ -31,10 +30,6 @@ class Input(NamedTuple): ["pi0", "pi0"], ), "J/psi(1S)", - ( - "J/psi(1S)_1_to_f(0)(980)_0+gamma_1;f(0)(980)_0_to_pi0_0+pi0_0;", - "J/psi(1S)_1_to_f(0)(980)_0+gamma_-1;f(0)(980)_0_to_pi0_0+pi0_0;", - ), 1.0, ), ( @@ -45,10 +40,6 @@ class Input(NamedTuple): ["pi+", "pi-"], ), "J/psi(1S)", - ( - "J/psi(1S)_1_to_pi0_0+rho(770)0_1;rho(770)0_1_to_pi+_0+pi-_0;", - "J/psi(1S)_1_to_pi0_0+rho(770)0_-1;rho(770)0_-1_to_pi+_0+pi-_0;", - ), -1.0, ), ], @@ -56,7 +47,6 @@ class Input(NamedTuple): def test_parity_prefactor( test_input: Input, ingoing_state: str, - related_component_names: tuple[str, str], relative_parity_prefactor: float, ) -> None: stm = StateTransitionManager( diff --git a/tests/unit/test_particle.py b/tests/unit/test_particle.py index fc62d70b..4d68c984 100644 --- a/tests/unit/test_particle.py +++ b/tests/unit/test_particle.py @@ -323,11 +323,11 @@ def test_exceptions(self, particle_database: ParticleCollection): ): particle_database += create_particle(gamma, name="gamma_new") with pytest.raises(NotImplementedError): - particle_database.find(3.14) # type: ignore[arg-type] + particle_database.find(3.12) # type: ignore[arg-type] with pytest.raises(NotImplementedError): - particle_database += 3.14 # type: ignore[arg-type] + particle_database += 3.12 # type: ignore[arg-type] with pytest.raises(NotImplementedError): - assert 3.14 in particle_database + assert 3.12 in particle_database with pytest.raises(AssertionError): assert gamma == "gamma" @@ -383,7 +383,7 @@ def test_repr(self, instance: Spin, repr_method): [(0.3, 0.3), (1.0, 0.5), (0.5, 0.0), (-0.5, 0.5)], ) def test_exceptions(self, magnitude, projection): - regex_pattern = "|".join([ + regex_pattern = "|".join([ # noqa: FLY002 r"Spin magnitude \d\.\d has to be a multitude of \d\.[05]", r"\(projection - magnitude\) should be integer", r"Spin magnitude has to be positive", @@ -479,7 +479,7 @@ def test_create_particle_isospin(): name="some particle", pid=0, spin=0, - mass=3.14, + mass=3.12, ) new_isospin = Spin(0, 0) new_particle = create_particle( diff --git a/tests/unit/test_system_control.py b/tests/unit/test_system_control.py index 1f8e79a6..7e6433af 100644 --- a/tests/unit/test_system_control.py +++ b/tests/unit/test_system_control.py @@ -273,15 +273,12 @@ class TestSolutionFilter: ) def test_remove_duplicates(self, ls_pairs, result, particle_database): pi0 = particle_database["pi0"] - graphs = [] - for ls_pair in ls_pairs: - graphs.append(make_ls_test_graph(ls_pair[0], ls_pair[1], pi0)) + graphs = [make_ls_test_graph(L, S, pi0) for L, S in ls_pairs] results = remove_duplicate_solutions(graphs) assert len(results) == result - for ls_pair in ls_pairs: - graphs.append(make_ls_test_graph_scrambled(ls_pair[0], ls_pair[1], pi0)) + graphs.extend(make_ls_test_graph_scrambled(L, S, pi0) for L, S in ls_pairs) results = remove_duplicate_solutions(graphs) assert len(results) == result @@ -389,7 +386,7 @@ def test_edge_swap(particle_database, initial_state, final_state): problem_sets = stm.create_problem_sets() init_graphs: list[MutableTransition[ParticleWithSpin, InteractionProperties]] = [] - for _, problem_set_list in problem_sets.items(): + for problem_set_list in problem_sets.values(): init_graphs.extend([_create_graph(x) for x in problem_set_list]) for graph in init_graphs: @@ -435,7 +432,7 @@ def test_match_external_edges(particle_database, initial_state, final_state): problem_sets = stm.create_problem_sets() init_graphs: list[MutableTransition[ParticleWithSpin, InteractionProperties]] = [] - for _, problem_set_list in problem_sets.items(): + for problem_set_list in problem_sets.values(): init_graphs.extend([_create_graph(x) for x in problem_set_list]) match_external_edges(init_graphs) @@ -518,7 +515,7 @@ def test_external_edge_identical_particle_combinatorics( problem_sets = stm.create_problem_sets() init_graphs = [] - for _, problem_set_list in problem_sets.items(): + for problem_set_list in problem_sets.values(): init_graphs.extend([_create_graph(x) for x in problem_set_list]) match_external_edges(init_graphs)