From 7befb70906b72843b239fc1bb3a448e4211552fd Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Sat, 9 Dec 2023 16:35:40 +0100 Subject: [PATCH] BREAK: drop Python 3.6 support (#44) * DX: clean up `conf.py` * DX: define `tox -e docnblive` job * DX: activate VSCode multi-file diff editor https://code.visualstudio.com/updates/v1_85\#_multifile-diff-editor * DX: remove `"telemetry.enableCrashReporter"` settings * DX: sync required coverage with codecov * FIX: ignore `TYPE_CHECKING` boxes in coverage * FIX: ignore `version.py` file in coverage * FIX: run coverage `tox` job over `tests` folder * FIX: update badge for GitHub Pages * MAINT: update pip constraints and pre-commit --------- Co-authored-by: GitHub --- .constraints/py3.10.txt | 34 ++++- .constraints/py3.11.txt | 34 ++++- .constraints/py3.12.txt | 34 ++++- .constraints/py3.7.txt | 37 +++-- .constraints/py3.8.txt | 34 ++++- .constraints/py3.9.txt | 34 ++++- .cspell.json | 2 - .pre-commit-config.yaml | 21 ++- .vscode/settings.json | 2 +- README.md | 2 +- docs/conf.py | 298 ++++++++++++++----------------------- pyproject.toml | 131 +++++++++++++++- setup.cfg | 110 -------------- setup.py | 6 - src/boostcfg/__init__.py | 12 +- src/boostcfg/lineparser.py | 7 +- src/pawian/data.py | 18 ++- src/pawian/qa.py | 38 ++--- tox.ini | 23 ++- 19 files changed, 478 insertions(+), 399 deletions(-) delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.constraints/py3.10.txt b/.constraints/py3.10.txt index df4c872..6f0b7c0 100644 --- a/.constraints/py3.10.txt +++ b/.constraints/py3.10.txt @@ -2,10 +2,11 @@ # This file is autogenerated by pip-compile with Python 3.10 # by the following command: # -# pip-compile --extra=dev --no-annotate --output-file=.constraints/py3.10.txt --strip-extras +# pip-compile --extra=dev --no-annotate --output-file=.constraints/py3.10.txt --strip-extras --unsafe-package=boostcfg --unsafe-package=pawian --unsafe-package=pawian-tools --unsafe-package=pip --unsafe-package=setuptools # accessible-pygments==0.0.4 alabaster==0.7.13 +annotated-types==0.6.0 anyio==4.1.0 argon2-cffi==23.1.0 argon2-cffi-bindings==21.2.0 @@ -20,6 +21,8 @@ beautifulsoup4==4.12.2 black==23.11.0 bleach==6.1.0 cachetools==5.3.2 +cattrs==23.2.3 +cerberus==1.3.5 certifi==2023.11.17 cffi==1.16.0 cfgv==3.4.0 @@ -35,6 +38,7 @@ debugpy==1.8.0 decorator==5.1.1 defusedxml==0.7.1 distlib==0.3.7 +docopt==0.6.2 docstring-to-markdown==0.13 docutils==0.19 exceptiongroup==1.2.0 @@ -44,6 +48,8 @@ fastjsonschema==2.19.0 filelock==3.13.1 fonttools==4.46.0 fqdn==1.5.1 +gitdb==4.0.11 +gitpython==3.1.40 gprof2dot==2022.7.29 greenlet==3.0.2 identify==2.5.33 @@ -55,6 +61,7 @@ ipykernel==6.27.1 ipython==8.18.1 ipywidgets==8.1.1 isoduration==20.11.0 +isort==5.13.0 jedi==0.19.1 jinja2==3.1.2 json5==0.9.14 @@ -67,16 +74,19 @@ jupyter-core==5.5.0 jupyter-events==0.9.0 jupyter-lsp==2.2.1 jupyter-server==2.12.1 +jupyter-server-mathjax==0.2.6 jupyter-server-terminals==0.4.4 jupyterlab==4.0.9 jupyterlab-code-formatter==2.2.1 +jupyterlab-git==0.50.0 jupyterlab-lsp==5.0.1 -jupyterlab-myst==2.1.0 ; python_version >= "3.7.0" +jupyterlab-myst==2.1.0 jupyterlab-pygments==0.3.0 jupyterlab-server==2.25.2 jupyterlab-widgets==3.0.9 kiwisolver==1.4.5 livereload==2.6.3 +lsprotocol==2023.0.0 markdown-it-py==3.0.0 markupsafe==2.1.3 matplotlib==3.8.2 @@ -90,6 +100,7 @@ myst-nb==1.0.0 myst-parser==2.0.0 nbclient==0.9.0 nbconvert==7.12.0 +nbdime==4.0.1 nbformat==5.9.2 nest-asyncio==1.5.8 nodeenv==1.8.0 @@ -101,9 +112,13 @@ pandas==2.1.4 pandocfilters==1.5.0 parso==0.8.3 pathspec==0.11.2 +pep517==0.13.1 pexpect==4.9.0 pillow==10.1.0 +pip-api==0.0.30 +pipreqs==0.4.13 platformdirs==4.1.0 +plette==0.4.4 pluggy==1.3.0 pre-commit==3.5.0 prometheus-client==0.19.0 @@ -112,8 +127,9 @@ psutil==5.9.6 ptyprocess==0.7.0 pure-eval==0.2.2 pycparser==2.21 +pydantic==2.5.2 +pydantic-core==2.14.5 pydata-sphinx-theme==0.14.4 -pydeps==1.12.17 pygments==2.17.2 pyparsing==3.1.1 pyproject-api==1.6.1 @@ -124,6 +140,7 @@ pytest-xdist==3.5.0 python-dateutil==2.8.2 python-json-logger==2.0.7 python-lsp-jsonrpc==1.1.2 +python-lsp-ruff==2.0.0 python-lsp-server==1.9.0 pytoolconfig==1.2.6 pytz==2023.3.post1 @@ -131,17 +148,20 @@ pyyaml==6.0.1 pyzmq==25.1.2 referencing==0.32.0 requests==2.31.0 +requirementslib==3.0.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 rope==1.11.0 rpds-py==0.13.2 -ruff==0.1.7 ; python_version >= "3.7.0" +ruff==0.1.7 send2trash==1.8.2 six==1.16.0 +smmap==5.0.1 sniffio==1.3.0 snowballstemmer==2.2.0 soupsieve==2.5 sphinx==6.2.1 +sphinx-api-relink==0.0.7 sphinx-autobuild==2021.3.14 sphinx-book-theme==1.0.1 sphinx-codeautolink==0.15.0 @@ -156,16 +176,15 @@ sphinxcontrib-qthelp==1.0.6 sphinxcontrib-serializinghtml==1.1.9 sqlalchemy==2.0.23 stack-data==0.6.3 -stdlib-list==0.10.0 tabulate==0.9.0 terminado==0.18.0 tinycss2==1.2.1 tomli==2.0.1 +tomlkit==0.12.3 tornado==6.4 tox==4.11.4 traitlets==5.14.0 types-python-dateutil==2.8.19.14 -types-setuptools==69.0.0.0 typing-extensions==4.8.0 tzdata==2023.3 ujson==5.8.0 @@ -179,7 +198,10 @@ webencodings==0.5.1 websocket-client==1.7.0 wheel==0.42.0 widgetsnbextension==4.0.9 +yarg==0.1.9 zipp==3.17.0 # The following packages are considered to be unsafe in a requirements file: +# pawian-tools +# pip # setuptools diff --git a/.constraints/py3.11.txt b/.constraints/py3.11.txt index 36ba7ed..f41455e 100644 --- a/.constraints/py3.11.txt +++ b/.constraints/py3.11.txt @@ -2,10 +2,11 @@ # This file is autogenerated by pip-compile with Python 3.11 # by the following command: # -# pip-compile --extra=dev --no-annotate --output-file=.constraints/py3.11.txt --strip-extras +# pip-compile --extra=dev --no-annotate --output-file=.constraints/py3.11.txt --strip-extras --unsafe-package=boostcfg --unsafe-package=pawian --unsafe-package=pawian-tools --unsafe-package=pip --unsafe-package=setuptools # accessible-pygments==0.0.4 alabaster==0.7.13 +annotated-types==0.6.0 anyio==4.1.0 argon2-cffi==23.1.0 argon2-cffi-bindings==21.2.0 @@ -20,6 +21,8 @@ beautifulsoup4==4.12.2 black==23.11.0 bleach==6.1.0 cachetools==5.3.2 +cattrs==23.2.3 +cerberus==1.3.5 certifi==2023.11.17 cffi==1.16.0 cfgv==3.4.0 @@ -35,6 +38,7 @@ debugpy==1.8.0 decorator==5.1.1 defusedxml==0.7.1 distlib==0.3.7 +docopt==0.6.2 docstring-to-markdown==0.13 docutils==0.19 execnet==2.0.2 @@ -43,6 +47,8 @@ fastjsonschema==2.19.0 filelock==3.13.1 fonttools==4.46.0 fqdn==1.5.1 +gitdb==4.0.11 +gitpython==3.1.40 gprof2dot==2022.7.29 greenlet==3.0.2 identify==2.5.33 @@ -54,6 +60,7 @@ ipykernel==6.27.1 ipython==8.18.1 ipywidgets==8.1.1 isoduration==20.11.0 +isort==5.13.0 jedi==0.19.1 jinja2==3.1.2 json5==0.9.14 @@ -66,16 +73,19 @@ jupyter-core==5.5.0 jupyter-events==0.9.0 jupyter-lsp==2.2.1 jupyter-server==2.12.1 +jupyter-server-mathjax==0.2.6 jupyter-server-terminals==0.4.4 jupyterlab==4.0.9 jupyterlab-code-formatter==2.2.1 +jupyterlab-git==0.50.0 jupyterlab-lsp==5.0.1 -jupyterlab-myst==2.1.0 ; python_version >= "3.7.0" +jupyterlab-myst==2.1.0 jupyterlab-pygments==0.3.0 jupyterlab-server==2.25.2 jupyterlab-widgets==3.0.9 kiwisolver==1.4.5 livereload==2.6.3 +lsprotocol==2023.0.0 markdown-it-py==3.0.0 markupsafe==2.1.3 matplotlib==3.8.2 @@ -89,6 +99,7 @@ myst-nb==1.0.0 myst-parser==2.0.0 nbclient==0.9.0 nbconvert==7.12.0 +nbdime==4.0.1 nbformat==5.9.2 nest-asyncio==1.5.8 nodeenv==1.8.0 @@ -100,9 +111,13 @@ pandas==2.1.4 pandocfilters==1.5.0 parso==0.8.3 pathspec==0.11.2 +pep517==0.13.1 pexpect==4.9.0 pillow==10.1.0 +pip-api==0.0.30 +pipreqs==0.4.13 platformdirs==4.1.0 +plette==0.4.4 pluggy==1.3.0 pre-commit==3.5.0 prometheus-client==0.19.0 @@ -111,8 +126,9 @@ psutil==5.9.6 ptyprocess==0.7.0 pure-eval==0.2.2 pycparser==2.21 +pydantic==2.5.2 +pydantic-core==2.14.5 pydata-sphinx-theme==0.14.4 -pydeps==1.12.17 pygments==2.17.2 pyparsing==3.1.1 pyproject-api==1.6.1 @@ -123,6 +139,7 @@ pytest-xdist==3.5.0 python-dateutil==2.8.2 python-json-logger==2.0.7 python-lsp-jsonrpc==1.1.2 +python-lsp-ruff==2.0.0 python-lsp-server==1.9.0 pytoolconfig==1.2.6 pytz==2023.3.post1 @@ -130,17 +147,20 @@ pyyaml==6.0.1 pyzmq==25.1.2 referencing==0.32.0 requests==2.31.0 +requirementslib==3.0.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 rope==1.11.0 rpds-py==0.13.2 -ruff==0.1.7 ; python_version >= "3.7.0" +ruff==0.1.7 send2trash==1.8.2 six==1.16.0 +smmap==5.0.1 sniffio==1.3.0 snowballstemmer==2.2.0 soupsieve==2.5 sphinx==6.2.1 +sphinx-api-relink==0.0.7 sphinx-autobuild==2021.3.14 sphinx-book-theme==1.0.1 sphinx-codeautolink==0.15.0 @@ -155,15 +175,14 @@ sphinxcontrib-qthelp==1.0.6 sphinxcontrib-serializinghtml==1.1.9 sqlalchemy==2.0.23 stack-data==0.6.3 -stdlib-list==0.10.0 tabulate==0.9.0 terminado==0.18.0 tinycss2==1.2.1 +tomlkit==0.12.3 tornado==6.4 tox==4.11.4 traitlets==5.14.0 types-python-dateutil==2.8.19.14 -types-setuptools==69.0.0.0 typing-extensions==4.8.0 tzdata==2023.3 ujson==5.8.0 @@ -177,7 +196,10 @@ webencodings==0.5.1 websocket-client==1.7.0 wheel==0.42.0 widgetsnbextension==4.0.9 +yarg==0.1.9 zipp==3.17.0 # The following packages are considered to be unsafe in a requirements file: +# pawian-tools +# pip # setuptools diff --git a/.constraints/py3.12.txt b/.constraints/py3.12.txt index 7a61b64..ec94920 100644 --- a/.constraints/py3.12.txt +++ b/.constraints/py3.12.txt @@ -2,10 +2,11 @@ # This file is autogenerated by pip-compile with Python 3.12 # by the following command: # -# pip-compile --extra=dev --no-annotate --output-file=.constraints/py3.12.txt --strip-extras +# pip-compile --extra=dev --no-annotate --output-file=.constraints/py3.12.txt --strip-extras --unsafe-package=boostcfg --unsafe-package=pawian --unsafe-package=pawian-tools --unsafe-package=pip --unsafe-package=setuptools # accessible-pygments==0.0.4 alabaster==0.7.13 +annotated-types==0.6.0 anyio==4.1.0 argon2-cffi==23.1.0 argon2-cffi-bindings==21.2.0 @@ -20,6 +21,8 @@ beautifulsoup4==4.12.2 black==23.11.0 bleach==6.1.0 cachetools==5.3.2 +cattrs==23.2.3 +cerberus==1.3.5 certifi==2023.11.17 cffi==1.16.0 cfgv==3.4.0 @@ -35,6 +38,7 @@ debugpy==1.8.0 decorator==5.1.1 defusedxml==0.7.1 distlib==0.3.7 +docopt==0.6.2 docstring-to-markdown==0.13 docutils==0.19 execnet==2.0.2 @@ -43,6 +47,8 @@ fastjsonschema==2.19.0 filelock==3.13.1 fonttools==4.46.0 fqdn==1.5.1 +gitdb==4.0.11 +gitpython==3.1.40 gprof2dot==2022.7.29 greenlet==3.0.2 identify==2.5.33 @@ -54,6 +60,7 @@ ipykernel==6.27.1 ipython==8.18.1 ipywidgets==8.1.1 isoduration==20.11.0 +isort==5.13.0 jedi==0.19.1 jinja2==3.1.2 json5==0.9.14 @@ -66,16 +73,19 @@ jupyter-core==5.5.0 jupyter-events==0.9.0 jupyter-lsp==2.2.1 jupyter-server==2.12.1 +jupyter-server-mathjax==0.2.6 jupyter-server-terminals==0.4.4 jupyterlab==4.0.9 jupyterlab-code-formatter==2.2.1 +jupyterlab-git==0.50.0 jupyterlab-lsp==5.0.1 -jupyterlab-myst==2.1.0 ; python_version >= "3.7.0" +jupyterlab-myst==2.1.0 jupyterlab-pygments==0.3.0 jupyterlab-server==2.25.2 jupyterlab-widgets==3.0.9 kiwisolver==1.4.5 livereload==2.6.3 +lsprotocol==2023.0.0 markdown-it-py==3.0.0 markupsafe==2.1.3 matplotlib==3.8.2 @@ -89,6 +99,7 @@ myst-nb==1.0.0 myst-parser==2.0.0 nbclient==0.9.0 nbconvert==7.12.0 +nbdime==4.0.1 nbformat==5.9.2 nest-asyncio==1.5.8 nodeenv==1.8.0 @@ -100,9 +111,13 @@ pandas==2.1.4 pandocfilters==1.5.0 parso==0.8.3 pathspec==0.11.2 +pep517==0.13.1 pexpect==4.9.0 pillow==10.1.0 +pip-api==0.0.30 +pipreqs==0.4.13 platformdirs==4.1.0 +plette==0.4.4 pluggy==1.3.0 pre-commit==3.5.0 prometheus-client==0.19.0 @@ -111,8 +126,9 @@ psutil==5.9.6 ptyprocess==0.7.0 pure-eval==0.2.2 pycparser==2.21 +pydantic==2.5.2 +pydantic-core==2.14.5 pydata-sphinx-theme==0.14.4 -pydeps==1.12.17 pygments==2.17.2 pyparsing==3.1.1 pyproject-api==1.6.1 @@ -123,6 +139,7 @@ pytest-xdist==3.5.0 python-dateutil==2.8.2 python-json-logger==2.0.7 python-lsp-jsonrpc==1.1.2 +python-lsp-ruff==2.0.0 python-lsp-server==1.9.0 pytoolconfig==1.2.6 pytz==2023.3.post1 @@ -130,17 +147,20 @@ pyyaml==6.0.1 pyzmq==25.1.2 referencing==0.32.0 requests==2.31.0 +requirementslib==3.0.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 rope==1.11.0 rpds-py==0.13.2 -ruff==0.1.7 ; python_version >= "3.7.0" +ruff==0.1.7 send2trash==1.8.2 six==1.16.0 +smmap==5.0.1 sniffio==1.3.0 snowballstemmer==2.2.0 soupsieve==2.5 sphinx==6.2.1 +sphinx-api-relink==0.0.7 sphinx-autobuild==2021.3.14 sphinx-book-theme==1.0.1 sphinx-codeautolink==0.15.0 @@ -155,15 +175,14 @@ sphinxcontrib-qthelp==1.0.6 sphinxcontrib-serializinghtml==1.1.9 sqlalchemy==2.0.23 stack-data==0.6.3 -stdlib-list==0.10.0 tabulate==0.9.0 terminado==0.18.0 tinycss2==1.2.1 +tomlkit==0.12.3 tornado==6.4 tox==4.11.4 traitlets==5.14.0 types-python-dateutil==2.8.19.14 -types-setuptools==69.0.0.0 typing-extensions==4.8.0 tzdata==2023.3 ujson==5.8.0 @@ -177,7 +196,10 @@ webencodings==0.5.1 websocket-client==1.7.0 wheel==0.42.0 widgetsnbextension==4.0.9 +yarg==0.1.9 zipp==3.17.0 # The following packages are considered to be unsafe in a requirements file: +# pawian-tools +# pip # setuptools diff --git a/.constraints/py3.7.txt b/.constraints/py3.7.txt index c742163..0c53021 100644 --- a/.constraints/py3.7.txt +++ b/.constraints/py3.7.txt @@ -2,7 +2,7 @@ # This file is autogenerated by pip-compile with Python 3.7 # by the following command: # -# pip-compile --extra=dev --no-annotate --output-file=.constraints/py3.7.txt --resolver=backtracking --strip-extras +# pip-compile --extra=dev --no-annotate --output-file=.constraints/py3.7.txt --resolver=backtracking --strip-extras --unsafe-package=boostcfg --unsafe-package=pawian --unsafe-package=pawian-tools --unsafe-package=pip --unsafe-package=setuptools # accessible-pygments==0.0.4 aiofiles==22.1.0 @@ -21,9 +21,12 @@ beautifulsoup4==4.12.2 black==23.3.0 bleach==6.0.0 cached-property==1.5.2 +cachetools==5.3.2 +cattrs==23.1.2 certifi==2023.11.17 cffi==1.15.1 cfgv==3.3.1 +chardet==5.2.0 charset-normalizer==3.3.2 click==8.1.7 colorama==0.4.6 @@ -35,7 +38,7 @@ decorator==5.1.1 defusedxml==0.7.1 distlib==0.3.7 docstring-to-markdown==0.13 -docutils==0.17.1 +docutils==0.19 entrypoints==0.4 exceptiongroup==1.2.0 execnet==2.0.2 @@ -43,12 +46,14 @@ fastjsonschema==2.19.0 filelock==3.12.2 fonttools==4.38.0 fqdn==1.5.1 +gitdb==4.0.11 +gitpython==3.1.40 gprof2dot==2022.7.29 greenlet==3.0.2 identify==2.5.24 idna==3.6 imagesize==1.4.1 -importlib-metadata==6.7.0 ; python_version < "3.8.0" +importlib-metadata==6.7.0 importlib-resources==5.12.0 iniconfig==2.0.0 ipykernel==6.16.2 @@ -56,6 +61,7 @@ ipython==7.34.0 ipython-genutils==0.2.0 ipywidgets==8.1.1 isoduration==20.11.0 +isort==5.11.5 jedi==0.18.2 jinja2==3.1.2 json5==0.9.14 @@ -68,17 +74,20 @@ jupyter-events==0.6.3 jupyter-lsp==1.5.1 jupyter-server==1.24.0 jupyter-server-fileid==0.9.0 +jupyter-server-mathjax==0.2.6 jupyter-server-ydoc==0.8.0 jupyter-ydoc==0.2.5 jupyterlab==3.6.6 jupyterlab-code-formatter==2.2.1 +jupyterlab-git==0.44.0 jupyterlab-lsp==3.10.2 -jupyterlab-myst==1.2.0 ; python_version >= "3.7.0" +jupyterlab-myst==1.2.0 jupyterlab-pygments==0.2.2 jupyterlab-server==2.24.0 jupyterlab-widgets==3.0.9 kiwisolver==1.4.5 livereload==2.6.3 +lsprotocol==2023.0.0 markdown-it-py==2.2.0 markupsafe==2.1.3 matplotlib==3.5.3 @@ -93,6 +102,7 @@ myst-parser==0.18.1 nbclassic==1.0.0 nbclient==0.5.13 nbconvert==7.6.0 +nbdime==3.2.1 nbformat==5.8.0 nest-asyncio==1.5.8 nodeenv==1.8.0 @@ -108,19 +118,18 @@ pexpect==4.9.0 pickleshare==0.7.5 pillow==9.5.0 pkgutil-resolve-name==1.3.10 -platformdirs==3.11.0 +platformdirs==4.0.0 pluggy==1.2.0 pre-commit==2.21.0 prometheus-client==0.17.1 prompt-toolkit==3.0.41 psutil==5.9.6 ptyprocess==0.7.0 -py==1.11.0 pycparser==2.21 pydata-sphinx-theme==0.13.3 -pydeps==1.12.17 pygments==2.17.2 pyparsing==3.1.1 +pyproject-api==1.5.3 pyrsistent==0.19.3 pytest==7.4.3 pytest-cov==4.1.0 @@ -129,6 +138,7 @@ pytest-xdist==3.5.0 python-dateutil==2.8.2 python-json-logger==2.0.7 python-lsp-jsonrpc==1.0.0 +python-lsp-ruff==1.6.0 python-lsp-server==1.7.4 pytoolconfig==1.2.6 pytz==2023.3.post1 @@ -138,13 +148,15 @@ requests==2.31.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 rope==1.9.0 -ruff==0.1.7 ; python_version >= "3.7.0" +ruff==0.1.7 send2trash==1.8.2 six==1.16.0 +smmap==5.0.1 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-api-relink==0.0.7 sphinx-autobuild==2021.3.14 sphinx-book-theme==1.0.1 sphinx-codeautolink==0.15.0 @@ -158,22 +170,20 @@ sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 sqlalchemy==1.4.50 -stdlib-list==0.10.0 tabulate==0.9.0 terminado==0.17.1 tinycss2==1.2.1 tomli==2.0.1 tornado==6.2 -tox==3.28.0 ; python_version < "3.8.0" +tox==4.8.0 traitlets==5.9.0 typed-ast==1.5.5 -types-setuptools==69.0.0.0 typing-extensions==4.7.1 ujson==5.7.0 uproot==5.0.13 uri-template==1.3.0 urllib3==2.0.7 -virtualenv==20.21.1 ; python_version < "3.8.0" +virtualenv==20.25.0 wcwidth==0.2.12 webcolors==1.13 webencodings==0.5.1 @@ -185,4 +195,5 @@ ypy-websocket==0.8.4 zipp==3.15.0 # The following packages are considered to be unsafe in a requirements file: +# pawian-tools # setuptools diff --git a/.constraints/py3.8.txt b/.constraints/py3.8.txt index f2dc9ff..8cc8436 100644 --- a/.constraints/py3.8.txt +++ b/.constraints/py3.8.txt @@ -2,10 +2,11 @@ # This file is autogenerated by pip-compile with Python 3.8 # by the following command: # -# pip-compile --extra=dev --no-annotate --output-file=.constraints/py3.8.txt --strip-extras +# pip-compile --extra=dev --no-annotate --output-file=.constraints/py3.8.txt --strip-extras --unsafe-package=boostcfg --unsafe-package=pawian --unsafe-package=pawian-tools --unsafe-package=pip --unsafe-package=setuptools # accessible-pygments==0.0.4 alabaster==0.7.13 +annotated-types==0.6.0 anyio==4.1.0 argon2-cffi==23.1.0 argon2-cffi-bindings==21.2.0 @@ -21,6 +22,8 @@ beautifulsoup4==4.12.2 black==23.11.0 bleach==6.1.0 cachetools==5.3.2 +cattrs==23.2.3 +cerberus==1.3.5 certifi==2023.11.17 cffi==1.16.0 cfgv==3.4.0 @@ -36,6 +39,7 @@ debugpy==1.8.0 decorator==5.1.1 defusedxml==0.7.1 distlib==0.3.7 +docopt==0.6.2 docstring-to-markdown==0.13 docutils==0.19 exceptiongroup==1.2.0 @@ -45,6 +49,8 @@ fastjsonschema==2.19.0 filelock==3.13.1 fonttools==4.46.0 fqdn==1.5.1 +gitdb==4.0.11 +gitpython==3.1.40 gprof2dot==2022.7.29 greenlet==3.0.2 identify==2.5.33 @@ -57,6 +63,7 @@ ipykernel==6.27.1 ipython==8.12.3 ipywidgets==8.1.1 isoduration==20.11.0 +isort==5.13.0 jedi==0.19.1 jinja2==3.1.2 json5==0.9.14 @@ -69,16 +76,19 @@ jupyter-core==5.5.0 jupyter-events==0.9.0 jupyter-lsp==2.2.1 jupyter-server==2.12.1 +jupyter-server-mathjax==0.2.6 jupyter-server-terminals==0.4.4 jupyterlab==4.0.9 jupyterlab-code-formatter==2.2.1 +jupyterlab-git==0.50.0 jupyterlab-lsp==5.0.1 -jupyterlab-myst==2.1.0 ; python_version >= "3.7.0" +jupyterlab-myst==2.1.0 jupyterlab-pygments==0.3.0 jupyterlab-server==2.25.2 jupyterlab-widgets==3.0.9 kiwisolver==1.4.5 livereload==2.6.3 +lsprotocol==2023.0.0 markdown-it-py==2.2.0 markupsafe==2.1.3 matplotlib==3.7.4 @@ -92,6 +102,7 @@ myst-nb==0.17.2 myst-parser==0.18.1 nbclient==0.7.4 nbconvert==7.12.0 +nbdime==4.0.1 nbformat==5.9.2 nest-asyncio==1.5.8 nodeenv==1.8.0 @@ -103,11 +114,15 @@ pandas==2.0.3 pandocfilters==1.5.0 parso==0.8.3 pathspec==0.11.2 +pep517==0.13.1 pexpect==4.9.0 pickleshare==0.7.5 pillow==10.1.0 +pip-api==0.0.30 +pipreqs==0.4.13 pkgutil-resolve-name==1.3.10 platformdirs==4.1.0 +plette==0.4.4 pluggy==1.3.0 pre-commit==3.5.0 prometheus-client==0.19.0 @@ -116,8 +131,9 @@ psutil==5.9.6 ptyprocess==0.7.0 pure-eval==0.2.2 pycparser==2.21 +pydantic==2.5.2 +pydantic-core==2.14.5 pydata-sphinx-theme==0.14.4 -pydeps==1.12.17 pygments==2.17.2 pyparsing==3.1.1 pyproject-api==1.6.1 @@ -128,6 +144,7 @@ pytest-xdist==3.5.0 python-dateutil==2.8.2 python-json-logger==2.0.7 python-lsp-jsonrpc==1.1.2 +python-lsp-ruff==2.0.0 python-lsp-server==1.9.0 pytoolconfig==1.2.6 pytz==2023.3.post1 @@ -135,17 +152,20 @@ pyyaml==6.0.1 pyzmq==25.1.2 referencing==0.32.0 requests==2.31.0 +requirementslib==3.0.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 rope==1.11.0 rpds-py==0.13.2 -ruff==0.1.7 ; python_version >= "3.7.0" +ruff==0.1.7 send2trash==1.8.2 six==1.16.0 +smmap==5.0.1 sniffio==1.3.0 snowballstemmer==2.2.0 soupsieve==2.5 sphinx==5.3.0 +sphinx-api-relink==0.0.7 sphinx-autobuild==2021.3.14 sphinx-book-theme==1.0.1 sphinx-codeautolink==0.15.0 @@ -160,16 +180,15 @@ sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 sqlalchemy==2.0.23 stack-data==0.6.3 -stdlib-list==0.10.0 tabulate==0.9.0 terminado==0.18.0 tinycss2==1.2.1 tomli==2.0.1 +tomlkit==0.12.3 tornado==6.4 tox==4.11.4 traitlets==5.14.0 types-python-dateutil==2.8.19.14 -types-setuptools==69.0.0.0 typing-extensions==4.8.0 tzdata==2023.3 ujson==5.8.0 @@ -183,7 +202,10 @@ webencodings==0.5.1 websocket-client==1.7.0 wheel==0.42.0 widgetsnbextension==4.0.9 +yarg==0.1.9 zipp==3.17.0 # The following packages are considered to be unsafe in a requirements file: +# pawian-tools +# pip # setuptools diff --git a/.constraints/py3.9.txt b/.constraints/py3.9.txt index 96643e4..ce93860 100644 --- a/.constraints/py3.9.txt +++ b/.constraints/py3.9.txt @@ -2,10 +2,11 @@ # This file is autogenerated by pip-compile with Python 3.9 # by the following command: # -# pip-compile --extra=dev --no-annotate --output-file=.constraints/py3.9.txt --strip-extras +# pip-compile --extra=dev --no-annotate --output-file=.constraints/py3.9.txt --strip-extras --unsafe-package=boostcfg --unsafe-package=pawian --unsafe-package=pawian-tools --unsafe-package=pip --unsafe-package=setuptools # accessible-pygments==0.0.4 alabaster==0.7.13 +annotated-types==0.6.0 anyio==4.1.0 argon2-cffi==23.1.0 argon2-cffi-bindings==21.2.0 @@ -20,6 +21,8 @@ beautifulsoup4==4.12.2 black==23.11.0 bleach==6.1.0 cachetools==5.3.2 +cattrs==23.2.3 +cerberus==1.3.5 certifi==2023.11.17 cffi==1.16.0 cfgv==3.4.0 @@ -35,6 +38,7 @@ debugpy==1.8.0 decorator==5.1.1 defusedxml==0.7.1 distlib==0.3.7 +docopt==0.6.2 docstring-to-markdown==0.13 docutils==0.19 exceptiongroup==1.2.0 @@ -44,6 +48,8 @@ fastjsonschema==2.19.0 filelock==3.13.1 fonttools==4.46.0 fqdn==1.5.1 +gitdb==4.0.11 +gitpython==3.1.40 gprof2dot==2022.7.29 greenlet==3.0.2 identify==2.5.33 @@ -56,6 +62,7 @@ ipykernel==6.27.1 ipython==8.18.1 ipywidgets==8.1.1 isoduration==20.11.0 +isort==5.13.0 jedi==0.19.1 jinja2==3.1.2 json5==0.9.14 @@ -68,16 +75,19 @@ jupyter-core==5.5.0 jupyter-events==0.9.0 jupyter-lsp==2.2.1 jupyter-server==2.12.1 +jupyter-server-mathjax==0.2.6 jupyter-server-terminals==0.4.4 jupyterlab==4.0.9 jupyterlab-code-formatter==2.2.1 +jupyterlab-git==0.50.0 jupyterlab-lsp==5.0.1 -jupyterlab-myst==2.1.0 ; python_version >= "3.7.0" +jupyterlab-myst==2.1.0 jupyterlab-pygments==0.3.0 jupyterlab-server==2.25.2 jupyterlab-widgets==3.0.9 kiwisolver==1.4.5 livereload==2.6.3 +lsprotocol==2023.0.0 markdown-it-py==3.0.0 markupsafe==2.1.3 matplotlib==3.8.2 @@ -91,6 +101,7 @@ myst-nb==1.0.0 myst-parser==2.0.0 nbclient==0.9.0 nbconvert==7.12.0 +nbdime==4.0.1 nbformat==5.9.2 nest-asyncio==1.5.8 nodeenv==1.8.0 @@ -102,9 +113,13 @@ pandas==2.1.4 pandocfilters==1.5.0 parso==0.8.3 pathspec==0.11.2 +pep517==0.13.1 pexpect==4.9.0 pillow==10.1.0 +pip-api==0.0.30 +pipreqs==0.4.13 platformdirs==4.1.0 +plette==0.4.4 pluggy==1.3.0 pre-commit==3.5.0 prometheus-client==0.19.0 @@ -113,8 +128,9 @@ psutil==5.9.6 ptyprocess==0.7.0 pure-eval==0.2.2 pycparser==2.21 +pydantic==2.5.2 +pydantic-core==2.14.5 pydata-sphinx-theme==0.14.4 -pydeps==1.12.17 pygments==2.17.2 pyparsing==3.1.1 pyproject-api==1.6.1 @@ -125,6 +141,7 @@ pytest-xdist==3.5.0 python-dateutil==2.8.2 python-json-logger==2.0.7 python-lsp-jsonrpc==1.1.2 +python-lsp-ruff==2.0.0 python-lsp-server==1.9.0 pytoolconfig==1.2.6 pytz==2023.3.post1 @@ -132,17 +149,20 @@ pyyaml==6.0.1 pyzmq==25.1.2 referencing==0.32.0 requests==2.31.0 +requirementslib==3.0.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 rope==1.11.0 rpds-py==0.13.2 -ruff==0.1.7 ; python_version >= "3.7.0" +ruff==0.1.7 send2trash==1.8.2 six==1.16.0 +smmap==5.0.1 sniffio==1.3.0 snowballstemmer==2.2.0 soupsieve==2.5 sphinx==6.2.1 +sphinx-api-relink==0.0.7 sphinx-autobuild==2021.3.14 sphinx-book-theme==1.0.1 sphinx-codeautolink==0.15.0 @@ -157,16 +177,15 @@ sphinxcontrib-qthelp==1.0.6 sphinxcontrib-serializinghtml==1.1.9 sqlalchemy==2.0.23 stack-data==0.6.3 -stdlib-list==0.10.0 tabulate==0.9.0 terminado==0.18.0 tinycss2==1.2.1 tomli==2.0.1 +tomlkit==0.12.3 tornado==6.4 tox==4.11.4 traitlets==5.14.0 types-python-dateutil==2.8.19.14 -types-setuptools==69.0.0.0 typing-extensions==4.8.0 tzdata==2023.3 ujson==5.8.0 @@ -180,7 +199,10 @@ webencodings==0.5.1 websocket-client==1.7.0 wheel==0.42.0 widgetsnbextension==4.0.9 +yarg==0.1.9 zipp==3.17.0 # The following packages are considered to be unsafe in a requirements file: +# pawian-tools +# pip # setuptools diff --git a/.cspell.json b/.cspell.json index d20e61e..ee803c8 100644 --- a/.cspell.json +++ b/.cspell.json @@ -26,8 +26,6 @@ "docs/_templates/*", "docs/conf.py", "pyproject.toml", - "setup.cfg", - "setup.py", "tox.ini" ], "ignoreWords": [ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c8ea5fc..0332037 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,17 +13,6 @@ repos: - id: check-hooks-apply - id: check-useless-excludes - - repo: https://github.com/ComPWA/repo-maintenance - rev: 0.1.9 - hooks: - - id: check-dev-files - args: - - --no-prettierrc - - --pin-requirements=bimonthly - - --repo-name=PawianTools - - --repo-title=Pawian Tools - - id: format-setup-cfg - - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 hooks: @@ -52,6 +41,16 @@ repos: types_or: - jupyter + - repo: https://github.com/ComPWA/repo-maintenance + rev: 0.1.9 + hooks: + - id: check-dev-files + args: + - --no-prettierrc + - --pin-requirements=bimonthly + - --repo-name=PawianTools + - --repo-title=Pawian Tools + - repo: https://github.com/streetsidesoftware/cspell-cli rev: v8.1.1 hooks: diff --git a/.vscode/settings.json b/.vscode/settings.json index fed79fa..0b14d0d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -37,6 +37,7 @@ "github-actions.workflows.pinned.workflows": [".github/workflows/ci.yml"], "gitlens.telemetry.enabled": false, "livePreview.defaultPreviewPath": "docs/_build/html", + "multiDiffEditor.experimental.enabled": true, "mypy-type-checker.args": ["--config-file=${workspaceFolder}/pyproject.toml"], "mypy-type-checker.importStrategy": "fromEnvironment", "notebook.gotoSymbols.showAllSymbols": true, @@ -55,7 +56,6 @@ ".constraints/*.txt": true, "tests/**/__init__.py": true }, - "telemetry.enableCrashReporter": false, "yaml.schemas": { "https://json.schemastore.org/github-workflow.json": "file:///home/redeboer/dev/redeboer/PawianTools/.github/workflows/requirements.yml" } diff --git a/README.md b/README.md index ea19100..faa9205 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Python Tools for Pawian -[![GitHub Pages](https://github.com/redeboer/PawianTools/actions/workflows/gh-pages.yml/badge.svg)](https://github.com/redeboer/PawianTools/actions/workflows/gh-pages.yml) +[![GitHub Pages](https://github.com/redeboer/PawianTools/actions/workflows/ci.yml/badge.svg)](https://github.com/redeboer/PawianTools/actions/workflows/ci.yml) [![Binder](https://static.mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/redeboer/PawianTools/stable?filepath=docs/usage) [![Google Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/redeboer/PawianTools/blob/main) [![GPLv3+ license](https://img.shields.io/badge/License-GPLv3+-blue.svg)](https://www.gnu.org/licenses/gpl-3.0-standalone.html) diff --git a/docs/conf.py b/docs/conf.py index 9541bc8..66a2379 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -4,63 +4,68 @@ documentation: https://www.sphinx-doc.org/en/master/usage/configuration.html """ -import os -import re -import shutil -import subprocess -import sys -from typing import Dict +from __future__ import annotations + +from sphinx_api_relink.helpers import ( + get_branch_name, + get_execution_mode, + get_package_version, + pin, + pin_minor, + set_intersphinx_version_remapping, +) -if sys.version_info < (3, 8): - from importlib_metadata import PackageNotFoundError - from importlib_metadata import version as get_package_version -else: - from importlib.metadata import PackageNotFoundError - from importlib.metadata import version as get_package_version +set_intersphinx_version_remapping({ + "ipython": { + "8.12.2": "8.12.1", + "8.12.3": "8.12.1", + }, +}) -# -- Project information ----------------------------------------------------- -project = "PawianTools" +BRANCH = get_branch_name() +ORGANIZATION = "redeboer" PACKAGE = "pawian" REPO_NAME = "PawianTools" -copyright = "2020, RUB EP1" -author = "Meike Küßner, Remco de Boer" - -try: - __VERSION = get_package_version(PACKAGE) - version = ".".join(__VERSION.split(".")[:3]) -except PackageNotFoundError: - pass +REPO_TITLE = REPO_NAME -# -- Generate API ------------------------------------------------------------ -shutil.rmtree("api", ignore_errors=True) -subprocess.call( - " ".join([ - "sphinx-apidoc", - "../src/", - "-o api/", - "--force", - "--no-toc", - "--templatedir _templates", - "--separate", +add_module_names = False +api_github_repo = f"{ORGANIZATION}/{REPO_NAME}" +api_target_substitutions: dict[str, str | tuple[str, str]] = { + "Axes": "matplotlib.axes.Axes", + "BarContainer": "matplotlib.container.BarContainer", + "Figure": "matplotlib.figure.Figure", + "TH1": "uproot.behaviors.TH1.TH1", + "TH2": "uproot.behaviors.TH2.TH2", + "TH3": "uproot.behaviors.TH3.TH3", + "np.ndarray": "numpy.ndarray", + "pd.DataFrame": "pandas.core.frame.DataFrame", +} +author = "Meike Küßner, Remco de Boer" +autodoc_default_options = { + "members": True, + "undoc-members": True, + "show-inheritance": True, + "special-members": ", ".join([ + "__call__", + "__eq__", ]), - shell=True, # noqa: S602 -) - -# -- General configuration --------------------------------------------------- -master_doc = "index.md" -source_suffix = { - ".ipynb": "myst-nb", - ".md": "myst-nb", - ".rst": "restructuredtext", } - -# The master toctree document. -master_doc = "index" -modindex_common_prefix = [ - "boostcfg.", - f"{PACKAGE}.", +autodoc_member_order = "bysource" +autodoc_typehints_format = "short" +autosectionlabel_prefix_document = True +codeautolink_concat_default = True +codeautolink_global_preface = """ +from IPython.display import display +""" +copybutton_prompt_is_regexp = True +copybutton_prompt_text = r">>> |\.\.\. " # doctest +copyright = "2020, RUB EP1" +default_role = "py:obj" +exclude_patterns = [ + "**.ipynb_checkpoints", + "*build", + "tests", ] - extensions = [ "myst_nb", "sphinx.ext.autodoc", @@ -70,52 +75,54 @@ "sphinx.ext.intersphinx", "sphinx.ext.mathjax", "sphinx.ext.napoleon", - "sphinx.ext.viewcode", + "sphinx_api_relink", "sphinx_codeautolink", "sphinx_copybutton", "sphinx_thebe", "sphinx_togglebutton", ] -exclude_patterns = [ - "**.ipynb_checkpoints", - "*build", - "tests", +generate_apidoc_package_path = [ + f"../src/{PACKAGE}", + "../src/boostcfg", ] - -# General sphinx settings -add_module_names = False -autodoc_default_options = { - "members": True, - "undoc-members": True, - "show-inheritance": True, - "special-members": ", ".join([ - "__call__", - "__eq__", - ]), -} -autodoc_member_order = "bysource" -autodoc_typehints_format = "short" -codeautolink_concat_default = True -codeautolink_global_preface = """ -from IPython.display import display - -""" graphviz_output_format = "svg" html_copy_source = True # needed for download notebook button html_last_updated_fmt = "%-d %B %Y" +html_logo = ( + "https://gitlab.ep1.rub.de/uploads/-/system/project/avatar/7/pawian-logo.jpg" +) html_show_copyright = False html_show_sourcelink = False html_show_sphinx = False html_sourcelink_suffix = "" html_theme = "sphinx_book_theme" html_theme_options = { - "repository_url": f"https://github.com/redeboer/{REPO_NAME}", - "repository_branch": "main", + "icon_links": [ + { + "name": "GitHub", + "url": f"https://github.com/{ORGANIZATION}/{REPO_NAME}", + "icon": "fa-brands fa-github", + }, + { + "name": "Launch on Binder", + "url": f"https://mybinder.org/v2/gh/{ORGANIZATION}/{REPO_NAME}/{BRANCH}?filepath=docs", + "icon": "https://mybinder.readthedocs.io/en/latest/_static/favicon.png", + "type": "url", + }, + { + "name": "Launch on Colaboratory", + "url": f"https://colab.research.google.com/github/{ORGANIZATION}/{REPO_NAME}/blob/{BRANCH}", + "icon": "https://avatars.githubusercontent.com/u/33467679?s=100", + "type": "url", + }, + ], + "logo": {"text": REPO_TITLE}, + "repository_url": f"https://github.com/{ORGANIZATION}/{REPO_NAME}", + "repository_branch": BRANCH, "path_to_docs": "docs", "use_download_button": True, "use_edit_page_button": True, "use_issues_button": True, - "use_repository_button": True, "launch_buttons": { "binderhub_url": "https://mybinder.org", "colab_url": "https://colab.research.google.com", @@ -127,108 +134,29 @@ "show_navbar_depth": 2, "show_toc_level": 2, } -html_title = "PawianTools" -pygments_style = "sphinx" -todo_include_todos = False -viewcode_follow_imported_members = True - -# Cross-referencing configuration -default_role = "py:obj" -primary_domain = "py" -nitpicky = True # warn if cross-references are missing -nitpick_ignore = [ - ("py:class", "pandas.core.base.PandasObject"), -] - - -# Intersphinx settings -version_remapping: Dict[str, Dict[str, str]] = { - "ipython": { - "8.12.2": "8.12.1", - "8.12.3": "8.12.1", - }, -} - - -def get_version(package_name: str) -> str: - python_version = f"{sys.version_info.major}.{sys.version_info.minor}" - constraints_path = f"../.constraints/py{python_version}.txt" - package_name = package_name.lower() - with open(constraints_path) as stream: - constraints = stream.read() - for line in constraints.split("\n"): - line = line.split("#")[0] # remove comments - line = line.strip() - line = line.lower() - if not line.startswith(package_name): - continue - if not line: - continue - line_segments = tuple(line.split("==")) - if len(line_segments) != 2: # noqa: PLR2004 - continue - _, installed_version, *_ = line_segments - installed_version = installed_version.strip() - remapped_versions = version_remapping.get(package_name) - if remapped_versions is not None: - existing_version = remapped_versions.get(installed_version) - if existing_version is not None: - return existing_version - return installed_version - return "stable" - - -def get_minor_version(package_name: str) -> str: - installed_version = get_version(package_name) - if installed_version == "stable": - return installed_version - matches = re.match(r"^([0-9]+\.[0-9]+).*$", installed_version) - if matches is None: - msg = f"Could not find documentation for {package_name} v{installed_version}" - raise ValueError(msg) - return matches[1] - - +html_title = REPO_TITLE intersphinx_mapping = { "awkward": ("https://awkward-array.org/doc/stable", None), - "IPython": (f"https://ipython.readthedocs.io/en/{get_version('IPython')}", None), + "IPython": (f"https://ipython.readthedocs.io/en/{pin('IPython')}", None), "compwa-org": ("https://compwa-org.readthedocs.io", None), - "matplotlib": (f"https://matplotlib.org/{get_version('matplotlib')}", None), - "numpy": (f"https://numpy.org/doc/{get_minor_version('numpy')}", None), + "matplotlib": (f"https://matplotlib.org/{pin('matplotlib')}", None), + "numpy": (f"https://numpy.org/doc/{pin_minor('numpy')}", None), "pandas": ( - f"https://pandas.pydata.org/pandas-docs/version/{get_minor_version('pandas')}", + f"https://pandas.pydata.org/pandas-docs/version/{pin_minor('pandas')}", None, ), "python": ("https://docs.python.org/3", None), "uproot": ("https://uproot.readthedocs.io/en/stable", None), } - -# Settings for autosectionlabel -autosectionlabel_prefix_document = True - -# Settings for copybutton -copybutton_prompt_is_regexp = True -copybutton_prompt_text = r">>> |\.\.\. " # doctest - -# Settings for linkcheck linkcheck_anchors = False linkcheck_ignore = [ "https://panda-wiki.gsi.de/bin/view/PWA/PawianPwaSoftware", ] - - -# Settings for myst_nb -def get_nb_execution_mode() -> str: - if "EXECUTE_NB" in os.environ: - print("\033[93;1mWill run Jupyter notebooks!\033[0m") - return "cache" - return "off" - - -nb_execution_mode = get_nb_execution_mode() -nb_execution_timeout = -1 - -# Settings for myst-parser +master_doc = "index" +modindex_common_prefix = [ + "boostcfg.", + f"{PACKAGE}.", +] myst_enable_extensions = [ "amsmath", "colon_fence", @@ -236,29 +164,27 @@ def get_nb_execution_mode() -> str: "smartquotes", "substitution", ] +myst_heading_anchors = 2 myst_update_mathjax = False - -# Settings for Thebe cell output +nb_execution_mode = get_execution_mode() +nb_execution_show_tb = True +nb_execution_timeout = -1 +nb_output_stderr = "remove" +nitpick_ignore = [ + ("py:class", "PandasObject"), +] +nitpicky = True +primary_domain = "py" +project = REPO_TITLE +pygments_style = "sphinx" +release = get_package_version("pawian-tools") +source_suffix = { + ".ipynb": "myst-nb", + ".md": "myst-nb", + ".rst": "restructuredtext", +} thebe_config = { "repository_url": html_theme_options["repository_url"], "repository_branch": html_theme_options["repository_branch"], } - -# -- Visualize dependencies --------------------------------------------------- -if nb_execution_mode != "off": - print("Generating module dependency tree...") - subprocess.call( - " ".join([ - "HOME=.", # in case of calling through tox - "pydeps", - f"../src/{PACKAGE}", - "-o module_structure.svg", - "--exclude *._*", # hide private modules - "--max-bacon=1", # hide external dependencies - "--noshow", - ]), - shell=True, # noqa: S602 - ) - if os.path.exists("module_structure.svg"): - with open(f"api/{PACKAGE}.rst", "a") as stream: - stream.write("\n.. image:: /module_structure.svg") +version = get_package_version("pawian-tools") diff --git a/pyproject.toml b/pyproject.toml index b7e5dbf..16090f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,129 @@ [build-system] +build-backend = "setuptools.build_meta" requires = [ - "setuptools>=36.2.1", # environment markers + "setuptools>=61.2", "setuptools_scm", - "wheel", ] +[project] +authors = [{name = "Common Partial Wave Analysis", email = "compwa-admin@ep1.rub.de"}] +classifiers = [ + "Development Status :: 2 - Pre-Alpha", + "Intended Audience :: Developers", + "Intended Audience :: Education", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python", + "Topic :: Scientific/Engineering :: Physics", + "Topic :: Scientific/Engineering", + "Typing :: Typed", +] +dependencies = [ + "awkward >=1", + "matplotlib", + "numpy", + "pandas", + "uproot >=4", +] +description = "Python helper tools for the Pawian framework" +dynamic = ["version"] +keywords = [ + "HEP", + "PWA", + "amplitude analysis", + "partial wave analysis", + "particle physics", + "particles", + "physics", +] +license = {text = "GPLv3 or later"} +name = "pawian-tools" +requires-python = ">=3.7" + +[project.optional-dependencies] +dev = [ + "pawian-tools[doc]", + "pawian-tools[jupyter]", + "pawian-tools[sty]", + "pawian-tools[test]", + "sphinx-autobuild", + "tox >=1.9", # for skip_install, use_develop +] +doc = [ + "Sphinx >=3", + "ipywidgets", + "myst-nb", + "sphinx-api-relink>=0.0.7", + "sphinx-book-theme", + "sphinx-codeautolink[ipython]", + "sphinx-copybutton", + "sphinx-thebe", + "sphinx-togglebutton", +] +format = [ + "black", +] +jupyter = [ + "isort", + "jupyterlab", + "jupyterlab-code-formatter", + "jupyterlab-git", + "jupyterlab-lsp", + "jupyterlab-myst", + "jupyterlab-myst", + "python-lsp-ruff", + "python-lsp-server[rope]", +] +lint = [ + "pawian-tools[mypy]", + "ruff", +] +"mypy" = [ + "mypy >=0.730", + "sphinx-api-relink", +] +sty = [ + "pawian-tools[format]", + "pawian-tools[lint]", + "pawian-tools[test]", # for pytest type hints + "pre-commit", +] +test = [ + "pytest", + "pytest-cov", + "pytest-profiling", + "pytest-xdist", +] + +[project.readme] +content-type = "text/markdown" +file = "README.md" + +[project.urls] +Changelog = "https://github.com/redeboer/PawianTools/releases" +Documentation = "http://redeboer.github.io/PawianTools" +Source = "https://github.com/redeboer/PawianTools" +Tracker = "https://github.com/redeboer/PawianTools/issues" + +[tool.setuptools] +include-package-data = false +package-dir = {"" = "src"} + +[tool.setuptools.package-data] +pawian = ["samples/*"] + +[tool.setuptools.packages.find] +namespaces = false +where = ["src"] + [tool.setuptools_scm] write_to = "src/pawian/version.py" @@ -28,14 +147,19 @@ target-version = [ "py310", "py311", "py312", - "py36", "py37", "py38", "py39", ] +[tool.coverage.report] +exclude_also = [ + "if TYPE_CHECKING:", +] + [tool.coverage.run] branch = true +omit = ["version.py"] source = ["src"] [tool.mypy] @@ -134,6 +258,7 @@ extend-select = [ "D", "EM", "ERA", + "FA", "I", "ICN", "INP", diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index f6ad18a..0000000 --- a/setup.cfg +++ /dev/null @@ -1,110 +0,0 @@ -[metadata] -name = pawian-tools -description = Python helper tools for the Pawian framework -author = Common Partial Wave Analysis -author_email = compwa-admin@ep1.rub.de -long_description = file: README.md -long_description_content_type = text/markdown -project_urls = - Tracker = https://github.com/redeboer/PawianTools/issues - Changelog = https://github.com/redeboer/PawianTools/releases - Documentation = http://redeboer.github.io/PawianTools - Source = https://github.com/redeboer/PawianTools -license = GPLv3 or later -keywords = - HEP - PWA - amplitude analysis - partial wave analysis - particle physics - particles - physics -classifiers = - Development Status :: 2 - Pre-Alpha - Intended Audience :: Developers - Intended Audience :: Education - Intended Audience :: Science/Research - License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+) - Natural Language :: English - Operating System :: OS Independent - Programming Language :: Python - Programming Language :: Python :: 3.6 - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Programming Language :: Python :: 3.12 - Topic :: Scientific/Engineering - Topic :: Scientific/Engineering :: Physics - Typing :: Typed - -[options] -python_requires = >=3.6 -setup_requires = - setuptools_scm -install_requires = - awkward >=1 - matplotlib - numpy - pandas - uproot >=4 -packages = find: -package_dir = - =src - -[options.packages.find] -where = src - -[options.package_data] -pawian = - samples/* - -[options.extras_require] -doc = - importlib-metadata; python_version <"3.8.0" - ipywidgets - myst-nb - pydeps - Sphinx >=3 - Sphinx <4.4; python_version <"3.8.0" # https://github.com/ComPWA/qrules/runs/4833302679 - sphinx-book-theme - sphinx-codeautolink[ipython] - sphinx-copybutton - sphinx-thebe - sphinx-togglebutton -format = - black -mypy = - mypy >=0.730 # error code support - types-setuptools -lint = - %(mypy)s - ruff; python_version >="3.7.0" -test = - pytest - pytest-cov - pytest-profiling - pytest-xdist -sty = - %(format)s - %(lint)s - %(test)s # for pytest type hints - pre-commit >=2.9.2 # for black -jupyter = - jupyterlab - jupyterlab-code-formatter - jupyterlab-lsp - jupyterlab-myst; python_version >="3.7.0" - python-lsp-server[rope] -dev = - %(doc)s - %(jupyter)s - %(sty)s - %(test)s - sphinx-autobuild - sphinx-autobuild - tox <4; python_version <"3.8.0" # https://github.com/redeboer/PawianTools/actions/runs/3861498991/jobs/6582508970#step:3:91 - tox >=1.9 # for skip_install, use_develop - virtualenv <20.22.0; python_version <"3.8.0" # importlib-metadata conflict - virtualenv!=20.16.*,!=20.17.* # https://github.com/redeboer/PawianTools/actions/runs/4359491077/jobs/7621340858#step:3:76 diff --git a/setup.py b/setup.py deleted file mode 100644 index 9329697..0000000 --- a/setup.py +++ /dev/null @@ -1,6 +0,0 @@ -from setuptools import setup - -setup( - use_scm_version=True, - setup_requires=["setuptools_scm"], -) diff --git a/src/boostcfg/__init__.py b/src/boostcfg/__init__.py index bb2f866..255f98c 100644 --- a/src/boostcfg/__init__.py +++ b/src/boostcfg/__init__.py @@ -9,7 +9,9 @@ `__. """ -from typing import Any, Dict, Optional +from __future__ import annotations + +from typing import Any from . import lineparser @@ -17,9 +19,9 @@ class BoostConfigParser: """Data structure that holds information of Boost config files.""" - def __init__(self, filename: Optional[str] = None) -> None: - self.__values: Dict[str, Any] = {} - self.__config_file: Optional[str] = None + def __init__(self, filename: str | None = None) -> None: + self.__values: dict[str, Any] = {} + self.__config_file: str | None = None if isinstance(filename, str): self.read_config(filename=filename, reset=True) @@ -58,5 +60,5 @@ def __getitem__(self, key: str) -> Any: return self.__values[key] @property - def config_file(self) -> Optional[str]: + def config_file(self) -> str | None: return self.__config_file diff --git a/src/boostcfg/lineparser.py b/src/boostcfg/lineparser.py index 2676b99..31a8681 100644 --- a/src/boostcfg/lineparser.py +++ b/src/boostcfg/lineparser.py @@ -1,5 +1,7 @@ """A collection of tools to parse lines in a Boost config file.""" +from __future__ import annotations + __all__ = [ "get_key_value_pair", "is_commented", @@ -10,10 +12,9 @@ import re -from typing import Tuple, Union # regex -def get_key_value_pair(line: str) -> Tuple[str, str]: +def get_key_value_pair(line: str) -> tuple[str, str]: """Extract key and value from a line in a :code:`cfg` file. Extracts everything before an equal sign as the key, and everything after as the @@ -46,7 +47,7 @@ def strip_comment(line: str) -> str: return matches[0] -def string_to_value(string: str) -> Union[bool, float, int, str]: +def string_to_value(string: str) -> bool | float | int | str: """Attempt to convert a string to a `float` or `int`.""" try: return int(string) diff --git a/src/pawian/data.py b/src/pawian/data.py index c6a0721..7fda85b 100644 --- a/src/pawian/data.py +++ b/src/pawian/data.py @@ -1,5 +1,3 @@ -# cspell:ignore astype dropna - """Data module of PawianTools. This module allows you to parse and analyze ASCII data files of momentum @@ -24,17 +22,20 @@ `~pandas.DataFrame` accessors. """ +from __future__ import annotations import sys -from typing import Any, Iterable, List, Optional, Union +from typing import TYPE_CHECKING, Any, Iterable import awkward as ak import numpy as np import pandas as pd import uproot -from pandas.core.base import PandasObject from uproot.exceptions import KeyInFileError +if TYPE_CHECKING: + from pandas.core.base import PandasObject + if sys.version_info < (3, 8): from typing_extensions import Literal else: @@ -106,7 +107,7 @@ def intensities(self) -> pd.Series: return self.weights @property - def particles(self) -> List[str]: + def particles(self) -> list[str]: """Get list of particles contained in the data frame.""" if not self.has_particles: msg = "This dataframe is single-level and does not contain particles" @@ -117,7 +118,7 @@ def particles(self) -> List[str]: return particles.to_list() @property - def momentum_labels(self) -> List[str]: + def momentum_labels(self) -> list[str]: """Get list of momentum labels contained in the data frame.""" momentum_labels = self._obj.columns.droplevel(0).unique() if self.has_weights: @@ -172,6 +173,7 @@ def write_ascii(self, filename: str, **kwargs: Any) -> None: if self.has_weights: new_dict.append(self._obj[_WEIGHT_LABEL]) for par in self.particles: + # cspell:ignore astype dropna new_dict.append( self._obj[par].apply( lambda x: " ".join(x.dropna().astype(str)), @@ -184,7 +186,7 @@ def write_ascii(self, filename: str, **kwargs: Any) -> None: def create_skeleton_frame( - particle_names: Optional[Iterable[str]] = None, number_of_rows: Optional[int] = None + particle_names: Iterable[str] | None = None, number_of_rows: int | None = None ) -> pd.DataFrame: """Create skeleton `~pandas.DataFrame`. @@ -205,7 +207,7 @@ def create_skeleton_frame( def read_ascii( # noqa: C901 filename: str, - particles: Optional[Union[List[str], int]] = None, + particles: list[str] | int | None = None, **kwargs: Any, ) -> pd.DataFrame: """Import from a Pawian-like ASCII file. diff --git a/src/pawian/qa.py b/src/pawian/qa.py index 31964cc..60d2b72 100644 --- a/src/pawian/qa.py +++ b/src/pawian/qa.py @@ -4,27 +4,29 @@ module contains handlers for such files. """ +from __future__ import annotations + import logging import re # regex from math import ceil, sqrt -from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union +from typing import TYPE_CHECKING, Any import matplotlib.pyplot as plt -import numpy as np -import pandas as pd import uproot -from matplotlib.axes import Axes -from matplotlib.container import BarContainer -from matplotlib.figure import Figure from uproot.behaviors.TH1 import TH1 -from uproot.behaviors.TH2 import TH2 -from uproot.behaviors.TH3 import TH3 from pawian.data import read_pawian_hists from pawian.latex import convert if TYPE_CHECKING: + import numpy as np + import pandas as pd + from matplotlib.axes import Axes + from matplotlib.container import BarContainer + from matplotlib.figure import Figure from uproot.behaviors.TAxis import TAxis + from uproot.behaviors.TH2 import TH2 + from uproot.behaviors.TH3 import TH3 from uproot.reading import ReadOnlyDirectory @@ -44,7 +46,7 @@ def import_file(self, filename: str) -> None: self.__data = read_pawian_hists(filename, type_name="data") self.__fit = read_pawian_hists(filename, type_name="fitted") - def get_uproot_histogram(self, name: str) -> Optional[Union[TH1, TH2, TH3]]: + def get_uproot_histogram(self, name: str) -> TH1 | TH2 | TH3 | None: """Get a histogram from a :file:`pawianHists.root` file. Get an `uproot` histogram from the :file:`pawianHists.root` file. @@ -57,7 +59,7 @@ def get_uproot_histogram(self, name: str) -> Optional[Union[TH1, TH2, TH3]]: return obj return None - def get_histogram_content(self, name: str) -> Optional[Tuple[list, list]]: + def get_histogram_content(self, name: str) -> tuple[list, list] | None: """Get an array of lower edges and an array of values for the histogram. You can then for instance use `matplotlib.pyplot.hist` to plot it like @@ -81,8 +83,8 @@ def get_histogram_content(self, name: str) -> Optional[Tuple[list, list]]: return edges, values def draw_histogram( - self, name: str, plot_on: Optional[Axes] = None, **kwargs: Any - ) -> Tuple[np.ndarray, np.ndarray, BarContainer]: + self, name: str, plot_on: Axes | None = None, **kwargs: Any + ) -> tuple[np.ndarray, np.ndarray, BarContainer]: """Plot a histogram in a matplotlib figure. Args: @@ -108,12 +110,12 @@ def draw_histogram( def draw_combined_histogram( # noqa: PLR0913 self, name: str, - plot_on: Optional[Axes] = None, + plot_on: Axes | None = None, data: bool = True, fit: bool = True, mc: bool = True, **kwargs: Any, - ) -> Dict[str, Tuple[np.ndarray, np.ndarray, BarContainer]]: + ) -> dict[str, tuple[np.ndarray, np.ndarray, BarContainer]]: """Combine the three types of histograms in one plot. Args: @@ -154,7 +156,7 @@ def draw_combined_histogram( # noqa: PLR0913 return hists def draw_all_histograms( - self, plot_on: Optional[Figure] = None, legend: bool = True, **kwargs: Any + self, plot_on: Figure | None = None, legend: bool = True, **kwargs: Any ) -> None: """Draw a comparative overview of all histograms. @@ -177,7 +179,7 @@ def draw_all_histograms( sub.legend() @property - def histogram_names(self) -> List[str]: + def histogram_names(self) -> list[str]: """Get a list of all histogram names in a :file:`pawianHists.root` file.""" names = [] for name in self.__file: @@ -187,7 +189,7 @@ def histogram_names(self) -> List[str]: return names @property - def unique_histogram_names(self) -> List[str]: + def unique_histogram_names(self) -> list[str]: """Get a list of unique histograms from a :file:`pawianHists.root` file. Get a list of histograms in the :file:`pawianHists.root` file of which the @@ -204,7 +206,7 @@ def unique_histogram_names(self) -> List[str]: return names @property - def particles(self) -> List[str]: + def particles(self) -> list[str]: """Get particle names contained in the file.""" return self.data.pwa.particles diff --git a/tox.ini b/tox.ini index 81fb37e..e795088 100644 --- a/tox.ini +++ b/tox.ini @@ -19,8 +19,8 @@ description = allowlist_externals = pytest commands = - pytest {posargs:tests/unit} \ - --cov-fail-under=90 \ + pytest {posargs:tests} \ + --cov-fail-under=85 \ --cov-report=html \ --cov-report=xml \ --cov=boostcfg \ @@ -74,6 +74,25 @@ setenv = EXECUTE_NB = yes FORCE_COLOR = yes +[testenv:docnblive] +allowlist_externals = + sphinx-autobuild +commands = + sphinx-autobuild \ + --watch docs \ + --watch src \ + --re-ignore docs/.*\.inv \ + --re-ignore docs/_build/.* \ + --re-ignore docs/api/.* \ + --open-browser \ + docs/ docs/_build/html +description = + Set up a server to preview changes to the HTML pages live +passenv = * +setenv = + EXECUTE_NB = yes + FORCE_COLOR = yes + [testenv:linkcheck] allowlist_externals = sphinx-build