From cb911077f75af4f04616f9c4f59ef2d965ffce41 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 7 Jul 2023 03:03:30 +0200 Subject: [PATCH 1/2] DX!: switch to Ruff as linter (#198) * MAINT: implement updates from pre-commit hooks * MAINT: update pip constraints and pre-commit * MAINT: upgrade to Jupyter Lab v4 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: GitHub Co-authored-by: Remco de Boer <29308176+redeboer@users.noreply.github.com> --- .constraints/py3.10.txt | 70 ++++++++-------- .constraints/py3.11.txt | 68 +++++++-------- .constraints/py3.7.txt | 47 +++++------ .constraints/py3.8.txt | 72 ++++++++-------- .constraints/py3.9.txt | 70 ++++++++-------- .cspell.json | 4 +- .flake8 | 33 -------- .gitpod.yml | 2 + .pre-commit-config.yaml | 27 +++--- .vscode/extensions.json | 10 +++ .vscode/settings.json | 4 +- README.md | 2 +- docs/adr/001/operators.ipynb | 4 +- docs/adr/001/sympy.ipynb | 3 +- docs/adr/002/composition.ipynb | 2 +- docs/adr/002/expr.ipynb | 13 +-- docs/adr/002/helpers.py | 3 +- docs/conf.py | 29 +++---- docs/develop.md | 14 ++-- docs/report/000.ipynb | 3 +- docs/report/001.ipynb | 3 +- docs/report/002.ipynb | 2 +- docs/report/003.ipynb | 11 +-- docs/report/004.ipynb | 40 ++++----- docs/report/005.ipynb | 10 +-- docs/report/006.ipynb | 1 + docs/report/007.ipynb | 1 + docs/report/009.ipynb | 15 ++-- docs/report/010.ipynb | 14 ++-- docs/report/011.ipynb | 27 +++--- docs/report/013.ipynb | 10 ++- docs/report/014.ipynb | 29 ++++--- docs/report/015.ipynb | 2 +- docs/report/016.ipynb | 5 +- docs/report/017.ipynb | 17 ++-- docs/report/018.ipynb | 6 +- docs/report/021.ipynb | 15 ++-- docs/report/022.ipynb | 6 +- pyproject.toml | 149 +++++++++++++++++++++++++++++++-- pyrightconfig.json | 34 -------- pytest.ini | 21 ----- setup.cfg | 23 ++--- 42 files changed, 496 insertions(+), 425 deletions(-) delete mode 100644 .flake8 delete mode 100644 pyrightconfig.json delete mode 100644 pytest.ini diff --git a/.constraints/py3.10.txt b/.constraints/py3.10.txt index 96a738f8..00cf381f 100644 --- a/.constraints/py3.10.txt +++ b/.constraints/py3.10.txt @@ -5,16 +5,14 @@ # pip-compile --extra=dev --no-annotate --output-file=.constraints/py3.10.txt --strip-extras setup.py # accessible-pygments==0.0.4 -aiofiles==22.1.0 -aiosqlite==0.19.0 alabaster==0.7.13 -anyio==3.7.0 +anyio==3.7.1 appdirs==1.4.4 -aquirdturtle-collapsible-headings==3.1.0 argon2-cffi==21.3.0 argon2-cffi-bindings==21.2.0 arrow==1.2.3 asttokens==2.2.1 +async-lru==2.0.2 attrs==23.1.0 babel==2.12.1 backcall==0.2.0 @@ -28,7 +26,7 @@ cffi==1.15.1 cfgv==3.3.1 chardet==5.1.0 charset-normalizer==3.1.0 -click==8.1.3 +click==8.1.4 colorama==0.4.6 comm==0.1.3 contourpy==1.1.0 @@ -39,7 +37,7 @@ defusedxml==0.7.1 distlib==0.3.6 docutils==0.19 esbonio==0.16.1 -exceptiongroup==1.1.1 +exceptiongroup==1.1.2 executing==1.2.0 fastjsonschema==2.17.1 filelock==3.12.2 @@ -52,55 +50,53 @@ idna==3.4 imagesize==1.4.1 importlib-metadata==6.7.0 iniconfig==2.0.0 -ipykernel==6.23.2 +ipykernel==6.24.0 ipympl==0.9.3 ipython==8.14.0 ipython-genutils==0.2.0 -ipywidgets==8.0.6 +ipywidgets==8.0.7 isoduration==20.11.0 -isort==5.12.0 jedi==0.18.2 jinja2==3.1.2 json5==0.9.14 jsonpointer==2.4 -jsonschema==4.17.3 +jsonschema==4.18.0 +jsonschema-specifications==2023.6.1 jupyter==1.0.0 jupyter-cache==0.6.1 -jupyter-client==8.2.0 +jupyter-client==8.3.0 jupyter-console==6.6.3 jupyter-core==5.3.1 jupyter-events==0.6.3 -jupyter-server==2.6.0 -jupyter-server-fileid==0.9.0 +jupyter-lsp==2.2.0 +jupyter-server==2.7.0 jupyter-server-terminals==0.4.4 -jupyter-server-ydoc==0.8.0 -jupyter-ydoc==0.2.4 -jupyterlab==3.6.4 +jupyterlab==4.0.2 jupyterlab-code-formatter==2.2.1 -jupyterlab-myst==1.2.0 +jupyterlab-myst==2.0.1 jupyterlab-pygments==0.2.2 jupyterlab-server==2.23.0 -jupyterlab-widgets==3.0.7 +jupyterlab-widgets==3.0.8 kiwisolver==1.4.4 latexcodec==2.0.1 livereload==2.6.3 lsprotocol==2023.0.0a2 markdown-it-py==2.2.0 markupsafe==2.1.3 -matplotlib==3.7.1 +matplotlib==3.7.2 matplotlib-inline==0.1.6 mdit-py-plugins==0.3.5 mdurl==0.1.2 mistune==3.0.1 -mpl-interactions==0.23.0 +mpl-interactions==0.23.1 mypy-extensions==1.0.0 myst-nb==0.17.2 myst-parser==0.18.1 nbclassic==1.0.0 -nbclient==0.5.13 +nbclient==0.6.8 nbconvert==7.6.0 nbformat==5.9.0 -nbmake==1.3.0 +nbmake==1.4.1 nest-asyncio==1.5.6 nodeenv==1.8.0 notebook==6.5.4 @@ -113,37 +109,39 @@ parso==0.8.3 pathspec==0.11.1 pexpect==4.8.0 pickleshare==0.7.5 -pillow==9.5.0 -platformdirs==3.7.0 +pillow==10.0.0 +platformdirs==3.8.1 pluggy==1.2.0 pre-commit==3.3.3 prometheus-client==0.17.0 -prompt-toolkit==3.0.38 +prompt-toolkit==3.0.39 psutil==5.9.5 ptyprocess==0.7.0 pure-eval==0.2.2 pybtex==0.24.0 pybtex-docutils==1.0.2 pycparser==2.21 -pydantic==1.10.9 +pydantic==1.10.11 pydata-sphinx-theme==0.13.3 pygls==1.0.2 pygments==2.15.1 -pyparsing==3.1.0 -pyproject-api==1.5.2 -pyrsistent==0.19.3 +pyparsing==3.0.9 +pyproject-api==1.5.3 pyspellchecker==0.7.2 -pytest==7.3.2 +pytest==7.4.0 python-dateutil==2.8.2 python-json-logger==2.0.7 pyyaml==6.0 pyzmq==25.1.0 qtconsole==5.4.3 qtpy==2.3.1 +referencing==0.29.1 requests==2.31.0 requests-file==1.5.1 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 +rpds-py==0.8.8 +ruff==0.0.277 send2trash==1.8.2 six==1.16.0 sniffio==1.3.0 @@ -170,28 +168,26 @@ sphinxcontrib-jsmath==1.0.1 sphinxcontrib-plantuml==0.25 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 -sqlalchemy==2.0.16 +sqlalchemy==2.0.18 stack-data==0.6.2 tabulate==0.9.0 terminado==0.17.1 tinycss2==1.2.1 tomli==2.0.1 tornado==6.3.2 -tox==4.6.3 +tox==4.6.4 traitlets==5.9.0 typeguard==3.0.2 -typing-extensions==4.6.3 +typing-extensions==4.7.1 uri-template==1.3.0 urllib3==2.0.3 virtualenv==20.23.1 wcwidth==0.2.6 webcolors==1.13 webencodings==0.5.1 -websocket-client==1.6.0 +websocket-client==1.6.1 wheel==0.40.0 -widgetsnbextension==4.0.7 -y-py==0.5.9 -ypy-websocket==0.8.2 +widgetsnbextension==4.0.8 zipp==3.15.0 # The following packages are considered to be unsafe in a requirements file: diff --git a/.constraints/py3.11.txt b/.constraints/py3.11.txt index e7e8e834..bb96e4ef 100644 --- a/.constraints/py3.11.txt +++ b/.constraints/py3.11.txt @@ -5,16 +5,14 @@ # pip-compile --extra=dev --no-annotate --output-file=.constraints/py3.11.txt --strip-extras setup.py # accessible-pygments==0.0.4 -aiofiles==22.1.0 -aiosqlite==0.19.0 alabaster==0.7.13 -anyio==3.7.0 +anyio==3.7.1 appdirs==1.4.4 -aquirdturtle-collapsible-headings==3.1.0 argon2-cffi==21.3.0 argon2-cffi-bindings==21.2.0 arrow==1.2.3 asttokens==2.2.1 +async-lru==2.0.2 attrs==23.1.0 babel==2.12.1 backcall==0.2.0 @@ -28,7 +26,7 @@ cffi==1.15.1 cfgv==3.3.1 chardet==5.1.0 charset-normalizer==3.1.0 -click==8.1.3 +click==8.1.4 colorama==0.4.6 comm==0.1.3 contourpy==1.1.0 @@ -51,55 +49,53 @@ idna==3.4 imagesize==1.4.1 importlib-metadata==6.7.0 iniconfig==2.0.0 -ipykernel==6.23.2 +ipykernel==6.24.0 ipympl==0.9.3 ipython==8.14.0 ipython-genutils==0.2.0 -ipywidgets==8.0.6 +ipywidgets==8.0.7 isoduration==20.11.0 -isort==5.12.0 jedi==0.18.2 jinja2==3.1.2 json5==0.9.14 jsonpointer==2.4 -jsonschema==4.17.3 +jsonschema==4.18.0 +jsonschema-specifications==2023.6.1 jupyter==1.0.0 jupyter-cache==0.6.1 -jupyter-client==8.2.0 +jupyter-client==8.3.0 jupyter-console==6.6.3 jupyter-core==5.3.1 jupyter-events==0.6.3 -jupyter-server==2.6.0 -jupyter-server-fileid==0.9.0 +jupyter-lsp==2.2.0 +jupyter-server==2.7.0 jupyter-server-terminals==0.4.4 -jupyter-server-ydoc==0.8.0 -jupyter-ydoc==0.2.4 -jupyterlab==3.6.4 +jupyterlab==4.0.2 jupyterlab-code-formatter==2.2.1 -jupyterlab-myst==1.2.0 +jupyterlab-myst==2.0.1 jupyterlab-pygments==0.2.2 jupyterlab-server==2.23.0 -jupyterlab-widgets==3.0.7 +jupyterlab-widgets==3.0.8 kiwisolver==1.4.4 latexcodec==2.0.1 livereload==2.6.3 lsprotocol==2023.0.0a2 markdown-it-py==2.2.0 markupsafe==2.1.3 -matplotlib==3.7.1 +matplotlib==3.7.2 matplotlib-inline==0.1.6 mdit-py-plugins==0.3.5 mdurl==0.1.2 mistune==3.0.1 -mpl-interactions==0.23.0 +mpl-interactions==0.23.1 mypy-extensions==1.0.0 myst-nb==0.17.2 myst-parser==0.18.1 nbclassic==1.0.0 -nbclient==0.5.13 +nbclient==0.6.8 nbconvert==7.6.0 nbformat==5.9.0 -nbmake==1.3.0 +nbmake==1.4.1 nest-asyncio==1.5.6 nodeenv==1.8.0 notebook==6.5.4 @@ -112,37 +108,39 @@ parso==0.8.3 pathspec==0.11.1 pexpect==4.8.0 pickleshare==0.7.5 -pillow==9.5.0 -platformdirs==3.7.0 +pillow==10.0.0 +platformdirs==3.8.1 pluggy==1.2.0 pre-commit==3.3.3 prometheus-client==0.17.0 -prompt-toolkit==3.0.38 +prompt-toolkit==3.0.39 psutil==5.9.5 ptyprocess==0.7.0 pure-eval==0.2.2 pybtex==0.24.0 pybtex-docutils==1.0.2 pycparser==2.21 -pydantic==1.10.9 +pydantic==1.10.11 pydata-sphinx-theme==0.13.3 pygls==1.0.2 pygments==2.15.1 -pyparsing==3.1.0 -pyproject-api==1.5.2 -pyrsistent==0.19.3 +pyparsing==3.0.9 +pyproject-api==1.5.3 pyspellchecker==0.7.2 -pytest==7.3.2 +pytest==7.4.0 python-dateutil==2.8.2 python-json-logger==2.0.7 pyyaml==6.0 pyzmq==25.1.0 qtconsole==5.4.3 qtpy==2.3.1 +referencing==0.29.1 requests==2.31.0 requests-file==1.5.1 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 +rpds-py==0.8.8 +ruff==0.0.277 send2trash==1.8.2 six==1.16.0 sniffio==1.3.0 @@ -169,27 +167,25 @@ sphinxcontrib-jsmath==1.0.1 sphinxcontrib-plantuml==0.25 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 -sqlalchemy==2.0.16 +sqlalchemy==2.0.18 stack-data==0.6.2 tabulate==0.9.0 terminado==0.17.1 tinycss2==1.2.1 tornado==6.3.2 -tox==4.6.3 +tox==4.6.4 traitlets==5.9.0 typeguard==3.0.2 -typing-extensions==4.6.3 +typing-extensions==4.7.1 uri-template==1.3.0 urllib3==2.0.3 virtualenv==20.23.1 wcwidth==0.2.6 webcolors==1.13 webencodings==0.5.1 -websocket-client==1.6.0 +websocket-client==1.6.1 wheel==0.40.0 -widgetsnbextension==4.0.7 -y-py==0.5.9 -ypy-websocket==0.8.2 +widgetsnbextension==4.0.8 zipp==3.15.0 # The following packages are considered to be unsafe in a requirements file: diff --git a/.constraints/py3.7.txt b/.constraints/py3.7.txt index 77059d61..1511de00 100644 --- a/.constraints/py3.7.txt +++ b/.constraints/py3.7.txt @@ -8,9 +8,8 @@ accessible-pygments==0.0.4 aiofiles==22.1.0 aiosqlite==0.19.0 alabaster==0.7.13 -anyio==3.7.0 +anyio==3.7.1 appdirs==1.4.4 -aquirdturtle-collapsible-headings==3.1.0 argon2-cffi==21.3.0 argon2-cffi-bindings==21.2.0 arrow==1.2.3 @@ -28,17 +27,17 @@ cffi==1.15.1 cfgv==3.3.1 chardet==5.1.0 charset-normalizer==3.1.0 -click==8.1.3 +click==8.1.4 colorama==0.4.6 cycler==0.11.0 debugpy==1.6.7 decorator==5.1.1 defusedxml==0.7.1 distlib==0.3.6 -docutils==0.17.1 +docutils==0.19 entrypoints==0.4 esbonio==0.16.1 -exceptiongroup==1.1.1 +exceptiongroup==1.1.2 fastjsonschema==2.17.1 filelock==3.12.2 fonttools==4.38.0 @@ -55,9 +54,8 @@ ipykernel==6.16.2 ipympl==0.9.3 ipython==7.34.0 ipython-genutils==0.2.0 -ipywidgets==8.0.6 +ipywidgets==8.0.7 isoduration==20.11.0 -isort==5.11.5 jedi==0.18.2 jinja2==3.1.2 json5==0.9.14 @@ -73,12 +71,12 @@ jupyter-server==1.24.0 jupyter-server-fileid==0.9.0 jupyter-server-ydoc==0.8.0 jupyter-ydoc==0.2.4 -jupyterlab==3.6.4 +jupyterlab==3.6.5 jupyterlab-code-formatter==2.2.1 jupyterlab-myst==1.2.0 jupyterlab-pygments==0.2.2 jupyterlab-server==2.23.0 -jupyterlab-widgets==3.0.7 +jupyterlab-widgets==3.0.8 kiwisolver==1.4.4 latexcodec==2.0.1 livereload==2.6.3 @@ -90,7 +88,7 @@ matplotlib-inline==0.1.6 mdit-py-plugins==0.3.5 mdurl==0.1.2 mistune==3.0.1 -mpl-interactions==0.23.0 +mpl-interactions==0.23.1 mypy-extensions==1.0.0 myst-nb==0.17.2 myst-parser==0.18.1 @@ -98,7 +96,7 @@ nbclassic==1.0.0 nbclient==0.5.13 nbconvert==7.6.0 nbformat==5.8.0 -nbmake==1.3.0 +nbmake==1.2.1 ; python_version == "3.7.*" nest-asyncio==1.5.6 nodeenv==1.8.0 notebook==6.5.4 @@ -112,25 +110,25 @@ pexpect==4.8.0 pickleshare==0.7.5 pillow==9.5.0 pkgutil-resolve-name==1.3.10 -platformdirs==3.7.0 +platformdirs==3.8.1 pluggy==1.2.0 pre-commit==2.21.0 prometheus-client==0.17.0 -prompt-toolkit==3.0.38 +prompt-toolkit==3.0.39 psutil==5.9.5 ptyprocess==0.7.0 pybtex==0.24.0 pybtex-docutils==1.0.2 pycparser==2.21 -pydantic==1.10.9 +pydantic==1.10.11 pydata-sphinx-theme==0.13.3 pygls==1.0.2 pygments==2.15.1 pyparsing==3.1.0 -pyproject-api==1.5.2 +pyproject-api==1.5.3 pyrsistent==0.19.3 pyspellchecker==0.7.2 -pytest==7.3.2 +pytest==7.4.0 python-dateutil==2.8.2 python-json-logger==2.0.7 pytz==2023.3 @@ -142,12 +140,13 @@ requests==2.31.0 requests-file==1.5.1 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 +ruff==0.0.277 send2trash==1.8.2 six==1.16.0 sniffio==1.3.0 snowballstemmer==2.2.0 soupsieve==2.4.1 -sphinx==4.3.2 ; python_version < "3.8.0" +sphinx==5.3.0 sphinx-autobuild==2021.3.14 sphinx-book-theme==1.0.1 sphinx-codeautolink==0.15.0 @@ -168,28 +167,28 @@ sphinxcontrib-jsmath==1.0.1 sphinxcontrib-plantuml==0.25 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 -sqlalchemy==1.4.48 +sqlalchemy==1.4.49 tabulate==0.9.0 terminado==0.17.1 tinycss2==1.2.1 tomli==2.0.1 tornado==6.2 -tox==4.6.3 +tox==4.6.4 traitlets==5.9.0 -typed-ast==1.5.4 +typed-ast==1.5.5 typeguard==3.0.2 -typing-extensions==4.6.3 +typing-extensions==4.7.1 uri-template==1.3.0 urllib3==2.0.3 virtualenv==20.23.1 wcwidth==0.2.6 webcolors==1.13 webencodings==0.5.1 -websocket-client==1.6.0 +websocket-client==1.6.1 wheel==0.40.0 -widgetsnbextension==4.0.7 +widgetsnbextension==4.0.8 y-py==0.5.9 -ypy-websocket==0.8.2 +ypy-websocket==0.8.2 ; python_version < "3.8.0" zipp==3.15.0 # The following packages are considered to be unsafe in a requirements file: diff --git a/.constraints/py3.8.txt b/.constraints/py3.8.txt index d9f5e951..82593697 100644 --- a/.constraints/py3.8.txt +++ b/.constraints/py3.8.txt @@ -5,16 +5,14 @@ # pip-compile --extra=dev --no-annotate --output-file=.constraints/py3.8.txt --strip-extras setup.py # accessible-pygments==0.0.4 -aiofiles==22.1.0 -aiosqlite==0.19.0 alabaster==0.7.13 -anyio==3.7.0 +anyio==3.7.1 appdirs==1.4.4 -aquirdturtle-collapsible-headings==3.1.0 argon2-cffi==21.3.0 argon2-cffi-bindings==21.2.0 arrow==1.2.3 asttokens==2.2.1 +async-lru==2.0.2 attrs==23.1.0 babel==2.12.1 backcall==0.2.0 @@ -28,7 +26,7 @@ cffi==1.15.1 cfgv==3.3.1 chardet==5.1.0 charset-normalizer==3.1.0 -click==8.1.3 +click==8.1.4 colorama==0.4.6 comm==0.1.3 contourpy==1.1.0 @@ -39,7 +37,7 @@ defusedxml==0.7.1 distlib==0.3.6 docutils==0.19 esbonio==0.16.1 -exceptiongroup==1.1.1 +exceptiongroup==1.1.2 executing==1.2.0 fastjsonschema==2.17.1 filelock==3.12.2 @@ -53,60 +51,58 @@ imagesize==1.4.1 importlib-metadata==6.7.0 importlib-resources==5.12.0 iniconfig==2.0.0 -ipykernel==6.23.2 +ipykernel==6.24.0 ipympl==0.9.3 ipython==8.12.2 ipython-genutils==0.2.0 -ipywidgets==8.0.6 +ipywidgets==8.0.7 isoduration==20.11.0 -isort==5.12.0 jedi==0.18.2 jinja2==3.1.2 json5==0.9.14 jsonpointer==2.4 -jsonschema==4.17.3 +jsonschema==4.18.0 +jsonschema-specifications==2023.6.1 jupyter==1.0.0 jupyter-cache==0.6.1 -jupyter-client==8.2.0 +jupyter-client==8.3.0 jupyter-console==6.6.3 jupyter-core==5.3.1 jupyter-events==0.6.3 -jupyter-server==2.6.0 -jupyter-server-fileid==0.9.0 +jupyter-lsp==2.2.0 +jupyter-server==2.7.0 jupyter-server-terminals==0.4.4 -jupyter-server-ydoc==0.8.0 -jupyter-ydoc==0.2.4 -jupyterlab==3.6.4 +jupyterlab==4.0.2 jupyterlab-code-formatter==2.2.1 -jupyterlab-myst==1.2.0 +jupyterlab-myst==2.0.1 jupyterlab-pygments==0.2.2 jupyterlab-server==2.23.0 -jupyterlab-widgets==3.0.7 +jupyterlab-widgets==3.0.8 kiwisolver==1.4.4 latexcodec==2.0.1 livereload==2.6.3 lsprotocol==2023.0.0a2 markdown-it-py==2.2.0 markupsafe==2.1.3 -matplotlib==3.7.1 +matplotlib==3.7.2 matplotlib-inline==0.1.6 mdit-py-plugins==0.3.5 mdurl==0.1.2 mistune==3.0.1 -mpl-interactions==0.23.0 +mpl-interactions==0.23.1 mypy-extensions==1.0.0 myst-nb==0.17.2 myst-parser==0.18.1 nbclassic==1.0.0 -nbclient==0.5.13 +nbclient==0.6.8 nbconvert==7.6.0 nbformat==5.9.0 -nbmake==1.3.0 +nbmake==1.4.1 nest-asyncio==1.5.6 nodeenv==1.8.0 notebook==6.5.4 notebook-shim==0.2.3 -numpy==1.24.3 +numpy==1.24.4 overrides==7.3.1 packaging==23.1 pandocfilters==1.5.0 @@ -114,28 +110,27 @@ parso==0.8.3 pathspec==0.11.1 pexpect==4.8.0 pickleshare==0.7.5 -pillow==9.5.0 +pillow==10.0.0 pkgutil-resolve-name==1.3.10 -platformdirs==3.7.0 +platformdirs==3.8.1 pluggy==1.2.0 pre-commit==3.3.3 prometheus-client==0.17.0 -prompt-toolkit==3.0.38 +prompt-toolkit==3.0.39 psutil==5.9.5 ptyprocess==0.7.0 pure-eval==0.2.2 pybtex==0.24.0 pybtex-docutils==1.0.2 pycparser==2.21 -pydantic==1.10.9 +pydantic==1.10.11 pydata-sphinx-theme==0.13.3 pygls==1.0.2 pygments==2.15.1 -pyparsing==3.1.0 -pyproject-api==1.5.2 -pyrsistent==0.19.3 +pyparsing==3.0.9 +pyproject-api==1.5.3 pyspellchecker==0.7.2 -pytest==7.3.2 +pytest==7.4.0 python-dateutil==2.8.2 python-json-logger==2.0.7 pytz==2023.3 @@ -143,10 +138,13 @@ pyyaml==6.0 pyzmq==25.1.0 qtconsole==5.4.3 qtpy==2.3.1 +referencing==0.29.1 requests==2.31.0 requests-file==1.5.1 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 +rpds-py==0.8.8 +ruff==0.0.277 send2trash==1.8.2 six==1.16.0 sniffio==1.3.0 @@ -173,28 +171,26 @@ sphinxcontrib-jsmath==1.0.1 sphinxcontrib-plantuml==0.25 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 -sqlalchemy==2.0.16 +sqlalchemy==2.0.18 stack-data==0.6.2 tabulate==0.9.0 terminado==0.17.1 tinycss2==1.2.1 tomli==2.0.1 tornado==6.3.2 -tox==4.6.3 +tox==4.6.4 traitlets==5.9.0 typeguard==3.0.2 -typing-extensions==4.6.3 +typing-extensions==4.7.1 uri-template==1.3.0 urllib3==2.0.3 virtualenv==20.23.1 wcwidth==0.2.6 webcolors==1.13 webencodings==0.5.1 -websocket-client==1.6.0 +websocket-client==1.6.1 wheel==0.40.0 -widgetsnbextension==4.0.7 -y-py==0.5.9 -ypy-websocket==0.8.2 +widgetsnbextension==4.0.8 zipp==3.15.0 # The following packages are considered to be unsafe in a requirements file: diff --git a/.constraints/py3.9.txt b/.constraints/py3.9.txt index be3fac83..d56df4c5 100644 --- a/.constraints/py3.9.txt +++ b/.constraints/py3.9.txt @@ -5,16 +5,14 @@ # pip-compile --extra=dev --no-annotate --output-file=.constraints/py3.9.txt --strip-extras setup.py # accessible-pygments==0.0.4 -aiofiles==22.1.0 -aiosqlite==0.19.0 alabaster==0.7.13 -anyio==3.7.0 +anyio==3.7.1 appdirs==1.4.4 -aquirdturtle-collapsible-headings==3.1.0 argon2-cffi==21.3.0 argon2-cffi-bindings==21.2.0 arrow==1.2.3 asttokens==2.2.1 +async-lru==2.0.2 attrs==23.1.0 babel==2.12.1 backcall==0.2.0 @@ -28,7 +26,7 @@ cffi==1.15.1 cfgv==3.3.1 chardet==5.1.0 charset-normalizer==3.1.0 -click==8.1.3 +click==8.1.4 colorama==0.4.6 comm==0.1.3 contourpy==1.1.0 @@ -39,7 +37,7 @@ defusedxml==0.7.1 distlib==0.3.6 docutils==0.19 esbonio==0.16.1 -exceptiongroup==1.1.1 +exceptiongroup==1.1.2 executing==1.2.0 fastjsonschema==2.17.1 filelock==3.12.2 @@ -53,55 +51,53 @@ imagesize==1.4.1 importlib-metadata==6.7.0 importlib-resources==5.12.0 iniconfig==2.0.0 -ipykernel==6.23.2 +ipykernel==6.24.0 ipympl==0.9.3 ipython==8.14.0 ipython-genutils==0.2.0 -ipywidgets==8.0.6 +ipywidgets==8.0.7 isoduration==20.11.0 -isort==5.12.0 jedi==0.18.2 jinja2==3.1.2 json5==0.9.14 jsonpointer==2.4 -jsonschema==4.17.3 +jsonschema==4.18.0 +jsonschema-specifications==2023.6.1 jupyter==1.0.0 jupyter-cache==0.6.1 -jupyter-client==8.2.0 +jupyter-client==8.3.0 jupyter-console==6.6.3 jupyter-core==5.3.1 jupyter-events==0.6.3 -jupyter-server==2.6.0 -jupyter-server-fileid==0.9.0 +jupyter-lsp==2.2.0 +jupyter-server==2.7.0 jupyter-server-terminals==0.4.4 -jupyter-server-ydoc==0.8.0 -jupyter-ydoc==0.2.4 -jupyterlab==3.6.4 +jupyterlab==4.0.2 jupyterlab-code-formatter==2.2.1 -jupyterlab-myst==1.2.0 +jupyterlab-myst==2.0.1 jupyterlab-pygments==0.2.2 jupyterlab-server==2.23.0 -jupyterlab-widgets==3.0.7 +jupyterlab-widgets==3.0.8 kiwisolver==1.4.4 latexcodec==2.0.1 livereload==2.6.3 lsprotocol==2023.0.0a2 markdown-it-py==2.2.0 markupsafe==2.1.3 -matplotlib==3.7.1 +matplotlib==3.7.2 matplotlib-inline==0.1.6 mdit-py-plugins==0.3.5 mdurl==0.1.2 mistune==3.0.1 -mpl-interactions==0.23.0 +mpl-interactions==0.23.1 mypy-extensions==1.0.0 myst-nb==0.17.2 myst-parser==0.18.1 nbclassic==1.0.0 -nbclient==0.5.13 +nbclient==0.6.8 nbconvert==7.6.0 nbformat==5.9.0 -nbmake==1.3.0 +nbmake==1.4.1 nest-asyncio==1.5.6 nodeenv==1.8.0 notebook==6.5.4 @@ -114,37 +110,39 @@ parso==0.8.3 pathspec==0.11.1 pexpect==4.8.0 pickleshare==0.7.5 -pillow==9.5.0 -platformdirs==3.7.0 +pillow==10.0.0 +platformdirs==3.8.1 pluggy==1.2.0 pre-commit==3.3.3 prometheus-client==0.17.0 -prompt-toolkit==3.0.38 +prompt-toolkit==3.0.39 psutil==5.9.5 ptyprocess==0.7.0 pure-eval==0.2.2 pybtex==0.24.0 pybtex-docutils==1.0.2 pycparser==2.21 -pydantic==1.10.9 +pydantic==1.10.11 pydata-sphinx-theme==0.13.3 pygls==1.0.2 pygments==2.15.1 -pyparsing==3.1.0 -pyproject-api==1.5.2 -pyrsistent==0.19.3 +pyparsing==3.0.9 +pyproject-api==1.5.3 pyspellchecker==0.7.2 -pytest==7.3.2 +pytest==7.4.0 python-dateutil==2.8.2 python-json-logger==2.0.7 pyyaml==6.0 pyzmq==25.1.0 qtconsole==5.4.3 qtpy==2.3.1 +referencing==0.29.1 requests==2.31.0 requests-file==1.5.1 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 +rpds-py==0.8.8 +ruff==0.0.277 send2trash==1.8.2 six==1.16.0 sniffio==1.3.0 @@ -171,28 +169,26 @@ sphinxcontrib-jsmath==1.0.1 sphinxcontrib-plantuml==0.25 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 -sqlalchemy==2.0.16 +sqlalchemy==2.0.18 stack-data==0.6.2 tabulate==0.9.0 terminado==0.17.1 tinycss2==1.2.1 tomli==2.0.1 tornado==6.3.2 -tox==4.6.3 +tox==4.6.4 traitlets==5.9.0 typeguard==3.0.2 -typing-extensions==4.6.3 +typing-extensions==4.7.1 uri-template==1.3.0 urllib3==2.0.3 virtualenv==20.23.1 wcwidth==0.2.6 webcolors==1.13 webencodings==0.5.1 -websocket-client==1.6.0 +websocket-client==1.6.1 wheel==0.40.0 -widgetsnbextension==4.0.7 -y-py==0.5.9 -ypy-websocket==0.8.2 +widgetsnbextension==4.0.8 zipp==3.15.0 # The following packages are considered to be unsafe in a requirements file: diff --git a/.cspell.json b/.cspell.json index ff747568..3b437555 100644 --- a/.cspell.json +++ b/.cspell.json @@ -25,14 +25,11 @@ "*particle*.*ml", ".constraints/*.txt", ".editorconfig", - ".flake8*", ".gitignore", ".gitpod.*", ".mypy.ini", ".pre-commit-config.yaml", ".prettierignore", - ".pydocstyle*", - ".pylintrc", ".readthedocs.yml", ".vscode/*", ".vscode/.gitignore", @@ -100,6 +97,7 @@ "parametrizations", "pathlib", "permutate", + "pyproject", "pytest", "PYTHONHASHSEED", "qrules", diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 8b526711..00000000 --- a/.flake8 +++ /dev/null @@ -1,33 +0,0 @@ -[flake8] -filename = - ./src/*.py - ./tests/*.py -exclude = - __pycache__ -ignore = - # https://github.com/psf/black#slices - E203 - # allowed by black - E231 - # already covered by black - E302 - # https://github.com/psf/black#line-length - E501 - # should be possible to use {} in latex strings - FS003 - # block quote ends without a blank line (black formatting) - RST201 - # missing pygments - RST299 - # unexpected indentation (related to google style docstring) - RST301 - # enforce type ignore with mypy error codes (combined --extend-select=TI100) - TI1 - # https://github.com/psf/black#line-breaks--binary-operators - W503 -per-file-ignores = - docs/conf.py:C408 -extend-select = - TI100 -radon-max-cc = 8 -radon-no-assert = True diff --git a/.gitpod.yml b/.gitpod.yml index e2bef50c..948c7cda 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -13,11 +13,13 @@ github: vscode: extensions: + - charliermarsh.ruff - christian-kohler.path-intellisense - eamodio.gitlens - editorconfig.editorconfig - esbenp.prettier-vscode - executablebookproject.myst-highlight + - garaioag.garaio-vscode-unwanted-recommendations - github.vscode-github-actions - github.vscode-pull-request-github - julialang.language-julia diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3a60b684..61c6ba51 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -37,7 +37,7 @@ repos: )$ - repo: https://github.com/ComPWA/repo-maintenance - rev: 0.0.182 + rev: 0.0.189 hooks: - id: check-dev-files args: @@ -55,13 +55,12 @@ repos: - id: nbqa-black additional_dependencies: - black>=22.1.0 - - id: nbqa-flake8 - additional_dependencies: - - flake8-future-annotations - - id: nbqa-isort - id: nbqa-pyupgrade args: - --py37-plus + - id: nbqa-ruff + args: + - --fix - repo: https://github.com/psf/black rev: 23.3.0 @@ -99,11 +98,6 @@ repos: docs/_static/favicon.ico )$ - - repo: https://github.com/pycqa/isort - rev: 5.12.0 - hooks: - - id: isort - - repo: https://github.com/kynan/nbstripout rev: 0.6.1 hooks: @@ -129,22 +123,29 @@ repos: metadata.vscode - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.0-alpha.9-for-vscode + rev: v3.0.0 hooks: - id: prettier - repo: https://github.com/ComPWA/mirrors-pyright - rev: v1.1.315 + rev: v1.1.316 hooks: - id: pyright - repo: https://github.com/asottile/pyupgrade - rev: v3.7.0 + rev: v3.8.0 hooks: - id: pyupgrade args: - --py37-plus + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.0.277 + hooks: + - id: ruff + args: + - --fix + - repo: https://github.com/ComPWA/mirrors-taplo rev: v0.8.0 hooks: diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 7dbed5f4..a485ccf4 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,10 +1,12 @@ { "recommendations": [ + "charliermarsh.ruff", "christian-kohler.path-intellisense", "eamodio.gitlens", "editorconfig.editorconfig", "esbenp.prettier-vscode", "executablebookproject.myst-highlight", + "garaioag.garaio-vscode-unwanted-recommendations", "github.vscode-github-actions", "github.vscode-pull-request-github", "julialang.language-julia", @@ -19,5 +21,13 @@ "tamasfe.even-better-toml", "tyriar.sort-lines", "yzhang.markdown-all-in-one" + ], + "unwantedRecommendations": [ + "bungcip.better-toml", + "ms-python.flake8", + "ms-python.isort", + "ms-python.mypy-type-checker", + "ms-python.pylint", + "travisillig.vscode-json-stable-stringify" ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 1c411409..9f8cd16d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -40,7 +40,6 @@ ], "livePreview.defaultPreviewPath": "docs/_build/html", "python.analysis.autoImportCompletions": false, - "python.analysis.diagnosticMode": "workspace", "python.analysis.typeCheckingMode": "strict", "python.formatting.provider": "black", "python.linting.banditEnabled": false, @@ -52,9 +51,10 @@ "python.linting.pylintEnabled": false, "python.testing.pytestEnabled": false, "rewrap.wrappingColumn": 88, + "ruff.enable": true, + "ruff.organizeImports": true, "search.exclude": { "**/tests/**/__init__.py": true, - "*/.pydocstyle": true, ".constraints/*.txt": true }, "yaml.schemas": { diff --git a/README.md b/README.md index 1eec9c9a..9a95408c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # ComPWA Organization Documentation +[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![10.5281/zenodo.6908149](https://zenodo.org/badge/DOI/10.5281/zenodo.6908149.svg)](https://doi.org/10.5281/zenodo.6908149) [![GPLv3+ license](https://img.shields.io/badge/License-GPLv3+-blue.svg)](https://www.gnu.org/licenses/gpl-3.0-standalone.html) @@ -12,7 +13,6 @@ [![Spelling checked](https://img.shields.io/badge/cspell-checked-brightgreen.svg)](https://github.com/streetsidesoftware/cspell/tree/master/packages/cspell) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) -[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort) This repository contains the source code for the [compwa-org.rtfd.io](https://compwa-org.readthedocs.io) pages. diff --git a/docs/adr/001/operators.ipynb b/docs/adr/001/operators.ipynb index 41d2f410..63ec7ede 100644 --- a/docs/adr/001/operators.ipynb +++ b/docs/adr/001/operators.ipynb @@ -213,14 +213,12 @@ " __radd__ = MAKE_RBINARY(operator.add)\n", " __rsub__ = MAKE_RBINARY(operator.sub)\n", " __rmul__ = MAKE_RBINARY(operator.mul)\n", - " # __div__ = MAKE_BINARY(operator.div)\n", - " # __rdiv__ = MAKE_RBINARY(operator.div)\n", " __truediv__ = MAKE_BINARY(operator.truediv)\n", " __rtruediv__ = MAKE_RBINARY(operator.truediv)\n", " __floordiv__ = MAKE_BINARY(operator.floordiv)\n", " __rfloordiv__ = MAKE_RBINARY(operator.floordiv)\n", "\n", - " def __neg__(self, other):\n", + " def __neg__(self):\n", " return UnaryOp(self, lambda x: -x)\n", "\n", " @property\n", diff --git a/docs/adr/001/sympy.ipynb b/docs/adr/001/sympy.ipynb index 6d3fe777..e027fd09 100644 --- a/docs/adr/001/sympy.ipynb +++ b/docs/adr/001/sympy.ipynb @@ -710,7 +710,8 @@ "import numpy as np\n", "\n", "parameter_values = (1.0, 0.0, 0.1, 2.0, 2.0, 0.2)\n", - "np_x = np.random.uniform(-1, 3, 10000)\n", + "rng = np.random.default_rng(0)\n", + "np_x = rng.uniform(-1, 3, 10000)\n", "tf_x = tf.constant(np_x)\n", "\n", "\n", diff --git a/docs/adr/002/composition.ipynb b/docs/adr/002/composition.ipynb index 934d966f..bee9dbe7 100644 --- a/docs/adr/002/composition.ipynb +++ b/docs/adr/002/composition.ipynb @@ -67,7 +67,7 @@ "try:\n", " from typing import Protocol\n", "except ImportError:\n", - " from typing_extensions import Protocol # type: ignore" + " from typing_extensions import Protocol" ] }, { diff --git a/docs/adr/002/expr.ipynb b/docs/adr/002/expr.ipynb index 6c03a073..3e0515b8 100644 --- a/docs/adr/002/expr.ipynb +++ b/docs/adr/002/expr.ipynb @@ -120,11 +120,12 @@ "class RelativisticBreitWigner(DynamicsExpr):\n", " def __new__(cls, *args: sp.Symbol, **hints) -> sp.Expr:\n", " if len(args) != 3:\n", - " raise ValueError(f\"3 parameters expected, got {len(args)}\")\n", + " msg = f\"3 parameters expected, got {len(args)}\"\n", + " raise ValueError(msg)\n", " args = sp.sympify(args)\n", " evaluate = hints.get(\"evaluate\", False)\n", " if evaluate:\n", - " return sp.Expr.__new__(cls, *args).evaluate() # type: ignore\n", + " return sp.Expr.__new__(cls, *args).evaluate()\n", " return sp.Expr.__new__(cls, *args)\n", "\n", " @property\n", @@ -186,11 +187,12 @@ "class RelativisticBreitWignerWithFF(DynamicsExpr):\n", " def __new__(cls, *args: sp.Symbol, **hints) -> sp.Expr:\n", " if len(args) != 7:\n", - " raise ValueError(f\"7 parameters expected, got {len(args)}\")\n", + " msg = f\"7 parameters expected, got {len(args)}\"\n", + " raise ValueError(msg)\n", " args = sp.sympify(args)\n", " evaluate = hints.get(\"evaluate\", False)\n", " if evaluate:\n", - " return sp.Expr.__new__(cls, *args).evaluate() # type: ignore\n", + " return sp.Expr.__new__(cls, *args).evaluate()\n", " return sp.Expr.__new__(cls, *args)\n", "\n", " def doit(self, **hints) -> sp.Expr:\n", @@ -396,7 +398,8 @@ " def decorator(decorated_class: type) -> type[DynamicsExpr]:\n", " def __new__(cls, *args: sp.Symbol, **hints) -> sp.Expr:\n", " if len(args) != n_args:\n", - " raise ValueError(f\"{n_args} parameters expected, got {len(args)}\")\n", + " msg = f\"{n_args} parameters expected, got {len(args)}\"\n", + " raise ValueError(msg)\n", " args = sp.sympify(args)\n", " evaluate = hints.get(\"evaluate\", False)\n", " if evaluate:\n", diff --git a/docs/adr/002/helpers.py b/docs/adr/002/helpers.py index ed283c37..2819ed97 100644 --- a/docs/adr/002/helpers.py +++ b/docs/adr/002/helpers.py @@ -54,5 +54,4 @@ def determine_attached_final_state( graph: StateTransitionGraph, edge_id: int, ) -> list[int]: - mock = [3, 4] - return mock + return [3, 4] diff --git a/docs/conf.py b/docs/conf.py index f7a3b335..4cdb4a7a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -5,6 +5,7 @@ https://www.sphinx-doc.org/en/master/usage/configuration.html """ +import contextlib import os import re import shutil @@ -19,10 +20,10 @@ from pybtex.plugin import register_plugin from pybtex.richtext import Tag, Text from pybtex.style.formatting.unsrt import Style as UnsrtStyle -from pybtex.style.template import _format_list # pyright: ignore[reportPrivateUsage] from pybtex.style.template import ( FieldIsMissing, Node, + _format_list, # pyright: ignore[reportPrivateUsage] field, href, join, @@ -61,13 +62,12 @@ def fetch_logo(url: str, output_path: str) -> None: LOGO_PATH = "_static/logo.svg" -try: +with contextlib.suppress(requests.exceptions.ConnectionError): fetch_logo( url="https://raw.githubusercontent.com/ComPWA/ComPWA/04e5199/doc/images/logo.svg", output_path=LOGO_PATH, ) -except requests.exceptions.ConnectionError: - pass + if os.path.exists(LOGO_PATH): html_logo = LOGO_PATH @@ -143,7 +143,7 @@ def fetch_logo(url: str, output_path: str) -> None: "icon_links": [ { "name": "GitHub", - "url": f"https://github.com/ComPWA", + "url": "https://github.com/ComPWA", "icon": "fa-brands fa-github", }, { @@ -209,7 +209,7 @@ def get_version(package_name: str) -> str: if not line: continue line_segments = tuple(line.split("==")) - if len(line_segments) != 2: + if len(line_segments) != 2: # noqa: PLR2004 continue _, installed_version, *_ = line_segments installed_version = installed_version.strip() @@ -228,9 +228,8 @@ def get_minor_version(package_name: str) -> str: return installed_version matches = re.match(r"^([0-9]+\.[0-9]+).*$", installed_version) if matches is None: - raise ValueError( - f"Could not find documentation for {package_name} v{installed_version}" - ) + msg = f"Could not find documentation for {package_name} v{installed_version}" + raise ValueError(msg) return matches[1] @@ -462,12 +461,11 @@ def et_al(children, data, sep="", sep2=None, last_sep=None): parts = [part for part in _format_list(children, data) if part] if len(parts) <= 1: return Text(*parts) - elif len(parts) == 2: + if len(parts) == 2: # noqa: PLR2004 return Text(sep2).join(parts) - elif len(parts) == 3: + if len(parts) == 3: # noqa: PLR2004 return Text(last_sep).join([Text(sep).join(parts[:-1]), parts[-1]]) - else: - return Text(parts[0], Tag("em", " et al")) + return Text(parts[0], Tag("em", " et al")) @node @@ -477,7 +475,7 @@ def names(children, context, role, **kwargs): try: persons = context["entry"].persons[role] except KeyError: - raise FieldIsMissing(role, context["entry"]) + raise FieldIsMissing(role, context["entry"]) from None style = context["style"] formatted_names = [ @@ -494,8 +492,7 @@ def format_names(self, role, as_sentence=True) -> Node: formatted_names = names(role, sep=", ", sep2=" and ", last_sep=", and ") if as_sentence: return sentence[formatted_names] - else: - return formatted_names + return formatted_names def format_eprint(self, e): # pyright: ignore[reportIncompatibleMethodOverride] if "doi" in e.fields: diff --git a/docs/develop.md b/docs/develop.md index 8366baad..37e76752 100644 --- a/docs/develop.md +++ b/docs/develop.md @@ -295,11 +295,8 @@ commit files locally (see {ref}`develop:Pre-commit`), when {ref}`running tox `, and when you make a {ref}`pull request `. - - -The tools are configured through files such as +The tools are mainly configured through [`pyproject.toml`](https://github.com/ComPWA/ampform/blob/main/pyproject.toml), -[`.pylintrc`](https://github.com/ComPWA/ampform/blob/main/.pylintrc), and [`tox.ini`](https://github.com/ComPWA/ampform/blob/main/tox.ini), and the workflow files under [`.github`](https://github.com/ComPWA/ampform/blob/main/.github). If you run into persistent linting errors, this may mean we need to further specify our conventions. In @@ -393,7 +390,8 @@ this speeds up your own programming, but these tools are particularly important conflicts in Git and makes diffs in code review easier to read. For the Python source code, we use [`black`](https://black.readthedocs.io) and -[`isort`](https://isort.readthedocs.io). For other code, we use +[`isort`](https://isort.readthedocs.io) ([through +Ruff](https://beta.ruff.rs/docs/rules/#isort-i)). For other code, we use [Prettier](https://prettier.io). All of these formatters are "opinionated formatters": they offer only limited configuration options, as to make formatting as conform as possible. @@ -409,7 +407,8 @@ of any output cells with [`nbstripout`](https://github.com/kynan/nbstripout). Linters point out when certain style conventions are not correctly followed. Unlike with {ref}`formatters `, you have to fix the errors yourself. As mentioned in {ref}`develop:Automated coding conventions`, style conventions are -formulated in config files. +formulated in config files. The main linter that ComPWA projects use, is +[Ruff](https://ruff.rs). ### Spelling @@ -852,7 +851,8 @@ name as the release tag are automatically closed. Even though we try to standardize the developer set-up of the repositories, we encourage you to use the code editors that you feel comfortable with. Where possible, we therefore define settings of linters, formatters, etc in config files that are specific to those -tools (such as `.pylintrc`), not in the configuration files of the editors. +tools (using `pyproject.toml` where possible), not in the configuration files of the +editors. Still, where code editor settings can be shared through configuration files in the repository, we provide recommended settings for the code editor as well. This is diff --git a/docs/report/000.ipynb b/docs/report/000.ipynb index 6fa92c44..d040b668 100644 --- a/docs/report/000.ipynb +++ b/docs/report/000.ipynb @@ -102,7 +102,8 @@ "import jax.numpy as jnp\n", "import numpy as np\n", "import sympy as sp\n", - "from black import FileMode, format_str" + "from black import FileMode, format_str\n", + "from IPython.display import display" ] }, { diff --git a/docs/report/001.ipynb b/docs/report/001.ipynb index ce2da436..251af6e0 100644 --- a/docs/report/001.ipynb +++ b/docs/report/001.ipynb @@ -620,7 +620,8 @@ "metadata": {}, "outputs": [], "source": [ - "sample = np.random.normal(size=1_000_000)\n", + "rng = np.random.default_rng()\n", + "sample = rng.normal(size=1_000_000)\n", "jax_sample = jnp.array(sample)" ] }, diff --git a/docs/report/002.ipynb b/docs/report/002.ipynb index dd3866e6..e13e90d2 100644 --- a/docs/report/002.ipynb +++ b/docs/report/002.ipynb @@ -898,7 +898,7 @@ "metadata": {}, "outputs": [], "source": [ - "kinematic_variable_names = {key for key in phsp_set}\n", + "kinematic_variable_names = set(phsp_set)\n", "parameter_names = {symbol.name for symbol in model.parameter_defaults}\n", "free_symbol_names = {symbol.name for symbol in free_symbols}" ] diff --git a/docs/report/003.ipynb b/docs/report/003.ipynb index 4b5fd4c0..c854ef92 100644 --- a/docs/report/003.ipynb +++ b/docs/report/003.ipynb @@ -395,9 +395,9 @@ "for ax in axes:\n", " ax.axhline(0, linewidth=0.5, c=\"black\")\n", "\n", - "real_style = dict(label=\"Real part\", c=\"black\", linestyle=\"dashed\")\n", - "imag_style = dict(label=\"Imag part\", c=\"red\")\n", - "threshold_style = dict(label=R\"$s_\\mathrm{thr}$\", c=\"grey\", linewidth=0.5)\n", + "real_style = {\"label\": \"Real part\", \"c\": \"black\", \"linestyle\": \"dashed\"}\n", + "imag_style = {\"label\": \"Imag part\", \"c\": \"red\"}\n", + "threshold_style = {\"label\": R\"$s_\\mathrm{thr}$\", \"c\": \"grey\", \"linewidth\": 0.5}\n", "\n", "ylim = (-1, +1)\n", "y_factor = 16 * np.pi\n", @@ -838,10 +838,11 @@ " def _numpycode(self, printer, *args):\n", " integration_vars, limits = _unpack_integral_limits(self)\n", " if len(limits) != 1:\n", - " raise ValueError(f\"Cannot handle {len(limits)}-dimensional integrals\")\n", + " msg = f\"Cannot handle {len(limits)}-dimensional integrals\"\n", + " raise ValueError(msg)\n", " integrate = \"quadpy_quad\"\n", " printer.module_imports[\"quadpy\"].update({f\"quad as {integrate}\"})\n", - " limit_str = \"%s, %s\" % tuple(map(printer._print, limits[0]))\n", + " limit_str = \"{}, {}\".format(*tuple(map(printer._print, limits[0])))\n", " args = \", \".join(map(printer._print, integration_vars))\n", " expr = printer._print(self.args[0])\n", " return (\n", diff --git a/docs/report/004.ipynb b/docs/report/004.ipynb index 1fb494a7..7db544a6 100644 --- a/docs/report/004.ipynb +++ b/docs/report/004.ipynb @@ -108,7 +108,7 @@ "import numpy as np\n", "import sympy as sp\n", "from ampform.dynamics import PhaseSpaceFactor, relativistic_breit_wigner_with_ff\n", - "from IPython.display import Math\n", + "from IPython.display import Math, display\n", "from ipywidgets import widgets\n", "from matplotlib import cm\n", "from mpl_interactions import heatmap_slicer\n", @@ -237,7 +237,7 @@ ")\n", "fig.suptitle(R\"Solution sheet for $\\rho$ in the $s$-plane\")\n", "colors = np.select(\n", - " [Z < rho_min, Z < 0, Z >= 0, Z > rho_max],\n", + " [rho_min > Z, Z < 0, Z >= 0, rho_max < Z],\n", " [rho_min, Z / np.abs(rho_min), Z / np.abs(rho_max), rho_max],\n", ")\n", "colors = (colors + 1) / 2\n", @@ -435,18 +435,18 @@ "cut_off_min = np.vectorize(lambda z: z if z > z_cut_min else z_cut_min)\n", "cut_off_max = np.vectorize(lambda z: z if z < z_cut_max else z_cut_max)\n", "\n", - "plot_style = dict(\n", - " linewidth=0,\n", - " alpha=0.7,\n", - " antialiased=True,\n", - " rstride=1,\n", - " cstride=1,\n", - ")\n", - "axis_style = dict(\n", - " c=\"black\",\n", - " linewidth=0.7,\n", - " linestyle=\"dashed\",\n", - ")\n", + "plot_style = {\n", + " \"linewidth\": 0,\n", + " \"alpha\": 0.7,\n", + " \"antialiased\": True,\n", + " \"rstride\": 1,\n", + " \"cstride\": 1,\n", + "}\n", + "axis_style = {\n", + " \"c\": \"black\",\n", + " \"linewidth\": 0.7,\n", + " \"linestyle\": \"dashed\",\n", + "}\n", "\n", "fig, axes = plt.subplots(\n", " ncols=2,\n", @@ -460,34 +460,34 @@ "m0_min = np.sign(x_min) * np.sqrt(np.abs(x_min))\n", "m0_max = np.sign(x_max) * np.sqrt(np.abs(x_max))\n", "\n", - "sliders = dict(\n", - " m0=widgets.FloatSlider(\n", + "sliders = {\n", + " \"m0\": widgets.FloatSlider(\n", " min=m0_min,\n", " max=m0_max,\n", " value=0.8,\n", " step=0.01,\n", " description=\"$m_0$\",\n", " ),\n", - " gamma0=widgets.FloatSlider(\n", + " \"gamma0\": widgets.FloatSlider(\n", " min=0.0,\n", " max=y_max,\n", " value=0.3,\n", " step=0.01,\n", " description=R\"$\\Gamma_0$\",\n", " ),\n", - " m1=widgets.FloatSlider(\n", + " \"m1\": widgets.FloatSlider(\n", " min=1e-4,\n", " max=m0_max / 2,\n", " step=0.01,\n", " description=\"$m_1$\",\n", " ),\n", - " m2=widgets.FloatSlider(\n", + " \"m2\": widgets.FloatSlider(\n", " min=1e-4,\n", " max=m0_max / 2,\n", " step=0.01,\n", " description=\"$m_2$\",\n", " ),\n", - ")\n", + "}\n", "\n", "\n", "@widgets.interact(**sliders)\n", diff --git a/docs/report/005.ipynb b/docs/report/005.ipynb index cc1199b9..078f33bd 100644 --- a/docs/report/005.ipynb +++ b/docs/report/005.ipynb @@ -123,7 +123,7 @@ "import numpy as np\n", "import symplot\n", "import sympy as sp\n", - "from IPython.display import Math\n", + "from IPython.display import Math, display\n", "from ipywidgets import widgets as ipywidgets\n", "from matplotlib import cm\n", "from mpl_interactions.controller import Controls\n", @@ -890,10 +890,10 @@ " )\n", " if n_channels > 1:\n", " ax_2d.legend(loc=\"upper right\")\n", - " mass_line_style = dict(\n", - " c=\"red\",\n", - " alpha=0.3,\n", - " )\n", + " mass_line_style = {\n", + " \"c\": \"red\",\n", + " \"alpha\": 0.3,\n", + " }\n", " for name in controls.params:\n", " if not name.startswith(\"m\"):\n", " continue\n", diff --git a/docs/report/006.ipynb b/docs/report/006.ipynb index b514c0b6..c7915992 100644 --- a/docs/report/006.ipynb +++ b/docs/report/006.ipynb @@ -101,6 +101,7 @@ "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import sympy as sp\n", + "from IPython.display import display\n", "from ipywidgets import widgets as ipywidgets\n", "from matplotlib import cm\n", "from matplotlib import widgets as mpl_widgets\n", diff --git a/docs/report/007.ipynb b/docs/report/007.ipynb index 4945b738..e230f658 100644 --- a/docs/report/007.ipynb +++ b/docs/report/007.ipynb @@ -84,6 +84,7 @@ "import os\n", "\n", "import sympy as sp\n", + "from IPython.display import display\n", "\n", "STATIC_WEB_PAGE = {\"EXECUTE_NB\", \"READTHEDOCS\"}.intersection(os.environ)" ] diff --git a/docs/report/009.ipynb b/docs/report/009.ipynb index 482fb3ed..f881bca2 100644 --- a/docs/report/009.ipynb +++ b/docs/report/009.ipynb @@ -161,6 +161,7 @@ "import os\n", "import re\n", "import warnings\n", + "from typing import TYPE_CHECKING\n", "\n", "import matplotlib.pyplot as plt\n", "import mpl_interactions.ipyplot as iplt\n", @@ -173,11 +174,13 @@ " create_expression,\n", " implement_doit_method,\n", ")\n", - "from IPython.display import Math\n", + "from IPython.display import Math, display\n", "from ipywidgets import widgets as ipywidgets\n", "from matplotlib import cm\n", "from mpl_interactions.controller import Controls\n", - "from sympy.printing.latex import LatexPrinter\n", + "\n", + "if TYPE_CHECKING:\n", + " from sympy.printing.latex import LatexPrinter\n", "\n", "warnings.filterwarnings(\"ignore\")\n", "STATIC_WEB_PAGE = {\"EXECUTE_NB\", \"READTHEDOCS\"}.intersection(os.environ)" @@ -792,10 +795,10 @@ " )\n", " if n_channels > 1:\n", " axes[0].legend(loc=\"upper right\")\n", - " mass_line_style = dict(\n", - " c=\"red\",\n", - " alpha=0.3,\n", - " )\n", + " mass_line_style = {\n", + " \"c\": \"red\",\n", + " \"alpha\": 0.3,\n", + " }\n", " for name in controls.params:\n", " if not re.match(r\"^m[0-9]+$\", name):\n", " continue\n", diff --git a/docs/report/010.ipynb b/docs/report/010.ipynb index 605292bd..17e1ed9f 100644 --- a/docs/report/010.ipynb +++ b/docs/report/010.ipynb @@ -100,6 +100,7 @@ "import os\n", "import re\n", "import warnings\n", + "from typing import TYPE_CHECKING\n", "\n", "import matplotlib.pyplot as plt\n", "import mpl_interactions.ipyplot as iplt\n", @@ -117,10 +118,13 @@ " create_expression,\n", " implement_doit_method,\n", ")\n", + "from IPython.display import display\n", "from ipywidgets import widgets as ipywidgets\n", "from matplotlib import cm\n", "from mpl_interactions.controller import Controls\n", - "from sympy.printing.latex import LatexPrinter\n", + "\n", + "if TYPE_CHECKING:\n", + " from sympy.printing.latex import LatexPrinter\n", "\n", "warnings.filterwarnings(\"ignore\")\n", "STATIC_WEB_PAGE = {\"EXECUTE_NB\", \"READTHEDOCS\"}.intersection(os.environ)" @@ -561,10 +565,10 @@ " )\n", " if n_channels > 1:\n", " axes[0].legend(loc=\"upper right\")\n", - " mass_line_style = dict(\n", - " c=\"red\",\n", - " alpha=0.3,\n", - " )\n", + " mass_line_style = {\n", + " \"c\": \"red\",\n", + " \"alpha\": 0.3,\n", + " }\n", " for name in controls.params:\n", " if not re.match(r\"^m[0-9]+$\", name):\n", " continue\n", diff --git a/docs/report/011.ipynb b/docs/report/011.ipynb index b017a1a5..db613d15 100644 --- a/docs/report/011.ipynb +++ b/docs/report/011.ipynb @@ -84,6 +84,7 @@ "from __future__ import annotations\n", "\n", "import inspect\n", + "from typing import TYPE_CHECKING\n", "\n", "import black\n", "import graphviz\n", @@ -101,11 +102,13 @@ " create_expression,\n", " implement_doit_method,\n", ")\n", - "from IPython.display import Math\n", + "from IPython.display import Math, display\n", "from qrules.topology import Topology, create_isobar_topologies\n", "from sympy.printing.numpy import NumPyPrinter\n", - "from sympy.printing.printer import Printer\n", - "from sympy.tensor.array.expressions.array_expressions import ArraySlice, ArraySymbol" + "from sympy.tensor.array.expressions.array_expressions import ArraySlice, ArraySymbol\n", + "\n", + "if TYPE_CHECKING:\n", + " from sympy.printing.printer import Printer" ] }, { @@ -446,7 +449,6 @@ ], "source": [ "n_events = 3\n", - "# n_events = sp.Symbol(\"n\", integer=True, positive=True)\n", "momentum = sp.MatrixSymbol(\"p\", m=n_events, n=4)\n", "beta = sp.Symbol(\"beta\")\n", "phi = sp.Symbol(\"phi\")\n", @@ -493,6 +495,8 @@ "outputs": [], "source": [ "# small helper function\n", + "\n", + "\n", "def print_lambdify(symbols, expr):\n", " np_expr = sp.lambdify(symbols, expr)\n", " src = inspect.getsource(np_expr)\n", @@ -560,7 +564,8 @@ "\n", " def recursive_multiply(tensors):\n", " if len(tensors) < 2:\n", - " raise ValueError(\"Need at least two tensors\")\n", + " msg = \"Need at least two tensors\"\n", + " raise ValueError(msg)\n", " if len(tensors) == 2:\n", " return multiply(tensors[0], tensors[1])\n", " return multiply(tensors[0], recursive_multiply(tensors[1:]))\n", @@ -1105,7 +1110,7 @@ "p_y = FourMomentumY(p)\n", "energy = Energy(p)\n", "\n", - "math_style = dict(environment=\"eqnarray\")\n", + "math_style = {\"environment\": \"eqnarray\"}\n", "display(\n", " p,\n", " Math(sp.multiline_latex(Phi(p), phi.evaluate(), **math_style)),\n", @@ -1322,7 +1327,8 @@ " cls, array: ArraySymbol, axis: int | None = None, **hints\n", " ) -> ArrayAxisSum:\n", " if axis is not None and not isinstance(axis, (int, sp.Integer)):\n", - " raise TypeError(\"Only single digits allowed for axis\")\n", + " msg = \"Only single digits allowed for axis\"\n", + " raise TypeError(msg)\n", " return create_expression(cls, array, axis, **hints)\n", "\n", " def _latex(self, printer, *args) -> str:\n", @@ -1940,10 +1946,11 @@ " events: dict[int, ArraySymbol], topology: Topology\n", ") -> dict[str, sp.Expr]:\n", " if topology.outgoing_edge_ids != set(events):\n", - " raise ValueError(\n", - " f\"Momentum IDs {set(events)} do not match \"\n", - " f\"final state edge IDs {set(topology.outgoing_edge_ids)}\"\n", + " msg = (\n", + " f\"Momentum IDs {set(events)} do not match final state edge IDs\"\n", + " f\" {set(topology.outgoing_edge_ids)}\"\n", " )\n", + " raise ValueError(msg)\n", "\n", " def __recursive_helicity_angles(\n", " events: dict[int, ArraySymbol], node_id: int\n", diff --git a/docs/report/013.ipynb b/docs/report/013.ipynb index d6319725..d9299077 100644 --- a/docs/report/013.ipynb +++ b/docs/report/013.ipynb @@ -92,6 +92,8 @@ "import logging\n", "import warnings\n", "\n", + "from IPython.display import display\n", + "\n", "LOGGER = logging.getLogger()\n", "LOGGER.setLevel(logging.ERROR)\n", "warnings.filterwarnings(\"ignore\")" @@ -492,10 +494,10 @@ " )\n", "\n", " fig, ax = plt.subplots(nrows=2, ncols=3, figsize=(8, 5))\n", - " hist_kwargs = dict(\n", - " bins=80,\n", - " histtype=\"step\",\n", - " )\n", + " hist_kwargs = {\n", + " \"bins\": 80,\n", + " \"histtype\": \"step\",\n", + " }\n", "\n", " for x in ax.flatten():\n", " x.set_yticks([])\n", diff --git a/docs/report/014.ipynb b/docs/report/014.ipynb index 0c88f0c8..1423084c 100644 --- a/docs/report/014.ipynb +++ b/docs/report/014.ipynb @@ -86,7 +86,7 @@ "import itertools\n", "import logging\n", "from functools import lru_cache\n", - "from typing import Iterable, Sequence\n", + "from typing import TYPE_CHECKING, Iterable, Sequence\n", "\n", "import ampform\n", "import attrs\n", @@ -110,13 +110,17 @@ " implement_doit_method,\n", ")\n", "from IPython.display import Math, display\n", - "from qrules.topology import Topology\n", - "from qrules.transition import StateTransition\n", "from sympy.core.symbol import Str\n", "from sympy.physics.quantum.spin import Rotation as Wigner\n", - "from sympy.printing.latex import LatexPrinter\n", "from sympy.printing.precedence import PRECEDENCE\n", "\n", + "if TYPE_CHECKING:\n", + " import sys\n", + "\n", + " from qrules.topology import Topology\n", + " from qrules.transition import StateTransition\n", + " from sympy.printing.latex import LatexPrinter\n", + "\n", "LOGGER = logging.getLogger()\n", "LOGGER.setLevel(logging.ERROR)" ] @@ -209,12 +213,7 @@ }, "outputs": [], "source": [ - "display(\n", - " *map(\n", - " lambda t: graphviz.Source(qrules.io.asdot(t, size=3)),\n", - " reaction.transitions,\n", - " )\n", - ")" + "display(*(graphviz.Source(qrules.io.asdot(t, size=3)) for t in reaction.transitions))" ] }, { @@ -669,15 +668,15 @@ }, "outputs": [], "source": [ - "import sys\n", "from collections import defaultdict\n", "\n", "from qrules import ReactionInfo\n", "\n", - "if sys.version_info >= (3, 8):\n", - " from typing import Literal\n", - "else:\n", - " from typing_extensions import Literal\n", + "if TYPE_CHECKING:\n", + " if sys.version_info >= (3, 8):\n", + " from typing import Literal\n", + " else:\n", + " from typing_extensions import Literal\n", "\n", "\n", "@lru_cache(maxsize=None)\n", diff --git a/docs/report/015.ipynb b/docs/report/015.ipynb index c9bcbb5e..bbfc39aa 100644 --- a/docs/report/015.ipynb +++ b/docs/report/015.ipynb @@ -90,7 +90,7 @@ "import qrules\n", "import sympy as sp\n", "from ampform.helicity import formulate_wigner_d\n", - "from IPython.display import Math\n", + "from IPython.display import Math, display\n", "\n", "LOGGER = logging.getLogger()\n", "LOGGER.setLevel(logging.ERROR)\n", diff --git a/docs/report/016.ipynb b/docs/report/016.ipynb index 601d680c..5379108f 100644 --- a/docs/report/016.ipynb +++ b/docs/report/016.ipynb @@ -402,10 +402,11 @@ " def _numpycode(self, printer, *args):\n", " integration_vars, limits = _unpack_integral_limits(self)\n", " if len(limits) != 1:\n", - " raise ValueError(f\"Cannot handle {len(limits)}-dimensional integrals\")\n", + " msg = f\"Cannot handle {len(limits)}-dimensional integrals\"\n", + " raise ValueError(msg)\n", " integrate = \"quadpy_quad\"\n", " printer.module_imports[\"quadpy\"].update({f\"quad as {integrate}\"})\n", - " limit_str = \"%s, %s\" % tuple(map(printer._print, limits[0]))\n", + " limit_str = \"{}, {}\".format(*tuple(map(printer._print, limits[0])))\n", " args = \", \".join(map(printer._print, integration_vars))\n", " expr = printer._print(self.args[0])\n", " return (\n", diff --git a/docs/report/017.ipynb b/docs/report/017.ipynb index 5f570ba8..868d5390 100644 --- a/docs/report/017.ipynb +++ b/docs/report/017.ipynb @@ -82,6 +82,7 @@ "from __future__ import annotations\n", "\n", "import warnings\n", + "from typing import TYPE_CHECKING\n", "\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", @@ -94,12 +95,14 @@ ")\n", "from IPython.display import Math\n", "from ipywidgets import FloatSlider, VBox, interactive_output\n", - "from matplotlib.axis import Axis\n", - "from matplotlib.contour import QuadContourSet\n", - "from matplotlib.lines import Line2D\n", "from matplotlib.patches import Patch\n", "from tensorwaves.function.sympy import create_parametrized_function\n", "\n", + "if TYPE_CHECKING:\n", + " from matplotlib.axis import Axis\n", + " from matplotlib.contour import QuadContourSet\n", + " from matplotlib.lines import Line2D\n", + "\n", "warnings.filterwarnings(\"ignore\")" ] }, @@ -383,10 +386,10 @@ " figsize=(7, 7),\n", " ncols=2,\n", " nrows=2,\n", - " gridspec_kw=dict(\n", - " height_ratios=[sidebar_ratio, 1],\n", - " width_ratios=[1, sidebar_ratio],\n", - " ),\n", + " gridspec_kw={\n", + " \"height_ratios\": [sidebar_ratio, 1],\n", + " \"width_ratios\": [1, sidebar_ratio],\n", + " },\n", ")\n", "_.remove()\n", "ax.set_xlim(0, 4)\n", diff --git a/docs/report/018.ipynb b/docs/report/018.ipynb index e3e63e37..eee01a32 100644 --- a/docs/report/018.ipynb +++ b/docs/report/018.ipynb @@ -325,8 +325,12 @@ }, "outputs": [], "source": [ + "from typing import TYPE_CHECKING\n", + "\n", "from scipy.interpolate import griddata\n", - "from tensorwaves.interface import DataSample\n", + "\n", + "if TYPE_CHECKING:\n", + " from tensorwaves.interface import DataSample\n", "\n", "\n", "def plot_distribution_and_weights(phsp: DataSample, weights: np.ndarray) -> None:\n", diff --git a/docs/report/021.ipynb b/docs/report/021.ipynb index 1361464f..b81a15d7 100644 --- a/docs/report/021.ipynb +++ b/docs/report/021.ipynb @@ -97,6 +97,7 @@ "\n", "import itertools\n", "import logging\n", + "from typing import TYPE_CHECKING\n", "\n", "import jax.numpy as jnp\n", "import matplotlib.pyplot as plt\n", @@ -123,14 +124,16 @@ " interactive_output,\n", ")\n", "from matplotlib.colors import LogNorm\n", - "from qrules.particle import Particle\n", "from symplot import create_slider\n", "from sympy.core.symbol import Str\n", "from sympy.physics.matrices import msigma\n", "from sympy.physics.quantum.spin import Rotation as Wigner\n", "from tensorwaves.data.transform import SympyDataTransformer\n", "from tensorwaves.function.sympy import create_function, create_parametrized_function\n", - "from tensorwaves.interface import ParametrizedFunction\n", + "\n", + "if TYPE_CHECKING:\n", + " from qrules.particle import Particle\n", + " from tensorwaves.interface import DataSample, ParametrizedFunction\n", "\n", "LOGGER = logging.getLogger()\n", "LOGGER.setLevel(logging.ERROR)\n", @@ -412,7 +415,7 @@ "\n", "\n", "def create_html_table_row(*items, typ=\"td\"):\n", - " items = map(lambda i: f\"<{typ}>{i}\", items)\n", + " items = (f\"<{typ}>{i}\" for i in items)\n", " return \"\" + \"\".join(items) + \"\\n\"\n", "\n", "\n", @@ -2321,7 +2324,7 @@ "source": [ "# Slider construction\n", "sliders = {}\n", - "for symbol, value in free_parameters.items():\n", + "for symbol, _value in free_parameters.items():\n", " if symbol.name.startswith(R\"\\mathcal{H}\"):\n", " real_slider = create_slider(symbol)\n", " imag_slider = create_slider(symbol)\n", @@ -2371,7 +2374,7 @@ "def set_coupling_to_zero(filter_pattern):\n", " if isinstance(filter_pattern, Combobox):\n", " filter_pattern = filter_pattern.value\n", - " for name, slider in sliders.items():\n", + " for name, _slider in sliders.items():\n", " if not name.startswith(R\"\\mathcal{H}\"):\n", " continue\n", " if filter_pattern not in name:\n", @@ -2486,7 +2489,7 @@ "def plot3(**kwargs):\n", " global quiver, mesh\n", " kwargs = to_complex_kwargs(**kwargs)\n", - " for func in list(polarimetry_funcs) + [intensity_func]:\n", + " for func in [*list(polarimetry_funcs), intensity_func]:\n", " func.update_parameters(kwargs)\n", " intensity = intensity_func(phsp_I)\n", " αx, αy, αz = tuple(func(phsp_α).real for func in polarimetry_funcs)\n", diff --git a/docs/report/022.ipynb b/docs/report/022.ipynb index 48628b96..ba18ff38 100644 --- a/docs/report/022.ipynb +++ b/docs/report/022.ipynb @@ -237,7 +237,7 @@ "outputs": [], "source": [ "B_test = tuple(\n", - " tuple(sp.Symbol(Rf\"\\tau={τ}, \\rho={ρ}\") for ρ in range(4)) for τ in range(4)\n", + " tuple(sp.Symbol(Rf\"\\tau={τ}, \\rho={p}\") for ρ in range(4)) for τ in range(4)\n", ")\n", "B_test = sp.Matrix(B_test)\n", "B_test" @@ -519,11 +519,11 @@ " ax.set_box_aspect(1)\n", " if τ == 0 and ρ == 0:\n", " Z = B_arrays[τ, ρ].real\n", - " ax.set_title(f\"$B_{{{τ}{ρ}}}$\")\n", + " ax.set_title(f\"$B_{{{τ}{p}}}$\")\n", " cmap = cmap = cm.viridis\n", " else:\n", " Z = B_norm[τ, ρ].real\n", - " ax.set_title(f\"$B_{{{τ}{ρ}}} / B_{{00}}$\")\n", + " ax.set_title(f\"$B_{{{τ}{p}}} / B_{{00}}$\")\n", " cmap = cmap = cm.coolwarm\n", " mesh = ax.pcolormesh(X, Y, Z, cmap=cmap)\n", " cbar = fig.colorbar(mesh, ax=ax, fraction=0.047, pad=0.01)\n", diff --git a/pyproject.toml b/pyproject.toml index 708215ef..c42559c5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,16 +32,149 @@ target-version = [ "py39", ] -[tool.isort] -profile = "black" - [tool.nbqa.addopts] -black = [ +black = ["--line-length=85"] +ruff = [ + "--extend-ignore=A003", + "--extend-ignore=B008", + "--extend-ignore=B018", + "--extend-ignore=C90", + "--extend-ignore=D", + "--extend-ignore=F404", + "--extend-ignore=F821", # cell magic + "--extend-ignore=ISC003", + "--extend-ignore=N802", + "--extend-ignore=N803", + "--extend-ignore=N806", + "--extend-ignore=N807", + "--extend-ignore=N815", + "--extend-ignore=N816", + "--extend-ignore=PLR09", + "--extend-ignore=PLR2004", + "--extend-ignore=PLW0602", + "--extend-ignore=PLW0603", + "--extend-ignore=PLW2901", "--line-length=85", ] -flake8 = [ - "--extend-ignore=E402,F404,F821", + +[tool.pyright] +exclude = [ + "**/.git", + "**/.ipynb_checkpoints", + "**/.mypy_cache", + "**/.pytest_cache", + "**/.tox", + "**/__pycache__", + "**/_build", ] -isort = [ - "--line-length=85", +reportGeneralTypeIssues = false +reportIncompatibleMethodOverride = false +reportMissingParameterType = false +reportMissingTypeArgument = false +reportMissingTypeStubs = false +reportOverlappingOverload = false +reportPrivateImportUsage = false +reportPrivateUsage = false +reportUnboundVariable = false +reportUnknownArgumentType = false +reportUnknownLambdaType = false +reportUnknownMemberType = false +reportUnknownParameterType = false +reportUnknownVariableType = false +reportUnnecessaryComparison = false +reportUnnecessaryContains = false +reportUnnecessaryIsInstance = false +reportUntypedFunctionDecorator = false +reportUnusedClass = true +reportUnusedFunction = true +reportUnusedImport = true +reportUnusedVariable = true +typeCheckingMode = "strict" + +[tool.pytest.ini_options] +addopts = """ +--color=yes +--durations=0 +--ignore-glob=*/.ipynb_checkpoints/* +--ignore=docs/adr/001/sympy.ipynb +--ignore=docs/conf.py +--nbmake-timeout=1200 +-k='not docs/report/019.ipynb'""" +filterwarnings = [ + "error", + "ignore:Passing a schema to Validator.iter_errors is deprecated.*:DeprecationWarning", + "ignore:The .* argument to NotebookFile is deprecated.*:pytest.PytestRemovedIn8Warning", + "ignore:open_text is deprecated.*:DeprecationWarning", + "ignore:read_text is deprecated.*:DeprecationWarning", + "ignore:unclosed .*:ResourceWarning", +] +norecursedirs = ["_build"] +testpaths = ["docs"] + +[tool.ruff] +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 = [ + "D101", + "D102", + "D103", + "D105", + "D107", + "D203", + "D213", + "D407", + "D416", + "E501", + "SIM108", +] +show-fixes = true +target-version = "py37" +task-tags = ["cspell"] + +[tool.ruff.per-file-ignores] +"docs/*" = [ + "D", + "E402", + "INP001", + "S101", + "S113", + "T201", +] +"docs/conf.py" = [ + "A001", + "PLW2901", +] +"setup.py" = ["D100"] + +[tool.ruff.pydocstyle] +convention = "google" diff --git a/pyrightconfig.json b/pyrightconfig.json deleted file mode 100644 index 8fca337b..00000000 --- a/pyrightconfig.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "exclude": [ - "**/__pycache__", - "**/_build", - "**/.git", - "**/.ipynb_checkpoints", - "**/.mypy_cache", - "**/.pytest_cache", - "**/.tox" - ], - "reportGeneralTypeIssues": false, - "reportIncompatibleMethodOverride": false, - "reportMissingParameterType": false, - "reportMissingTypeArgument": false, - "reportMissingTypeStubs": false, - "reportOverlappingOverload": false, - "reportPrivateImportUsage": false, - "reportPrivateUsage": false, - "reportUnboundVariable": false, - "reportUnknownArgumentType": false, - "reportUnknownLambdaType": false, - "reportUnknownMemberType": false, - "reportUnknownParameterType": false, - "reportUnknownVariableType": false, - "reportUnnecessaryComparison": false, - "reportUnnecessaryContains": false, - "reportUnnecessaryIsInstance": false, - "reportUntypedFunctionDecorator": false, - "reportUnusedClass": true, - "reportUnusedFunction": true, - "reportUnusedImport": true, - "reportUnusedVariable": true, - "typeCheckingMode": "strict" -} diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 067d19c2..00000000 --- a/pytest.ini +++ /dev/null @@ -1,21 +0,0 @@ -[pytest] -addopts = - --color=yes - --durations=0 - --ignore-glob=*/.ipynb_checkpoints/* - --ignore=docs/adr/001/sympy.ipynb - --ignore=docs/conf.py - --nbmake-timeout=1200 - ; notebooks with Julia kernels - -k='not docs/report/019.ipynb' -filterwarnings = - error - ignore:Passing a schema to Validator.iter_errors is deprecated.*:DeprecationWarning - ignore:The .* argument to NotebookFile is deprecated.*:pytest.PytestRemovedIn8Warning - ignore:open_text is deprecated.*:DeprecationWarning - ignore:read_text is deprecated.*:DeprecationWarning - ignore:unclosed .*:ResourceWarning -norecursedirs = - _build -testpaths = - docs diff --git a/setup.cfg b/setup.cfg index 9005f079..57a1184b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -29,7 +29,7 @@ classifiers = Topic :: Scientific/Engineering :: Physics [options] -python_requires = >=3.7, <3.11 +python_requires = >=3.7 install_requires = graphviz ipympl @@ -42,10 +42,8 @@ setup_requires = doc = myst-nb >=0.14 # nb_ configuration prefixes Sphinx >=3 - Sphinx <4.4; python_version <"3.8.0" # https://github.com/ComPWA/compwa-org/runs/4998868790 sphinx-book-theme sphinx-codeautolink[ipython] - sphinx-codeautolink !=0.14.0 # https://github.com/ComPWA/compwa-org/actions/runs/4034663203/jobs/6936046117 sphinx-comments sphinx-copybutton sphinx-issues @@ -58,22 +56,27 @@ doc = sphinxcontrib-plantuml test = jupyter - nbmake <=1.3.0 # https://github.com/ComPWA/compwa-org/runs/7522064686?check_suite_focus=true#step:3:73 + nbmake + nbmake <1.3; python_version=="3.7.*" format = black - isort +lint = + ruff sty = %(format)s + %(lint)s attrs # https://github.com/ComPWA/compwa-org/runs/8127821070?check_suite_focus=true#step:5:52 pre-commit >=1.4.0 +jupyter = + %(doc)s + jupyterlab + jupyterlab-code-formatter + jupyterlab-myst + ypy-websocket <0.8.3; python_version <"3.8.0" dev = %(doc)s + %(jupyter)s %(sty)s %(test)s - aquirdturtle-collapsible-headings - jupyterlab >=3.0.0 - jupyterlab-code-formatter - jupyterlab-myst sphinx-autobuild tox >=1.9 # for skip_install, use_develop - ypy-websocket <0.8.3 # https://github.com/ComPWA/compwa-org/actions/runs/4356883142/jobs/7615490013#step:3:78 From 54491601e1e233db338fbab6432f58d6ad6259b4 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 11 Jul 2023 12:12:58 +0200 Subject: [PATCH 2/2] DOC: provide install commands for Z shell (#199) * DOC: add `--install-hooks` flag * DOC: add link to Miniconda download page * MAINT: remove redundant newlines These newlines were there for Prettier with auto-wrapping. This is not needed anymore. --- docs/develop.md | 141 ++++++++++++++++++++++-------------------------- 1 file changed, 65 insertions(+), 76 deletions(-) diff --git a/docs/develop.md b/docs/develop.md index 37e76752..e68c7175 100644 --- a/docs/develop.md +++ b/docs/develop.md @@ -8,38 +8,32 @@ This page describes some of the tools and conventions followed by [source code of the AmpForm repository](https://github.com/ComPWA/AmpForm) as example, because its file structure is comparable to that of other ComPWA repositories. -:::::{tip} To start developing, simply run the following from a cloned repository on -your machine: - +:::::{tip} +To start developing, simply run the following from a cloned repository on your machine: ::::{tab-set} - :::{tab-item} Conda ```shell conda env create conda activate ampform -pre-commit install +pre-commit install --install-hooks ``` ::: - :::{tab-item} Python venv ```shell python3 -m venv ./venv source ./venv/bin/activate python3 -m pip install -c .constraints/py3.8.txt -e .[dev] -pre-commit install +pre-commit install --install-hooks ``` Replace `3.8` with the Python version you use on your machine. ::: - :::: - See {ref}`develop:Virtual environment` for more info. - ::::: ## Local set-up @@ -59,13 +53,13 @@ case, you have to activate the environment whenever you want to run the framewor the developer tools. ::::{tab-set} - :::{tab-item} Conda environment -[Conda/Anaconda](https://www.anaconda.com) can be installed without administrator -rights, see instructions on -[this page](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html). -In addition, Conda can install more than just Python packages. +[Conda](https://www.anaconda.com) can be installed without administrator rights. It is +recommended to [download +Miniconda](https://docs.conda.io/en/latest/miniconda.html#linux-installers), as it is +much smaller than Anaconda. In addition, Conda can install more than just Python +packages. All packages {ref}`maintained by the ComPWA organization ` provide a @@ -85,7 +79,6 @@ In addition, it will install the framework itself in ["editable" mode](#editable-installation), so that you can start developing right away. ::: - :::{tab-item} Python venv If you have [Python's `venv`](https://docs.python.org/3/library/venv.html), available on @@ -112,7 +105,6 @@ pip install -e . ``` ::: - :::: ### Editable installation @@ -133,7 +125,6 @@ python3 -m pip install -e . ``` :::{toggle} - Internally, this calls: ```shell @@ -152,12 +143,27 @@ They can be installed with [`pip`'s "extras" syntax](https://packaging.python.org/tutorials/installing-packages/#installing-setuptools-extras). Some examples would be: +::::{tab-set} +:::{tab-item} Bash + ```shell pip install tensorwaves[jax,scipy] pip install .[test] # local directory, not editable pip install -e .[dev] # editable + all dev requirements ``` +::: +:::{tab-item} Z shell + +```shell +pip install "tensorwaves[jax,scipy]" +pip install ".[test]" # local directory, not editable +pip install -e ".[dev]" # editable + all dev requirements +``` + +::: +:::: + Developers require several additional tools besides the dependencies required to run the package itself (see {ref}`develop:Automated coding conventions`). All those additional requirements can be installed with the last example. @@ -170,10 +176,8 @@ developer requirements, some of the repositories provide files can be used to 'pin' all versions of installed packages as follows: :::{margin} - Requirements may differ per Python version, so there is one constraint file for each version of Python that the package supports. - ::: ```shell @@ -182,12 +186,27 @@ python3 -m pip install -c .constraints/py3.8.txt -e . The syntax works just as well for {ref}`develop:Optional dependencies`: +::::{tab-set} +:::{tab-item} Bash + ```shell python3 -m pip install -c .constraints/py3.8.txt -e .[doc,sty] python3 -m pip install -c .constraints/py3.8.txt -e .[test] python3 -m pip install -c .constraints/py3.8.txt -e .[dev] ``` +::: +:::{tab-item} Z shell + +```shell +python3 -m pip install -c .constraints/py3.8.txt -e ".[doc,sty]" +python3 -m pip install -c .constraints/py3.8.txt -e ".[test]" +python3 -m pip install -c .constraints/py3.8.txt -e ".[dev]" +``` + +::: +:::: + The constraint files are updated automatically with [`pip-tools`](https://github.com/jazzband/pip-tools) through {ref}`develop:GitHub Actions`. See @@ -196,13 +215,11 @@ and [`requirements-cron.yml`](https://github.com/ComPWA/ampform/actions/workflows/requirements-cron.yml). :::{note} - Constraint files ensure that the framework is _deterministic and reproducible_ (up to testing) _for all commits and versions_, which is vital for both users (doing analysis) and for developers (for instance with {ref}`continuous integration `). In other words, it provides a way out of ["dependency hell"](https://en.wikipedia.org/wiki/Dependency_hell). - ::: ### Updating @@ -210,12 +227,27 @@ way out of ["dependency hell"](https://en.wikipedia.org/wiki/Dependency_hell). It may be that new commits in the repository modify the dependencies. In that case, you have to rerun this command after pulling new commits from the repository: +::::{tab-set} +:::{tab-item} Bash + ```shell git checkout main git pull pip install -c .constraints/py3.8.txt -e .[dev] ``` +::: +:::{tab-item} Z shell + +```shell +git checkout main +git pull +pip install -c .constraints/py3.8.txt -e ".[dev]" +``` + +::: +:::: + If you still have problems, it may be that certain dependencies have become redundant. In that case, trash the virtual environment and {ref}`create a new one `. @@ -233,7 +265,6 @@ accessible. Here's an example, where we also make the Julia executable available system: ::::{tab-set} - :::{tab-item} System-wide installation ```shell @@ -244,7 +275,6 @@ sudo ln -s /opt/julia-1.7.3/bin/julia /usr/local/bin/julia ``` ::: - :::{tab-item} Home-folder installation ```shell @@ -263,7 +293,6 @@ export PATH="~/bin:$PATH" ``` ::: - :::: Just as in Python, it's safest to work with a @@ -281,10 +310,8 @@ environment is reproducible for each commit (see also {ref}`develop:Pinning dependency versions`). :::{seealso} - Have a look {ref}`here` if you want to integrate Jupyter notebooks with Julia kernels into your {ref}`documentation`. - ::: ## Automated coding conventions @@ -311,14 +338,12 @@ All {ref}`style checks ` are enforced through a tool calle as well. This has to be done only once, after you clone the repository: ```shell -pre-commit install +pre-commit install --install-hooks ``` :::{margin} Initializing pre-commit - The first time you run {command}`pre-commit` after installing or updating its checks, it may take some time to initialize. - ::: Upon committing, {command}`pre-commit` runs a set of checks as defined in the file @@ -342,11 +367,9 @@ of these tools. More thorough checks can be run in one go with the following command: :::{margin} Running jobs in parallel - The {code}`-p` flag lets the jobs run in parallel. It also provides a nicer overview of the progress. See [`--parallel`](https://tox.wiki/en/latest/config.html#cmdoption-tox-p) flag. - ::: ```shell @@ -449,15 +472,11 @@ The flag {command}`-n auto` causes {code}`pytest` to [run with a distributed strategy](https://pypi.org/project/pytest-xdist). ::::{margin} - :::{tip} - In VScode, you can visualize test coverage are covered with [Coverage Gutters](https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters). For this you need to run {command}`pytest` with the flag {command}`--cov-report=xml`). - ::: - :::: @@ -479,10 +498,8 @@ pytest --profile-svg and check the stats and the {file}`prof/combined.svg` output file. :::{note} - Jupyter notebooks can also be used as tests. See more info {ref}`here `. - ::: ## Documentation @@ -532,15 +549,11 @@ or just click "details" under the RTD check once you submit your PR. ### Jupyter Notebooks ::::{margin} - :::{tip} - Sometimes it happens that your Jupyter installation does not recognize your {ref}`virtual environment `. In that case, have a look at [these instructions](https://ipython.readthedocs.io/en/stable/install/kernel_install.html#kernels-for-different-environments). - ::: - :::: The [docs](https://github.com/ComPWA/ampform/tree/main/docs) folder can also contain @@ -574,14 +587,12 @@ EXECUTE_NB= tox -e doclive ``` :::{tip} - Notebooks are automatically formatted through {ref}`pre-commit ` (see {ref}`develop:Formatting`). If you want to format the notebooks automatically as you're working, you can do so with [`jupyterlab-code-formatter`](https://ryantam626.github.io/jupyterlab_code_formatter/index.html), which is automatically {ref}`installed with the dev requirements `. - ::: #### IJulia notebooks @@ -592,7 +603,6 @@ It's also possible to execute and render Jupyter notebooks with Julia kernels. F environment): ::::{tab-set} - :::{tab-item} Shell ```shell @@ -600,7 +610,6 @@ julia -e 'import Pkg; Pkg.add("IJulia")' ``` ::: - :::{tab-item} Julia ```julia @@ -609,7 +618,6 @@ Pkg.add("IJulia") ``` ::: - :::: Next, install a Jupyter kernel: @@ -617,7 +625,6 @@ Next, install a Jupyter kernel: ::::{tab-set} - :::{tab-item} Shell ```shell @@ -625,7 +632,6 @@ julia -e 'using IJulia; installkernel("julia")' ``` ::: - :::{tab-item} Julia ```julia @@ -634,13 +640,10 @@ installkernel("julia") ``` ::: - :::: and select it as kernel in the Jupyter notebook. - :::{note} - IJulia has to be installed system-wide to make Sphinx understand how to execute the notebook. You can however access the local environment from the notebook itself, e.g. by defining a cell: @@ -652,7 +655,6 @@ Pkg.instantiate() ``` See {doc}`/report/019` for an example. - ::: ## Collaboration @@ -664,10 +666,8 @@ and developer set-up with GitHub issues (see for instance [report bugs](https://github.com/ComPWA/ampform/issues/new/choose). :::{tip} - If you are new to working with GitHub, have a look at the tutorials on [GitHub Skills](https://skills.github.com). - ::: ### Issue management @@ -726,10 +726,8 @@ found on RTD under "latest", see e.g. #### Epic branches :::{margin} - The word ["epic"](https://www.atlassian.com/agile/project-management/epics) is used in [agile software development](https://en.wikipedia.org/wiki/Agile_software_development). - ::: When working on a feature or larger refactoring that may take a longer time (think of @@ -869,7 +867,6 @@ We are open to other code editors as well. An example would be maintaining a [IntelliJ with Python](https://www.jetbrains.com/help/idea/plugin-overview.html#b370507b). So we'll gladly integrate your editor settings where possible as you [contribute](#collaboration) to the frameworks! - ::: ### Visual Studio code @@ -894,7 +891,6 @@ You can still specify your own settings in as the VSCode settings that come with this are folder settings. :::{dropdown} Conda and VSCode - ComPWA projects are best developed {ref}`with Conda ` and VSCode. The complete developer install procedure then becomes: @@ -917,17 +913,14 @@ developing the code-base. Below you can find some resources we highly recommend be familiar with. :::{margin} - Do you have other recommendations? Edit this page [here](https://github.com/ComPWA/compwa-org/edit/main/docs/develop.md)! - ::: -```{rubric} Software development in Python - -``` +:::{rubric} Software development in Python +::: - [Complete Python Development Guide ― testdriven.io](https://testdriven.io/guides/complete-python) - _Effective Python: 90 Specific Ways to Write Better Python_ (2019) by Brett Slatkin @@ -935,9 +928,8 @@ Do you have other recommendations? Edit this page [its website](https://effectivepython.com). - [Scikit-HEP Developer Information](https://scikit-hep.org/developer) -```{rubric} Clean Code - -``` +:::{rubric} Clean Code +::: - [Clean Code lesson series by "Uncle Bob" on YouTube](https://youtu.be/7EmboKQH8lM) - _Clean Code: A Handbook of Agile Software Craftsmanship_ (2009) by Robert Martin @@ -945,9 +937,8 @@ Do you have other recommendations? Edit this page - [This gist](https://gist.github.com/wojteklu/73c6914cc446146b8b533c0988cf8d29) with a comprehensive summary of the core principles of Martin's _Clean Code_ -```{rubric} Test-Driven Development - -``` +:::{rubric} Test-Driven Development +::: - _Test-Driven Development with Python_ (2017) by Harry Percival {cite}`percivalTestDrivenDevelopmentPython2017` @@ -956,9 +947,8 @@ Do you have other recommendations? Edit this page - [The different types of software testing ― Atlassian](https://www.atlassian.com/continuous-delivery/software-testing/types-of-software-testing) - [Types of Software Testing: 100 Examples of Different Testing Types ― Guru99](https://www.guru99.com/types-of-software-testing.html) -```{rubric} Software Design - -``` +:::{rubric} Software Design +::: - [Design Patterns in Python ― refactoring.guru](https://refactoring.guru/design-patterns/python) - [SourceMaking](https://sourcemaking.com): @@ -976,9 +966,8 @@ Do you have other recommendations? Edit this page while this document provides intended for C++ developers, it is an excellent, up-to-date set of guidelines that apply to any programming language. -```{rubric} Algorithms - -``` +:::{rubric} Algorithms +::: - _Algorithms_ (2011) by Robert Sedgewick and Kevin Wayne {cite}`sedgewickAlgorithms2011`. See also