From 9fea458eb197f81dc0e0f74f88c9f86bbed32dd6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 4 Jul 2023 08:02:49 +0000 Subject: [PATCH 01/47] MAINT: update pip constraints and pre-commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/ComPWA/repo-maintenance: 0.0.182 → 0.0.184](https://github.com/ComPWA/repo-maintenance/compare/0.0.182...0.0.184) - [github.com/ComPWA/mirrors-pyright: v1.1.315 → v1.1.316](https://github.com/ComPWA/mirrors-pyright/compare/v1.1.315...v1.1.316) - [github.com/asottile/pyupgrade: v3.7.0 → v3.8.0](https://github.com/asottile/pyupgrade/compare/v3.7.0...v3.8.0) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 03a4f4e2..f02bf2ae 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -38,7 +38,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/ComPWA/repo-maintenance - rev: 0.0.182 + rev: 0.0.184 hooks: - id: check-dev-files args: @@ -169,12 +169,12 @@ repos: - python - 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: From 2a7836e3dd7135500d2a3f97ee0ba25a6c6a0e5c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 4 Jul 2023 08:05:53 +0000 Subject: [PATCH 02/47] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .cspell.json | 3 - .flake8 | 60 ----- .gitpod.yml | 5 +- .mypy.ini | 33 --- .pre-commit-config.yaml | 45 +--- .pydocstyle | 11 - .pylintrc | 42 ---- .vscode/extensions.json | 12 +- .vscode/settings.json | 9 +- README.md | 2 +- docs/.pydocstyle | 4 - docs/_relink_references.py | 3 +- docs/conf.py | 14 +- docs/usage.ipynb | 2 - docs/usage/conservation.ipynb | 12 +- docs/usage/custom-topology.ipynb | 2 - docs/usage/ls-coupling.ipynb | 2 - docs/usage/particle.ipynb | 2 - docs/usage/reaction.ipynb | 2 - docs/usage/visualize.ipynb | 2 - pyproject.toml | 206 +++++++++++++++++- pyrightconfig.json | 34 --- pytest.ini | 24 -- src/qrules/__init__.py | 47 ++-- src/qrules/_system_control.py | 11 +- src/qrules/argument_handling.py | 23 +- src/qrules/combinatorics.py | 18 +- src/qrules/io/_dot.py | 3 +- src/qrules/particle.py | 15 +- src/qrules/settings.py | 50 ++--- src/qrules/solving.py | 34 +-- src/qrules/topology.py | 25 +-- src/qrules/transition.py | 90 ++------ tests/.pydocstyle | 4 - .../unit/conservation_rules/test_c_parity.py | 7 +- .../conservation_rules/test_clebsch_gordan.py | 12 +- .../conservation_rules/test_duck_typing.py | 7 +- .../unit/conservation_rules/test_g_parity.py | 7 +- .../test_gellmann_nishijima.py | 3 +- .../test_identical_particle_symmetrization.py | 6 +- .../test_parity_conservation.py | 8 +- tests/unit/conservation_rules/test_spin.py | 9 +- tests/unit/io/test_dot.py | 11 +- tests/unit/io/test_io.py | 8 +- tests/unit/test_combinatorics.py | 13 +- tests/unit/test_particle.py | 12 +- tests/unit/test_settings.py | 9 +- tests/unit/test_system_control.py | 23 +- tests/unit/test_topology.py | 16 +- tests/unit/test_transition.py | 12 +- 50 files changed, 372 insertions(+), 642 deletions(-) delete mode 100644 .flake8 delete mode 100644 .mypy.ini delete mode 100644 .pydocstyle delete mode 100644 .pylintrc delete mode 100644 docs/.pydocstyle delete mode 100644 pyrightconfig.json delete mode 100644 pytest.ini delete mode 100644 tests/.pydocstyle diff --git a/.cspell.json b/.cspell.json index cc153308..49c7238b 100644 --- a/.cspell.json +++ b/.cspell.json @@ -24,14 +24,11 @@ "*particle*.*ml", ".constraints/*.txt", ".editorconfig", - ".flake8*", ".gitignore", ".gitpod.*", ".mypy.ini", ".pre-commit-config.yaml", ".prettierignore", - ".pydocstyle*", - ".pylintrc", ".readthedocs.yml", ".vscode/*", ".vscode/.gitignore", diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 40c0eed9..00000000 --- a/.flake8 +++ /dev/null @@ -1,60 +0,0 @@ -[flake8] -application-import-names = - qrules -filename = - ./docs/*.py - ./src/*.py - ./tests/*.py -exclude = - **/__pycache__ - **/_build - /typings/** -ignore = - # False positive with attribute docstrings - B018 - # https://github.com/psf/black#slices - E203 - # allowed by black - E231 - # already covered by black - E302 - # https://github.com/psf/black#line-length - E501 - # avoid any from __future__ import annotations, in combination with FI58 - FI - # 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 -extend-select = - FI58 - TI100 -per-file-ignores = - # casts with generics - src/qrules/topology.py:E731 -rst-roles = - attr - cite - class - doc - download - file - func - meth - mod - ref -rst-directives = - autolink-preface - automethod - deprecated - envvar - exception - seealso diff --git a/.gitpod.yml b/.gitpod.yml index df3bc09b..91999103 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -13,18 +13,17 @@ github: vscode: extensions: + - charliermarsh.ruff - christian-kohler.path-intellisense - davidanson.vscode-markdownlint - eamodio.gitlens - editorconfig.editorconfig - esbenp.prettier-vscode - executablebookproject.myst-highlight + - garaioag.garaio-vscode-unwanted-recommendations - github.vscode-github-actions - github.vscode-pull-request-github - joaompinto.vscode-graphviz - - ms-python.flake8 - - ms-python.isort - - ms-python.pylint - ms-python.python - ms-python.vscode-pylance - ms-vscode.live-server diff --git a/.mypy.ini b/.mypy.ini deleted file mode 100644 index 4b8aa2fa..00000000 --- a/.mypy.ini +++ /dev/null @@ -1,33 +0,0 @@ -[mypy] -disallow_incomplete_defs = True -disallow_untyped_defs = True -exclude = _build -show_error_codes = True -warn_unused_configs = True - -[mypy-tests.*] -check_untyped_defs = True -disallow_incomplete_defs = False -disallow_untyped_defs = False -[mypy-typings.*] -ignore_errors = True - -; External packages that miss stubs or type hints -[mypy-IPython.*] -ignore_missing_imports = True -[mypy-constraint.*] -ignore_missing_imports = True -[mypy-jsonschema.*] -ignore_missing_imports = True -[mypy-particle.*] -ignore_missing_imports = True -[mypy-pybtex.*] -ignore_missing_imports = True -[mypy-pydot.*] -ignore_missing_imports = True -[mypy-sphinx.*] -ignore_missing_imports = True -[mypy-sphobjinv.*] -ignore_missing_imports = True -[mypy-tqdm.*] -ignore_missing_imports = True diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f02bf2ae..993c2938 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -60,12 +60,14 @@ repos: - id: nbqa-black additional_dependencies: - black>=22.1.0 - - id: nbqa-flake8 - - id: nbqa-isort - id: nbqa-pyupgrade args: - --py36-plus + - id: nbqa-ruff + args: + - --fix + - repo: https://github.com/psf/black rev: 23.3.0 hooks: @@ -92,20 +94,6 @@ repos: .*\.py )$ - - repo: local - hooks: - - id: flake8 - name: flake8 - entry: flake8 - language: system - types: - - python - - - repo: https://github.com/pycqa/isort - rev: 5.12.0 - hooks: - - id: isort - - repo: https://github.com/igorshubovych/markdownlint-cli rev: v0.35.0 hooks: @@ -150,24 +138,6 @@ repos: hooks: - id: prettier - - repo: https://github.com/pycqa/pydocstyle - rev: 6.3.0 - hooks: - - id: pydocstyle - - - repo: local - hooks: - - id: pylint - name: pylint - entry: pylint - args: - - --rcfile=.pylintrc - - --score=no - language: system - require_serial: true - types: - - python - - repo: https://github.com/ComPWA/mirrors-pyright rev: v1.1.316 hooks: @@ -180,6 +150,13 @@ repos: args: - --py36-plus + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: "" + hooks: + - id: ruff + args: + - --fix + - repo: https://github.com/ComPWA/mirrors-taplo rev: v0.8.0 hooks: diff --git a/.pydocstyle b/.pydocstyle deleted file mode 100644 index 3f5277ab..00000000 --- a/.pydocstyle +++ /dev/null @@ -1,11 +0,0 @@ -[pydocstyle] -convention = google -add_ignore = - D101, # class docstring - D102, # method docstring - D103, # function docstring - D105, # magic method docstring - D107, # init docstring - D203, # conflicts with D211 - D213, # multi-line docstring should start at the second line - D407, # missing dashed underline after section diff --git a/.pylintrc b/.pylintrc deleted file mode 100644 index a0925a9e..00000000 --- a/.pylintrc +++ /dev/null @@ -1,42 +0,0 @@ -# To see other available options: -# pylint --generate-rcfile > .pylintrc_new -# and compare the output - -[BASIC] -good-names-rgxs= - ^[p]$, - -[MASTER] -ignore= - conf.py, -ignore-patterns= - .*\.pyi - -[MESSAGES CONTROL] -disable= - abstract-class-instantiated, # doesn't work well with Generic - duplicate-code, # https://github.com/PyCQA/pylint/issues/214 - invalid-unary-operand-type, # conflicts with attrs.field - line-too-long, # automatically fixed with black - logging-fstring-interpolation, - missing-class-docstring, # pydocstyle - missing-function-docstring, # pydocstyle - missing-module-docstring, # pydocstyle - no-member, # conflicts with attrs.field - no-name-in-module, # already checked by mypy - not-a-mapping, # conflicts with attrs.field - not-an-iterable, # conflicts with attrs.field - not-callable, # conflicts with attrs.field - redefined-builtin, # flake8-built - too-few-public-methods, # data containers (attrs) and interface classes - unspecified-encoding, # http://pylint.pycqa.org/en/latest/whatsnew/2.10.html - unsubscriptable-object, # conflicts with attrs.field - unsupported-assignment-operation, # conflicts with attrs.field - unsupported-membership-test, # conflicts with attrs.field - unused-import, # https://www.flake8rules.com/rules/F401 - -[SIMILARITIES] -ignore-imports=yes # https://stackoverflow.com/a/30007053 - -[VARIABLES] -init-import=yes diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 730e5a07..b00915fb 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,17 +1,16 @@ { "recommendations": [ + "charliermarsh.ruff", "christian-kohler.path-intellisense", "davidanson.vscode-markdownlint", "eamodio.gitlens", "editorconfig.editorconfig", "esbenp.prettier-vscode", "executablebookproject.myst-highlight", + "garaioag.garaio-vscode-unwanted-recommendations", "github.vscode-github-actions", "github.vscode-pull-request-github", "joaompinto.vscode-graphviz", - "ms-python.flake8", - "ms-python.isort", - "ms-python.pylint", "ms-python.python", "ms-python.vscode-pylance", "ms-vscode.live-server", @@ -23,5 +22,12 @@ "tamasfe.even-better-toml", "tyriar.sort-lines", "yzhang.markdown-all-in-one" + ], + "unwantedRecommendations": [ + "bungcip.better-toml", + "ms-python.flake8", + "ms-python.isort", + "ms-python.pylint", + "travisillig.vscode-json-stable-stringify" ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 9c9f4668..f25cc168 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -36,11 +36,8 @@ "**/.git/**": true, "**/.tox/**": true }, - "flake8.importStrategy": "fromEnvironment", "git.rebaseWhenSync": true, "github-actions.workflows.pinned.workflows": [".github/workflows/ci.yml"], - "isort.check": true, - "isort.importStrategy": "fromEnvironment", "json.schemas": [ { "fileMatch": ["*particle*.json"], @@ -52,9 +49,7 @@ } ], "livePreview.defaultPreviewPath": "docs/_build/html", - "pylint.importStrategy": "fromEnvironment", "python.analysis.autoImportCompletions": false, - "python.analysis.diagnosticMode": "workspace", "python.analysis.inlayHints.pytestParameters": true, "python.analysis.typeCheckingMode": "strict", "python.formatting.provider": "black", @@ -62,13 +57,15 @@ "python.linting.enabled": true, "python.linting.flake8Enabled": false, "python.linting.mypyEnabled": true, - "python.linting.pydocstyleEnabled": true, + "python.linting.pydocstyleEnabled": false, "python.linting.pylamaEnabled": false, "python.linting.pylintEnabled": false, "python.testing.pytestArgs": ["--color=no", "--no-cov"], "python.testing.pytestEnabled": true, "python.testing.unittestEnabled": false, "rewrap.wrappingColumn": 88, + "ruff.enable": true, + "ruff.organizeImports": true, "search.exclude": { "**/tests/**/__init__.py": true, "*/.pydocstyle": true, diff --git a/README.md b/README.md index 6fbb3959..e58790d9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Quantum Number Conservation Rules +[![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.5526360](https://zenodo.org/badge/doi/10.5281/zenodo.5526360.svg)](https://doi.org/10.5281/zenodo.5526360) [![GPLv3+ license](https://img.shields.io/badge/License-GPLv3+-blue.svg)](https://www.gnu.org/licenses/gpl-3.0-standalone.html) @@ -21,7 +22,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) QRules is a Python package for **validating and generating particle reactions** using quantum number conservation rules. The user only has to provide a certain set of diff --git a/docs/.pydocstyle b/docs/.pydocstyle deleted file mode 100644 index 26d0703b..00000000 --- a/docs/.pydocstyle +++ /dev/null @@ -1,4 +0,0 @@ -; ignore all pydocstyle errors in this folder - -[pydocstyle] -add_ignore = D diff --git a/docs/_relink_references.py b/docs/_relink_references.py index fc7c1daa..cc9c087c 100644 --- a/docs/_relink_references.py +++ b/docs/_relink_references.py @@ -66,7 +66,8 @@ def _new_type_to_xref( if sphinx.version_info >= (4, 4): # https://github.com/sphinx-doc/sphinx/blob/v4.4.0/sphinx/domains/python.py#L110-L133 - from sphinx.domains.python import parse_reftarget # type: ignore[attr-defined] + from sphinx.domains.python import \ + parse_reftarget # type: ignore[attr-defined] reftype, target, title, refspecific = parse_reftarget(target, suppress_prefix) target = __TARGET_SUBSTITUTIONS.get(target, target) diff --git a/docs/conf.py b/docs/conf.py index a690049f..a56b66b8 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -12,24 +12,14 @@ from typing import Dict import requests - # pyright: reportMissingImports=false import sphobjinv as soi from pybtex.database import Entry 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 ( - FieldIsMissing, - Node, - _format_list, - field, - href, - join, - node, - sentence, - words, -) +from pybtex.style.template import (FieldIsMissing, Node, _format_list, field, + href, join, node, sentence, words) if sys.version_info < (3, 8): from importlib_metadata import PackageNotFoundError diff --git a/docs/usage.ipynb b/docs/usage.ipynb index 207a75a3..ff9f0a8b 100644 --- a/docs/usage.ipynb +++ b/docs/usage.ipynb @@ -46,8 +46,6 @@ "%config InlineBackend.figure_formats = ['svg']\n", "import os\n", "\n", - "from IPython.display import display # noqa: F401\n", - "\n", "STATIC_WEB_PAGE = {\"EXECUTE_NB\", \"READTHEDOCS\"}.intersection(os.environ)" ] }, diff --git a/docs/usage/conservation.ipynb b/docs/usage/conservation.ipynb index d30d9898..8938232b 100644 --- a/docs/usage/conservation.ipynb +++ b/docs/usage/conservation.ipynb @@ -46,8 +46,6 @@ "%config InlineBackend.figure_formats = ['svg']\n", "import os\n", "\n", - "from IPython.display import display # noqa: F401\n", - "\n", "STATIC_WEB_PAGE = {\"EXECUTE_NB\", \"READTHEDOCS\"}.intersection(os.environ)" ] }, @@ -83,13 +81,9 @@ "import graphviz\n", "\n", "import qrules\n", - "from qrules.conservation_rules import (\n", - " SpinEdgeInput,\n", - " SpinNodeInput,\n", - " parity_conservation,\n", - " spin_conservation,\n", - " spin_magnitude_conservation,\n", - ")\n", + "from qrules.conservation_rules import (SpinEdgeInput, SpinNodeInput,\n", + " parity_conservation, spin_conservation,\n", + " spin_magnitude_conservation)\n", "from qrules.quantum_numbers import Parity" ] }, diff --git a/docs/usage/custom-topology.ipynb b/docs/usage/custom-topology.ipynb index be98818a..fcaaa305 100644 --- a/docs/usage/custom-topology.ipynb +++ b/docs/usage/custom-topology.ipynb @@ -46,8 +46,6 @@ "%config InlineBackend.figure_formats = ['svg']\n", "import os\n", "\n", - "from IPython.display import display # noqa: F401\n", - "\n", "STATIC_WEB_PAGE = {\"EXECUTE_NB\", \"READTHEDOCS\"}.intersection(os.environ)" ] }, diff --git a/docs/usage/ls-coupling.ipynb b/docs/usage/ls-coupling.ipynb index 3fe6773e..38b860e7 100644 --- a/docs/usage/ls-coupling.ipynb +++ b/docs/usage/ls-coupling.ipynb @@ -46,8 +46,6 @@ "%config InlineBackend.figure_formats = ['svg']\n", "import os\n", "\n", - "from IPython.display import display # noqa: F401\n", - "\n", "STATIC_WEB_PAGE = {\"EXECUTE_NB\", \"READTHEDOCS\"}.intersection(os.environ)" ] }, diff --git a/docs/usage/particle.ipynb b/docs/usage/particle.ipynb index 8933b02c..1eb2bad4 100644 --- a/docs/usage/particle.ipynb +++ b/docs/usage/particle.ipynb @@ -46,8 +46,6 @@ "%config InlineBackend.figure_formats = ['svg']\n", "import os\n", "\n", - "from IPython.display import display # noqa: F401\n", - "\n", "STATIC_WEB_PAGE = {\"EXECUTE_NB\", \"READTHEDOCS\"}.intersection(os.environ)" ] }, diff --git a/docs/usage/reaction.ipynb b/docs/usage/reaction.ipynb index 73373ba1..0f6d5cbf 100644 --- a/docs/usage/reaction.ipynb +++ b/docs/usage/reaction.ipynb @@ -46,8 +46,6 @@ "%config InlineBackend.figure_formats = ['svg']\n", "import os\n", "\n", - "from IPython.display import display # noqa: F401\n", - "\n", "STATIC_WEB_PAGE = {\"EXECUTE_NB\", \"READTHEDOCS\"}.intersection(os.environ)" ] }, diff --git a/docs/usage/visualize.ipynb b/docs/usage/visualize.ipynb index dd43ceb6..b57bb1a3 100644 --- a/docs/usage/visualize.ipynb +++ b/docs/usage/visualize.ipynb @@ -46,8 +46,6 @@ "%config InlineBackend.figure_formats = ['svg']\n", "import os\n", "\n", - "from IPython.display import display # noqa: F401\n", - "\n", "STATIC_WEB_PAGE = {\"EXECUTE_NB\", \"READTHEDOCS\"}.intersection(os.environ)" ] }, diff --git a/pyproject.toml b/pyproject.toml index c4ad057f..b6ff3287 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,18 +33,206 @@ target-version = [ "py39", ] -[tool.isort] -known_third_party = "THIRDPARTY,particle" -profile = "black" -src_paths = [ +[tool.nbqa.addopts] +black = [ + "--line-length=85", +] +ruff = [ + "--extend-ignore=B018", + "--extend-ignore=C90", + "--extend-ignore=D", + "--extend-ignore=N806", + "--extend-ignore=N816", + "--extend-ignore=PLR09", + "--extend-ignore=PLR2004", + "--extend-ignore=PLW0602", + "--extend-ignore=PLW0603", + "--line-length=85", +] + +[tool.mypy] +disallow_incomplete_defs = true +disallow_untyped_defs = true +exclude = "_build" +show_error_codes = true +warn_unused_configs = true + +[[tool.mypy.overrides]] +module = ["tests.*"] +check_untyped_defs = true +disallow_incomplete_defs = false +disallow_untyped_defs = false + +[[tool.mypy.overrides]] +module = ["typings.*"] +ignore_errors = true + +[[tool.mypy.overrides]] +module = ["IPython.*"] +ignore_missing_imports = true + +[[tool.mypy.overrides]] +module = ["constraint.*"] +ignore_missing_imports = true + +[[tool.mypy.overrides]] +module = ["jsonschema.*"] +ignore_missing_imports = true + +[[tool.mypy.overrides]] +module = ["particle.*"] +ignore_missing_imports = true + +[[tool.mypy.overrides]] +module = ["pybtex.*"] +ignore_missing_imports = true + +[[tool.mypy.overrides]] +module = ["pydot.*"] +ignore_missing_imports = true + +[[tool.mypy.overrides]] +module = ["sphinx.*"] +ignore_missing_imports = true + +[[tool.mypy.overrides]] +module = ["sphobjinv.*"] +ignore_missing_imports = true + +[[tool.mypy.overrides]] +module = ["tqdm.*"] +ignore_missing_imports = true + +[tool.pyright] +exclude = [ + "**/.git", + "**/.ipynb_checkpoints", + "**/.mypy_cache", + "**/.pytest_cache", + "**/.tox", + "**/__pycache__", + "**/_build", +] +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.coverage.run] +branch = true +source = ["src"] + +[tool.pytest.ini_options] +addopts = """ +--color=yes +--doctest-continue-on-failure +--doctest-modules +--durations=3 +--ignore=docs/abbreviate_signature.py +--ignore=docs/conf.py""" +filterwarnings = [ + "error", + "ignore:Passing a schema to Validator.iter_errors is deprecated.*:DeprecationWarning", + "ignore:unclosed .*:ResourceWarning", +] +norecursedirs = ["_build"] +markers = ["slow: marks tests as slow (deselect with '-m \"not slow\"')"] +testpaths = [ + "docs", "src", "tests", ] -[tool.nbqa.addopts] -black = [ - "--line-length=85", +[tool.ruff] +extend-select = [ + "A", + "B", + "BLE", + "C4", + "C90", + "D", + "EM", + "ERA", + "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"] +src = [ + "src", + "tests", +] +extend-exclude = ["typings"] + +[tool.ruff.per-file-ignores] +"docs/*" = [ + "E402", + "INP001", + "S101", + "S113", + "T201", ] -flake8 = [ - "--extend-ignore=E402,F821", +"setup.py" = ["D100"] +"tests/*" = [ + "D", + "INP001", + "PGH001", + "PLR0913", + "PLR2004", + "S101", ] + +[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 8dd25843..00000000 --- a/pytest.ini +++ /dev/null @@ -1,24 +0,0 @@ -[coverage:run] -branch = True -source = src - -[pytest] -addopts = - --color=yes - --doctest-continue-on-failure - --doctest-modules - --durations=3 - --ignore=docs/abbreviate_signature.py - --ignore=docs/conf.py -filterwarnings = - error - ignore:Passing a schema to Validator.iter_errors is deprecated.*:DeprecationWarning - ignore:unclosed .*:ResourceWarning -norecursedirs = - _build -markers = - slow: marks tests as slow (deselect with '-m "not slow"') -testpaths = - docs - src - tests diff --git a/src/qrules/__init__.py b/src/qrules/__init__.py index a28b15d6..fe242055 100644 --- a/src/qrules/__init__.py +++ b/src/qrules/__init__.py @@ -17,44 +17,33 @@ """ from itertools import product -from typing import Dict, FrozenSet, Iterable, List, Optional, Sequence, Set, Union +from typing import (Dict, FrozenSet, Iterable, List, Optional, Sequence, Set, + Union) import attrs from . import io from .combinatorics import InitialFacts, StateDefinition, create_initial_facts -from .conservation_rules import ( - BaryonNumberConservation, - BottomnessConservation, - ChargeConservation, - CharmConservation, - ElectronLNConservation, - GraphElementRule, - MassConservation, - MuonLNConservation, - StrangenessConservation, - TauLNConservation, - c_parity_conservation, - clebsch_gordan_helicity_to_canonical, - g_parity_conservation, - gellmann_nishijima, - identical_particle_symmetrization, - isospin_conservation, - isospin_validity, - parity_conservation, - spin_magnitude_conservation, -) +from .conservation_rules import (BaryonNumberConservation, + BottomnessConservation, ChargeConservation, + CharmConservation, ElectronLNConservation, + GraphElementRule, MassConservation, + MuonLNConservation, StrangenessConservation, + TauLNConservation, c_parity_conservation, + clebsch_gordan_helicity_to_canonical, + g_parity_conservation, gellmann_nishijima, + identical_particle_symmetrization, + isospin_conservation, isospin_validity, + parity_conservation, + spin_magnitude_conservation) from .particle import ParticleCollection, load_pdg from .quantum_numbers import InteractionProperties -from .settings import ( - ADDITIONAL_PARTICLES_DEFINITIONS_PATH, - InteractionType, - _halves_domain, - _int_domain, -) +from .settings import (ADDITIONAL_PARTICLES_DEFINITIONS_PATH, InteractionType, + _halves_domain, _int_domain) from .solving import NodeSettings, QNResult, Rule, validate_full_solution from .topology import MutableTransition, create_n_body_topology -from .transition import EdgeSettings, ProblemSet, ReactionInfo, StateTransitionManager +from .transition import (EdgeSettings, ProblemSet, ReactionInfo, + StateTransitionManager) def check_reaction_violations( # pylint: disable=too-many-arguments diff --git a/src/qrules/_system_control.py b/src/qrules/_system_control.py index 18d49593..49b876ee 100644 --- a/src/qrules/_system_control.py +++ b/src/qrules/_system_control.py @@ -7,14 +7,9 @@ import attrs from .particle import Particle, ParticleCollection, ParticleWithSpin -from .quantum_numbers import ( - EdgeQuantumNumber, - EdgeQuantumNumbers, - InteractionProperties, - NodeQuantumNumber, - NodeQuantumNumbers, - Parity, -) +from .quantum_numbers import (EdgeQuantumNumber, EdgeQuantumNumbers, + InteractionProperties, NodeQuantumNumber, + NodeQuantumNumbers, Parity) from .settings import InteractionType from .solving import GraphEdgePropertyMap, GraphNodePropertyMap, GraphSettings from .topology import MutableTransition diff --git a/src/qrules/argument_handling.py b/src/qrules/argument_handling.py index fa99408d..c1b253aa 100644 --- a/src/qrules/argument_handling.py +++ b/src/qrules/argument_handling.py @@ -6,28 +6,13 @@ """ import inspect -from typing import ( - Any, - Callable, - Dict, - Generic, - List, - Optional, - Sequence, - Set, - Tuple, - Type, - TypeVar, - Union, -) +from typing import (Any, Callable, Dict, Generic, List, Optional, Sequence, + Set, Tuple, Type, TypeVar, Union) import attrs -from .conservation_rules import ( - ConservationRule, - EdgeQNConservationRule, - GraphElementRule, -) +from .conservation_rules import (ConservationRule, EdgeQNConservationRule, + GraphElementRule) from .quantum_numbers import EdgeQuantumNumber, NodeQuantumNumber, Parity Scalar = Union[int, float] diff --git a/src/qrules/combinatorics.py b/src/qrules/combinatorics.py index 261a6541..fe6dd116 100644 --- a/src/qrules/combinatorics.py +++ b/src/qrules/combinatorics.py @@ -9,23 +9,13 @@ import sys from collections import OrderedDict from copy import deepcopy -from typing import ( - Any, - Callable, - Dict, - Iterable, - List, - Mapping, - Optional, - Sequence, - Set, - Tuple, - Union, -) +from typing import (Any, Callable, Dict, Iterable, List, Mapping, Optional, + Sequence, Set, Tuple, Union) from qrules.particle import ParticleCollection, ParticleWithSpin from qrules.quantum_numbers import InteractionProperties, arange -from qrules.topology import MutableTransition, Topology, get_originating_node_list +from qrules.topology import (MutableTransition, Topology, + get_originating_node_list) if sys.version_info >= (3, 10): from typing import TypeAlias diff --git a/src/qrules/io/_dot.py b/src/qrules/io/_dot.py index 645af5e2..033d56ae 100644 --- a/src/qrules/io/_dot.py +++ b/src/qrules/io/_dot.py @@ -18,7 +18,8 @@ from qrules.particle import Particle, ParticleWithSpin, Spin from qrules.quantum_numbers import InteractionProperties, _to_fraction from qrules.solving import EdgeSettings, NodeSettings, QNProblemSet, QNResult -from qrules.topology import FrozenTransition, MutableTransition, Topology, Transition +from qrules.topology import (FrozenTransition, MutableTransition, Topology, + Transition) from qrules.transition import ProblemSet, ReactionInfo, State _LOGGER = logging.getLogger(__name__) diff --git a/src/qrules/particle.py b/src/qrules/particle.py index 9e42c277..e3919329 100644 --- a/src/qrules/particle.py +++ b/src/qrules/particle.py @@ -16,19 +16,8 @@ from difflib import get_close_matches from functools import total_ordering from math import copysign -from typing import ( - TYPE_CHECKING, - Any, - Callable, - Dict, - Iterable, - Iterator, - List, - Optional, - SupportsFloat, - Tuple, - Union, -) +from typing import (TYPE_CHECKING, Any, Callable, Dict, Iterable, Iterator, + List, Optional, SupportsFloat, Tuple, Union) import attrs from attrs import field, frozen diff --git a/src/qrules/settings.py b/src/qrules/settings.py index cfa6875f..4e9f04bf 100644 --- a/src/qrules/settings.py +++ b/src/qrules/settings.py @@ -13,34 +13,28 @@ from os.path import dirname, join, realpath from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union -from qrules.conservation_rules import ( - BaryonNumberConservation, - BottomnessConservation, - ChargeConservation, - CharmConservation, - ConservationRule, - EdgeQNConservationRule, - ElectronLNConservation, - GraphElementRule, - MassConservation, - MuonLNConservation, - StrangenessConservation, - TauLNConservation, - c_parity_conservation, - clebsch_gordan_helicity_to_canonical, - g_parity_conservation, - gellmann_nishijima, - helicity_conservation, - identical_particle_symmetrization, - isospin_conservation, - isospin_validity, - ls_spin_validity, - parity_conservation, - parity_conservation_helicity, - spin_conservation, - spin_magnitude_conservation, - spin_validity, -) +from qrules.conservation_rules import (BaryonNumberConservation, + BottomnessConservation, + ChargeConservation, CharmConservation, + ConservationRule, + EdgeQNConservationRule, + ElectronLNConservation, + GraphElementRule, MassConservation, + MuonLNConservation, + StrangenessConservation, + TauLNConservation, + c_parity_conservation, + clebsch_gordan_helicity_to_canonical, + g_parity_conservation, + gellmann_nishijima, + helicity_conservation, + identical_particle_symmetrization, + isospin_conservation, isospin_validity, + ls_spin_validity, parity_conservation, + parity_conservation_helicity, + spin_conservation, + spin_magnitude_conservation, + spin_validity) from qrules.particle import Particle, ParticleCollection from qrules.quantum_numbers import EdgeQuantumNumbers as EdgeQN from qrules.quantum_numbers import NodeQuantumNumbers as NodeQN diff --git a/src/qrules/solving.py b/src/qrules/solving.py index dfb13258..867788e3 100644 --- a/src/qrules/solving.py +++ b/src/qrules/solving.py @@ -14,37 +14,21 @@ from abc import ABC, abstractmethod from collections import defaultdict from copy import copy -from typing import ( - Any, - Callable, - Dict, - Generic, - Iterable, - List, - Optional, - Set, - Tuple, - Type, - TypeVar, - Union, -) +from typing import (Any, Callable, Dict, Generic, Iterable, List, Optional, + Set, Tuple, Type, TypeVar, Union) import attrs from attrs import define, field, frozen -from constraint import BacktrackingSolver, Constraint, Problem, Unassigned, Variable +from constraint import (BacktrackingSolver, Constraint, Problem, Unassigned, + Variable) from qrules._implementers import implement_pretty_repr -from .argument_handling import ( - GraphEdgePropertyMap, - GraphElementRule, - GraphNodePropertyMap, - Rule, - RuleArgumentHandler, - Scalar, - get_required_qns, -) -from .quantum_numbers import EdgeQuantumNumber, EdgeQuantumNumbers, NodeQuantumNumber +from .argument_handling import (GraphEdgePropertyMap, GraphElementRule, + GraphNodePropertyMap, Rule, + RuleArgumentHandler, Scalar, get_required_qns) +from .quantum_numbers import (EdgeQuantumNumber, EdgeQuantumNumbers, + NodeQuantumNumber) from .topology import MutableTransition, Topology if sys.version_info >= (3, 10): diff --git a/src/qrules/topology.py b/src/qrules/topology.py index d77037ba..fdd112fd 100644 --- a/src/qrules/topology.py +++ b/src/qrules/topology.py @@ -22,27 +22,10 @@ from abc import ABC, abstractmethod from collections import abc from functools import total_ordering -from typing import ( - TYPE_CHECKING, - Any, - Callable, - Dict, - FrozenSet, - Generic, - ItemsView, - Iterable, - Iterator, - KeysView, - List, - Mapping, - Optional, - Sequence, - Set, - Tuple, - TypeVar, - ValuesView, - overload, -) +from typing import (TYPE_CHECKING, Any, Callable, Dict, FrozenSet, Generic, + ItemsView, Iterable, Iterator, KeysView, List, Mapping, + Optional, Sequence, Set, Tuple, TypeVar, ValuesView, + overload) import attrs from attrs import define, field, frozen diff --git a/src/qrules/transition.py b/src/qrules/transition.py index 60c8db1d..3919be33 100644 --- a/src/qrules/transition.py +++ b/src/qrules/transition.py @@ -7,19 +7,8 @@ from copy import copy, deepcopy from enum import Enum, auto from multiprocessing import Pool -from typing import ( - TYPE_CHECKING, - Dict, - Iterable, - List, - Optional, - Sequence, - Set, - Tuple, - Type, - Union, - overload, -) +from typing import (TYPE_CHECKING, Dict, Iterable, List, Optional, Sequence, + Set, Tuple, Type, Union, overload) import attrs from attrs import define, field, frozen @@ -28,61 +17,26 @@ from qrules._implementers import implement_pretty_repr -from ._system_control import ( - GammaCheck, - InteractionDeterminator, - LeptonCheck, - create_edge_properties, - create_interaction_properties, - create_node_properties, - filter_interaction_types, - find_particle, - remove_duplicate_solutions, -) -from .combinatorics import ( - InitialFacts, - StateDefinition, - create_initial_facts, - ensure_nested_list, - match_external_edges, - permutate_topology_kinematically, -) -from .particle import ( - Particle, - ParticleCollection, - ParticleWithSpin, - _to_float, - load_pdg, -) -from .quantum_numbers import ( - EdgeQuantumNumber, - EdgeQuantumNumbers, - InteractionProperties, - NodeQuantumNumber, - NodeQuantumNumbers, -) -from .settings import ( - DEFAULT_INTERACTION_TYPES, - InteractionType, - NumberOfThreads, - create_interaction_settings, -) -from .solving import ( - CSPSolver, - EdgeSettings, - GraphEdgePropertyMap, - GraphSettings, - NodeSettings, - QNProblemSet, - QNResult, -) -from .topology import ( - FrozenDict, - MutableTransition, - Topology, - create_isobar_topologies, - create_n_body_topology, -) +from ._system_control import (GammaCheck, InteractionDeterminator, LeptonCheck, + create_edge_properties, + create_interaction_properties, + create_node_properties, filter_interaction_types, + find_particle, remove_duplicate_solutions) +from .combinatorics import (InitialFacts, StateDefinition, + create_initial_facts, ensure_nested_list, + match_external_edges, + permutate_topology_kinematically) +from .particle import (Particle, ParticleCollection, ParticleWithSpin, + _to_float, load_pdg) +from .quantum_numbers import (EdgeQuantumNumber, EdgeQuantumNumbers, + InteractionProperties, NodeQuantumNumber, + NodeQuantumNumbers) +from .settings import (DEFAULT_INTERACTION_TYPES, InteractionType, + NumberOfThreads, create_interaction_settings) +from .solving import (CSPSolver, EdgeSettings, GraphEdgePropertyMap, + GraphSettings, NodeSettings, QNProblemSet, QNResult) +from .topology import (FrozenDict, MutableTransition, Topology, + create_isobar_topologies, create_n_body_topology) if sys.version_info >= (3, 10): from typing import TypeAlias diff --git a/tests/.pydocstyle b/tests/.pydocstyle deleted file mode 100644 index 26d0703b..00000000 --- a/tests/.pydocstyle +++ /dev/null @@ -1,4 +0,0 @@ -; ignore all pydocstyle errors in this folder - -[pydocstyle] -add_ignore = D diff --git a/tests/unit/conservation_rules/test_c_parity.py b/tests/unit/conservation_rules/test_c_parity.py index 095de29f..16c8d344 100644 --- a/tests/unit/conservation_rules/test_c_parity.py +++ b/tests/unit/conservation_rules/test_c_parity.py @@ -2,11 +2,8 @@ import pytest -from qrules.conservation_rules import ( - CParityEdgeInput, - CParityNodeInput, - c_parity_conservation, -) +from qrules.conservation_rules import (CParityEdgeInput, CParityNodeInput, + c_parity_conservation) from qrules.quantum_numbers import Parity diff --git a/tests/unit/conservation_rules/test_clebsch_gordan.py b/tests/unit/conservation_rules/test_clebsch_gordan.py index b3a6f5b0..ae9fd959 100644 --- a/tests/unit/conservation_rules/test_clebsch_gordan.py +++ b/tests/unit/conservation_rules/test_clebsch_gordan.py @@ -2,14 +2,10 @@ import pytest -from qrules.conservation_rules import ( - IsoSpinEdgeInput, - SpinEdgeInput, - SpinNodeInput, - clebsch_gordan_helicity_to_canonical, - isospin_conservation, - spin_conservation, -) +from qrules.conservation_rules import (IsoSpinEdgeInput, SpinEdgeInput, + SpinNodeInput, + clebsch_gordan_helicity_to_canonical, + isospin_conservation, spin_conservation) from qrules.particle import Spin from .test_spin import __create_two_body_decay_spin_data diff --git a/tests/unit/conservation_rules/test_duck_typing.py b/tests/unit/conservation_rules/test_duck_typing.py index 9063aa1f..f8ec8352 100644 --- a/tests/unit/conservation_rules/test_duck_typing.py +++ b/tests/unit/conservation_rules/test_duck_typing.py @@ -12,11 +12,8 @@ from qrules import conservation_rules from qrules.particle import Particle -from qrules.quantum_numbers import ( - EdgeQuantumNumbers, - InteractionProperties, - NodeQuantumNumbers, -) +from qrules.quantum_numbers import (EdgeQuantumNumbers, InteractionProperties, + NodeQuantumNumbers) RULE_INPUT_CLASSES = { getattr(conservation_rules, name) diff --git a/tests/unit/conservation_rules/test_g_parity.py b/tests/unit/conservation_rules/test_g_parity.py index 4c10fd2f..949350d6 100644 --- a/tests/unit/conservation_rules/test_g_parity.py +++ b/tests/unit/conservation_rules/test_g_parity.py @@ -2,11 +2,8 @@ import pytest -from qrules.conservation_rules import ( - GParityEdgeInput, - GParityNodeInput, - g_parity_conservation, -) +from qrules.conservation_rules import (GParityEdgeInput, GParityNodeInput, + g_parity_conservation) from qrules.quantum_numbers import Parity diff --git a/tests/unit/conservation_rules/test_gellmann_nishijima.py b/tests/unit/conservation_rules/test_gellmann_nishijima.py index 9b718e77..bc756efa 100644 --- a/tests/unit/conservation_rules/test_gellmann_nishijima.py +++ b/tests/unit/conservation_rules/test_gellmann_nishijima.py @@ -2,7 +2,8 @@ import pytest -from qrules.conservation_rules import GellMannNishijimaInput, gellmann_nishijima +from qrules.conservation_rules import (GellMannNishijimaInput, + gellmann_nishijima) @pytest.mark.parametrize( diff --git a/tests/unit/conservation_rules/test_identical_particle_symmetrization.py b/tests/unit/conservation_rules/test_identical_particle_symmetrization.py index 20d1b5c9..2e5218a3 100644 --- a/tests/unit/conservation_rules/test_identical_particle_symmetrization.py +++ b/tests/unit/conservation_rules/test_identical_particle_symmetrization.py @@ -1,9 +1,7 @@ import pytest -from qrules.conservation_rules import ( - IdenticalParticleSymmetryOutEdgeInput, - identical_particle_symmetrization, -) +from qrules.conservation_rules import (IdenticalParticleSymmetryOutEdgeInput, + identical_particle_symmetrization) from qrules.quantum_numbers import Parity diff --git a/tests/unit/conservation_rules/test_parity_conservation.py b/tests/unit/conservation_rules/test_parity_conservation.py index 3d0dde31..f96b2898 100644 --- a/tests/unit/conservation_rules/test_parity_conservation.py +++ b/tests/unit/conservation_rules/test_parity_conservation.py @@ -2,11 +2,9 @@ import pytest -from qrules.conservation_rules import ( - HelicityParityEdgeInput, - parity_conservation, - parity_conservation_helicity, -) +from qrules.conservation_rules import (HelicityParityEdgeInput, + parity_conservation, + parity_conservation_helicity) from qrules.quantum_numbers import NodeQuantumNumbers, Parity diff --git a/tests/unit/conservation_rules/test_spin.py b/tests/unit/conservation_rules/test_spin.py index 9338f2a0..91c2cbb2 100644 --- a/tests/unit/conservation_rules/test_spin.py +++ b/tests/unit/conservation_rules/test_spin.py @@ -2,12 +2,9 @@ import pytest -from qrules.conservation_rules import ( - SpinEdgeInput, - SpinNodeInput, - spin_conservation, - spin_magnitude_conservation, -) +from qrules.conservation_rules import (SpinEdgeInput, SpinNodeInput, + spin_conservation, + spin_magnitude_conservation) from qrules.particle import Spin _SpinRuleInputType = Tuple[List[SpinEdgeInput], List[SpinEdgeInput], SpinNodeInput] diff --git a/tests/unit/io/test_dot.py b/tests/unit/io/test_dot.py index 8ff439d2..215d14f0 100644 --- a/tests/unit/io/test_dot.py +++ b/tests/unit/io/test_dot.py @@ -3,14 +3,11 @@ import qrules from qrules import io -from qrules.io._dot import _collapse_graphs, _get_particle_graphs, _strip_projections +from qrules.io._dot import (_collapse_graphs, _get_particle_graphs, + _strip_projections) from qrules.particle import Particle, ParticleCollection -from qrules.topology import ( - Edge, - Topology, - create_isobar_topologies, - create_n_body_topology, -) +from qrules.topology import (Edge, Topology, create_isobar_topologies, + create_n_body_topology) from qrules.transition import ReactionInfo diff --git a/tests/unit/io/test_io.py b/tests/unit/io/test_io.py index 8bc97ec5..458a2de8 100644 --- a/tests/unit/io/test_io.py +++ b/tests/unit/io/test_io.py @@ -4,12 +4,8 @@ from qrules import io from qrules.particle import Particle, ParticleCollection -from qrules.topology import ( - FrozenTransition, - Topology, - create_isobar_topologies, - create_n_body_topology, -) +from qrules.topology import (FrozenTransition, Topology, + create_isobar_topologies, create_n_body_topology) from qrules.transition import ReactionInfo diff --git a/tests/unit/test_combinatorics.py b/tests/unit/test_combinatorics.py index 098f19a7..254532bf 100644 --- a/tests/unit/test_combinatorics.py +++ b/tests/unit/test_combinatorics.py @@ -3,14 +3,11 @@ import pytest -from qrules.combinatorics import ( - _generate_kinematic_permutations, - _get_kinematic_representation, - _KinematicRepresentation, - _permutate_outer_edges, - create_initial_facts, - permutate_topology_kinematically, -) +from qrules.combinatorics import (_generate_kinematic_permutations, + _get_kinematic_representation, + _KinematicRepresentation, + _permutate_outer_edges, create_initial_facts, + permutate_topology_kinematically) from qrules.topology import Topology, create_isobar_topologies diff --git a/tests/unit/test_particle.py b/tests/unit/test_particle.py index 35c656e8..21879e3a 100644 --- a/tests/unit/test_particle.py +++ b/tests/unit/test_particle.py @@ -8,15 +8,9 @@ from attrs.exceptions import FrozenInstanceError from IPython.lib.pretty import pretty -from qrules.particle import ( - Particle, - ParticleCollection, - Spin, - _get_name_root, - create_antiparticle, - create_particle, -) - +from qrules.particle import (Particle, ParticleCollection, Spin, + _get_name_root, create_antiparticle, + create_particle) # For eval tests from qrules.quantum_numbers import Parity # noqa: F401 diff --git a/tests/unit/test_settings.py b/tests/unit/test_settings.py index a8bb739e..7720296d 100644 --- a/tests/unit/test_settings.py +++ b/tests/unit/test_settings.py @@ -2,13 +2,8 @@ from qrules.particle import ParticleCollection from qrules.quantum_numbers import EdgeQuantumNumbers as EdgeQN -from qrules.settings import ( - InteractionType, - _create_domains, - _halves_domain, - _int_domain, - create_interaction_settings, -) +from qrules.settings import (InteractionType, _create_domains, _halves_domain, + _int_domain, create_interaction_settings) class TestInteractionType: diff --git a/tests/unit/test_system_control.py b/tests/unit/test_system_control.py index 5a85e084..a69a2567 100644 --- a/tests/unit/test_system_control.py +++ b/tests/unit/test_system_control.py @@ -7,24 +7,15 @@ import pytest from qrules import InteractionType, ProblemSet, StateTransitionManager -from qrules._system_control import ( - create_edge_properties, - filter_graphs, - remove_duplicate_solutions, - require_interaction_property, -) +from qrules._system_control import (create_edge_properties, filter_graphs, + remove_duplicate_solutions, + require_interaction_property) from qrules.combinatorics import ( - ParticleWithSpin, - _create_edge_id_particle_mapping, - match_external_edges, - perform_external_edge_identical_particle_combinatorics, -) + ParticleWithSpin, _create_edge_id_particle_mapping, match_external_edges, + perform_external_edge_identical_particle_combinatorics) from qrules.particle import Particle -from qrules.quantum_numbers import ( - EdgeQuantumNumbers, - InteractionProperties, - NodeQuantumNumbers, -) +from qrules.quantum_numbers import (EdgeQuantumNumbers, InteractionProperties, + NodeQuantumNumbers) from qrules.topology import Edge, MutableTransition, Topology diff --git a/tests/unit/test_topology.py b/tests/unit/test_topology.py index 3e637d69..70c5d744 100644 --- a/tests/unit/test_topology.py +++ b/tests/unit/test_topology.py @@ -6,17 +6,11 @@ from attrs.exceptions import FrozenInstanceError from IPython.lib.pretty import pretty -from qrules.topology import ( # noqa: F401 - Edge, - FrozenDict, - InteractionNode, - MutableTopology, - SimpleStateTransitionTopologyBuilder, - Topology, - create_isobar_topologies, - create_n_body_topology, - get_originating_node_list, -) +from qrules.topology import (Edge, FrozenDict, InteractionNode, # noqa: F401 + MutableTopology, + SimpleStateTransitionTopologyBuilder, Topology, + create_isobar_topologies, create_n_body_topology, + get_originating_node_list) class TestEdge: diff --git a/tests/unit/test_transition.py b/tests/unit/test_transition.py index 88ff1e6a..a5a44ef5 100644 --- a/tests/unit/test_transition.py +++ b/tests/unit/test_transition.py @@ -5,16 +5,12 @@ import pytest from IPython.lib.pretty import pretty -from qrules.particle import Parity, Particle, ParticleCollection, Spin # noqa: F401 +from qrules.particle import (Parity, Particle, # noqa: F401 + ParticleCollection, Spin) from qrules.quantum_numbers import InteractionProperties # noqa: F401 from qrules.settings import InteractionType -from qrules.topology import ( # noqa: F401 - Edge, - FrozenDict, - FrozenTransition, - MutableTransition, - Topology, -) +from qrules.topology import (Edge, FrozenDict, FrozenTransition, # noqa: F401 + MutableTransition, Topology) from qrules.transition import ReactionInfo, State, StateTransitionManager From 3b448b3ef460f3cf2033b43471a6eff5858a7e4b Mon Sep 17 00:00:00 2001 From: GitHub Date: Tue, 4 Jul 2023 08:17:47 +0000 Subject: [PATCH 03/47] MAINT: update pip constraints and pre-commit --- .constraints/py3.10.txt | 30 +++++++++++++++--------------- .constraints/py3.11.txt | 28 ++++++++++++++-------------- .constraints/py3.7.txt | 18 +++++++++--------- .constraints/py3.8.txt | 30 +++++++++++++++--------------- .constraints/py3.9.txt | 30 +++++++++++++++--------------- .pre-commit-config.yaml | 2 +- 6 files changed, 69 insertions(+), 69 deletions(-) diff --git a/.constraints/py3.10.txt b/.constraints/py3.10.txt index d87ef8bb..f1f84661 100644 --- a/.constraints/py3.10.txt +++ b/.constraints/py3.10.txt @@ -38,7 +38,7 @@ deprecated==1.2.14 dill==0.3.6 distlib==0.3.6 docutils==0.19 -exceptiongroup==1.1.1 +exceptiongroup==1.1.2 execnet==1.9.0 executing==1.2.0 fastjsonschema==2.17.1 @@ -49,7 +49,7 @@ flake8-bugbear==23.6.5 ; python_version >= "3.8.0" flake8-builtins==2.1.0 ; python_version >= "3.8.0" flake8-comprehensions==3.13.0 ; python_version >= "3.8.0" flake8-future-import==0.4.7 ; python_version >= "3.8.0" -flake8-plugin-utils==1.3.2 +flake8-plugin-utils==1.3.3 flake8-pytest-style==1.7.2 ; python_version >= "3.8.0" flake8-rst-docstrings==0.3.0 ; python_version >= "3.8.0" flake8-type-ignore==0.1.0.post2 ; python_version >= "3.8.0" @@ -64,7 +64,7 @@ idna==3.4 imagesize==1.4.1 importlib-metadata==6.7.0 iniconfig==2.0.0 -ipykernel==6.23.2 +ipykernel==6.24.0 ipython==8.14.0 ipython-genutils==0.2.0 ipywidgets==8.0.6 @@ -76,17 +76,17 @@ json5==0.9.14 jsonpointer==2.4 jsonschema==4.17.3 jupyter-cache==0.6.1 -jupyter-client==8.2.0 +jupyter-client==8.3.0 jupyter-core==5.3.1 jupyter-events==0.6.3 -jupyter-server==2.6.0 +jupyter-server==2.7.0 jupyter-server-fileid==0.9.0 jupyter-server-terminals==0.4.4 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 ; python_version >= "3.7.0" +jupyterlab-myst==2.0.0 ; python_version >= "3.7.0" jupyterlab-pygments==0.2.2 jupyterlab-server==2.23.0 jupyterlab-widgets==3.0.7 @@ -100,7 +100,7 @@ mccabe==0.7.0 mdit-py-plugins==0.3.5 mdurl==0.1.2 mistune==3.0.1 -mypy==1.4.0 +mypy==1.4.1 mypy-extensions==1.0.0 myst-nb==0.17.2 myst-parser==0.18.1 @@ -117,12 +117,12 @@ overrides==7.3.1 packaging==23.1 pandocfilters==1.5.0 parso==0.8.3 -particle==0.22.1 +particle==0.23.0 pathspec==0.11.1 pep8-naming==0.13.3 ; python_version >= "3.8.0" pexpect==4.8.0 pickleshare==0.7.5 -platformdirs==3.7.0 +platformdirs==3.8.0 pluggy==1.2.0 pre-commit==3.3.3 prometheus-client==0.17.0 @@ -134,7 +134,7 @@ pybtex==0.24.0 pybtex-docutils==1.0.2 pycodestyle==2.10.0 pycparser==2.21 -pydantic==1.10.9 +pydantic==1.10.10 pydata-sphinx-theme==0.13.3 pydocstyle==6.3.0 pydot==1.4.2 @@ -144,7 +144,7 @@ pylint==2.17.4 pyparsing==3.1.0 pyproject-api==1.5.2 pyrsistent==0.19.3 -pytest==7.3.2 +pytest==7.4.0 pytest-cov==4.1.0 pytest-profiling==1.7.0 pytest-xdist==3.3.1 @@ -180,7 +180,7 @@ sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 sphobjinv==2.3.1 -sqlalchemy==2.0.16 +sqlalchemy==2.0.17 stack-data==0.6.2 tabulate==0.9.0 terminado==0.17.1 @@ -197,14 +197,14 @@ types-pyyaml==6.0.12.10 types-requests==2.31.0.1 types-setuptools==68.0.0.0 types-urllib3==1.26.25.13 -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 wrapt==1.15.0 diff --git a/.constraints/py3.11.txt b/.constraints/py3.11.txt index a4a6efb3..6c53ec07 100644 --- a/.constraints/py3.11.txt +++ b/.constraints/py3.11.txt @@ -48,7 +48,7 @@ flake8-bugbear==23.6.5 ; python_version >= "3.8.0" flake8-builtins==2.1.0 ; python_version >= "3.8.0" flake8-comprehensions==3.13.0 ; python_version >= "3.8.0" flake8-future-import==0.4.7 ; python_version >= "3.8.0" -flake8-plugin-utils==1.3.2 +flake8-plugin-utils==1.3.3 flake8-pytest-style==1.7.2 ; python_version >= "3.8.0" flake8-rst-docstrings==0.3.0 ; python_version >= "3.8.0" flake8-type-ignore==0.1.0.post2 ; python_version >= "3.8.0" @@ -63,7 +63,7 @@ idna==3.4 imagesize==1.4.1 importlib-metadata==6.7.0 iniconfig==2.0.0 -ipykernel==6.23.2 +ipykernel==6.24.0 ipython==8.14.0 ipython-genutils==0.2.0 ipywidgets==8.0.6 @@ -75,17 +75,17 @@ json5==0.9.14 jsonpointer==2.4 jsonschema==4.17.3 jupyter-cache==0.6.1 -jupyter-client==8.2.0 +jupyter-client==8.3.0 jupyter-core==5.3.1 jupyter-events==0.6.3 -jupyter-server==2.6.0 +jupyter-server==2.7.0 jupyter-server-fileid==0.9.0 jupyter-server-terminals==0.4.4 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 ; python_version >= "3.7.0" +jupyterlab-myst==2.0.0 ; python_version >= "3.7.0" jupyterlab-pygments==0.2.2 jupyterlab-server==2.23.0 jupyterlab-widgets==3.0.7 @@ -99,7 +99,7 @@ mccabe==0.7.0 mdit-py-plugins==0.3.5 mdurl==0.1.2 mistune==3.0.1 -mypy==1.4.0 +mypy==1.4.1 mypy-extensions==1.0.0 myst-nb==0.17.2 myst-parser==0.18.1 @@ -116,12 +116,12 @@ overrides==7.3.1 packaging==23.1 pandocfilters==1.5.0 parso==0.8.3 -particle==0.22.1 +particle==0.23.0 pathspec==0.11.1 pep8-naming==0.13.3 ; python_version >= "3.8.0" pexpect==4.8.0 pickleshare==0.7.5 -platformdirs==3.7.0 +platformdirs==3.8.0 pluggy==1.2.0 pre-commit==3.3.3 prometheus-client==0.17.0 @@ -133,7 +133,7 @@ pybtex==0.24.0 pybtex-docutils==1.0.2 pycodestyle==2.10.0 pycparser==2.21 -pydantic==1.10.9 +pydantic==1.10.10 pydata-sphinx-theme==0.13.3 pydocstyle==6.3.0 pydot==1.4.2 @@ -143,7 +143,7 @@ pylint==2.17.4 pyparsing==3.1.0 pyproject-api==1.5.2 pyrsistent==0.19.3 -pytest==7.3.2 +pytest==7.4.0 pytest-cov==4.1.0 pytest-profiling==1.7.0 pytest-xdist==3.3.1 @@ -179,7 +179,7 @@ sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 sphobjinv==2.3.1 -sqlalchemy==2.0.16 +sqlalchemy==2.0.17 stack-data==0.6.2 tabulate==0.9.0 terminado==0.17.1 @@ -195,14 +195,14 @@ types-pyyaml==6.0.12.10 types-requests==2.31.0.1 types-setuptools==68.0.0.0 types-urllib3==1.26.25.13 -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 wrapt==1.15.0 diff --git a/.constraints/py3.7.txt b/.constraints/py3.7.txt index a9359091..7c8e4e8b 100644 --- a/.constraints/py3.7.txt +++ b/.constraints/py3.7.txt @@ -36,7 +36,7 @@ dill==0.3.6 distlib==0.3.6 docutils==0.19 entrypoints==0.4 -exceptiongroup==1.1.1 +exceptiongroup==1.1.2 execnet==1.9.0 fastjsonschema==2.17.1 filelock==3.12.2 @@ -70,7 +70,7 @@ 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 ; python_version >= "3.7.0" jupyterlab-pygments==0.2.2 @@ -86,7 +86,7 @@ mccabe==0.7.0 mdit-py-plugins==0.3.5 mdurl==0.1.2 mistune==3.0.1 -mypy==1.4.0 +mypy==1.4.1 mypy-extensions==1.0.0 myst-nb==0.17.2 myst-parser==0.18.1 @@ -102,12 +102,12 @@ notebook-shim==0.2.3 packaging==23.1 pandocfilters==1.5.0 parso==0.8.3 -particle==0.22.1 +particle==0.23.0 pathspec==0.11.1 pexpect==4.8.0 pickleshare==0.7.5 pkgutil-resolve-name==1.3.10 -platformdirs==3.7.0 +platformdirs==3.8.0 pluggy==1.2.0 pre-commit==2.21.0 prometheus-client==0.17.0 @@ -118,7 +118,7 @@ py==1.11.0 pybtex==0.24.0 pybtex-docutils==1.0.2 pycparser==2.21 -pydantic==1.10.9 +pydantic==1.10.10 pydata-sphinx-theme==0.13.3 pydocstyle==6.3.0 pydot==1.4.2 @@ -126,7 +126,7 @@ pygments==2.15.1 pylint==2.17.4 pyparsing==3.1.0 pyrsistent==0.19.3 -pytest==7.3.2 +pytest==7.4.0 pytest-cov==4.1.0 pytest-profiling==1.7.0 pytest-xdist==3.3.1 @@ -179,14 +179,14 @@ types-pyyaml==6.0.12.10 types-requests==2.31.0.1 types-setuptools==68.0.0.0 types-urllib3==1.26.25.13 -typing-extensions==4.6.3 ; python_version < "3.10.0" +typing-extensions==4.7.1 ; python_version < "3.10.0" uri-template==1.3.0 urllib3==2.0.3 virtualenv==20.21.1 ; python_version < "3.8.0" 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 wrapt==1.15.0 diff --git a/.constraints/py3.8.txt b/.constraints/py3.8.txt index 2c0e3ee4..4f38b2f2 100644 --- a/.constraints/py3.8.txt +++ b/.constraints/py3.8.txt @@ -38,7 +38,7 @@ deprecated==1.2.14 dill==0.3.6 distlib==0.3.6 docutils==0.19 -exceptiongroup==1.1.1 +exceptiongroup==1.1.2 execnet==1.9.0 executing==1.2.0 fastjsonschema==2.17.1 @@ -49,7 +49,7 @@ flake8-bugbear==23.6.5 ; python_version >= "3.8.0" flake8-builtins==2.1.0 ; python_version >= "3.8.0" flake8-comprehensions==3.13.0 ; python_version >= "3.8.0" flake8-future-import==0.4.7 ; python_version >= "3.8.0" -flake8-plugin-utils==1.3.2 +flake8-plugin-utils==1.3.3 flake8-pytest-style==1.7.2 ; python_version >= "3.8.0" flake8-rst-docstrings==0.3.0 ; python_version >= "3.8.0" flake8-type-ignore==0.1.0.post2 ; python_version >= "3.8.0" @@ -65,7 +65,7 @@ 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 ipython==8.12.2 ipython-genutils==0.2.0 ipywidgets==8.0.6 @@ -77,17 +77,17 @@ json5==0.9.14 jsonpointer==2.4 jsonschema==4.17.3 jupyter-cache==0.6.1 -jupyter-client==8.2.0 +jupyter-client==8.3.0 jupyter-core==5.3.1 jupyter-events==0.6.3 -jupyter-server==2.6.0 +jupyter-server==2.7.0 jupyter-server-fileid==0.9.0 jupyter-server-terminals==0.4.4 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 ; python_version >= "3.7.0" +jupyterlab-myst==2.0.0 ; python_version >= "3.7.0" jupyterlab-pygments==0.2.2 jupyterlab-server==2.23.0 jupyterlab-widgets==3.0.7 @@ -101,7 +101,7 @@ mccabe==0.7.0 mdit-py-plugins==0.3.5 mdurl==0.1.2 mistune==3.0.1 -mypy==1.4.0 +mypy==1.4.1 mypy-extensions==1.0.0 myst-nb==0.17.2 myst-parser==0.18.1 @@ -118,13 +118,13 @@ overrides==7.3.1 packaging==23.1 pandocfilters==1.5.0 parso==0.8.3 -particle==0.22.1 +particle==0.23.0 pathspec==0.11.1 pep8-naming==0.13.3 ; python_version >= "3.8.0" pexpect==4.8.0 pickleshare==0.7.5 pkgutil-resolve-name==1.3.10 -platformdirs==3.7.0 +platformdirs==3.8.0 pluggy==1.2.0 pre-commit==3.3.3 prometheus-client==0.17.0 @@ -136,7 +136,7 @@ pybtex==0.24.0 pybtex-docutils==1.0.2 pycodestyle==2.10.0 pycparser==2.21 -pydantic==1.10.9 +pydantic==1.10.10 pydata-sphinx-theme==0.13.3 pydocstyle==6.3.0 pydot==1.4.2 @@ -146,7 +146,7 @@ pylint==2.17.4 pyparsing==3.1.0 pyproject-api==1.5.2 pyrsistent==0.19.3 -pytest==7.3.2 +pytest==7.4.0 pytest-cov==4.1.0 pytest-profiling==1.7.0 pytest-xdist==3.3.1 @@ -183,7 +183,7 @@ sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 sphobjinv==2.3.1 -sqlalchemy==2.0.16 +sqlalchemy==2.0.17 stack-data==0.6.2 tabulate==0.9.0 terminado==0.17.1 @@ -200,14 +200,14 @@ types-pyyaml==6.0.12.10 types-requests==2.31.0.1 types-setuptools==68.0.0.0 types-urllib3==1.26.25.13 -typing-extensions==4.6.3 ; python_version < "3.10.0" +typing-extensions==4.7.1 ; python_version < "3.10.0" 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 wrapt==1.15.0 diff --git a/.constraints/py3.9.txt b/.constraints/py3.9.txt index 943bdd6f..8ec9eec4 100644 --- a/.constraints/py3.9.txt +++ b/.constraints/py3.9.txt @@ -38,7 +38,7 @@ deprecated==1.2.14 dill==0.3.6 distlib==0.3.6 docutils==0.19 -exceptiongroup==1.1.1 +exceptiongroup==1.1.2 execnet==1.9.0 executing==1.2.0 fastjsonschema==2.17.1 @@ -49,7 +49,7 @@ flake8-bugbear==23.6.5 ; python_version >= "3.8.0" flake8-builtins==2.1.0 ; python_version >= "3.8.0" flake8-comprehensions==3.13.0 ; python_version >= "3.8.0" flake8-future-import==0.4.7 ; python_version >= "3.8.0" -flake8-plugin-utils==1.3.2 +flake8-plugin-utils==1.3.3 flake8-pytest-style==1.7.2 ; python_version >= "3.8.0" flake8-rst-docstrings==0.3.0 ; python_version >= "3.8.0" flake8-type-ignore==0.1.0.post2 ; python_version >= "3.8.0" @@ -64,7 +64,7 @@ idna==3.4 imagesize==1.4.1 importlib-metadata==6.7.0 iniconfig==2.0.0 -ipykernel==6.23.2 +ipykernel==6.24.0 ipython==8.14.0 ipython-genutils==0.2.0 ipywidgets==8.0.6 @@ -76,17 +76,17 @@ json5==0.9.14 jsonpointer==2.4 jsonschema==4.17.3 jupyter-cache==0.6.1 -jupyter-client==8.2.0 +jupyter-client==8.3.0 jupyter-core==5.3.1 jupyter-events==0.6.3 -jupyter-server==2.6.0 +jupyter-server==2.7.0 jupyter-server-fileid==0.9.0 jupyter-server-terminals==0.4.4 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 ; python_version >= "3.7.0" +jupyterlab-myst==2.0.0 ; python_version >= "3.7.0" jupyterlab-pygments==0.2.2 jupyterlab-server==2.23.0 jupyterlab-widgets==3.0.7 @@ -100,7 +100,7 @@ mccabe==0.7.0 mdit-py-plugins==0.3.5 mdurl==0.1.2 mistune==3.0.1 -mypy==1.4.0 +mypy==1.4.1 mypy-extensions==1.0.0 myst-nb==0.17.2 myst-parser==0.18.1 @@ -117,12 +117,12 @@ overrides==7.3.1 packaging==23.1 pandocfilters==1.5.0 parso==0.8.3 -particle==0.22.1 +particle==0.23.0 pathspec==0.11.1 pep8-naming==0.13.3 ; python_version >= "3.8.0" pexpect==4.8.0 pickleshare==0.7.5 -platformdirs==3.7.0 +platformdirs==3.8.0 pluggy==1.2.0 pre-commit==3.3.3 prometheus-client==0.17.0 @@ -134,7 +134,7 @@ pybtex==0.24.0 pybtex-docutils==1.0.2 pycodestyle==2.10.0 pycparser==2.21 -pydantic==1.10.9 +pydantic==1.10.10 pydata-sphinx-theme==0.13.3 pydocstyle==6.3.0 pydot==1.4.2 @@ -144,7 +144,7 @@ pylint==2.17.4 pyparsing==3.1.0 pyproject-api==1.5.2 pyrsistent==0.19.3 -pytest==7.3.2 +pytest==7.4.0 pytest-cov==4.1.0 pytest-profiling==1.7.0 pytest-xdist==3.3.1 @@ -180,7 +180,7 @@ sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 sphobjinv==2.3.1 -sqlalchemy==2.0.16 +sqlalchemy==2.0.17 stack-data==0.6.2 tabulate==0.9.0 terminado==0.17.1 @@ -197,14 +197,14 @@ types-pyyaml==6.0.12.10 types-requests==2.31.0.1 types-setuptools==68.0.0.0 types-urllib3==1.26.25.13 -typing-extensions==4.6.3 ; python_version < "3.10.0" +typing-extensions==4.7.1 ; python_version < "3.10.0" 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 wrapt==1.15.0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 993c2938..f1a05e64 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -151,7 +151,7 @@ repos: - --py36-plus - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "" + rev: "v0.0.276" hooks: - id: ruff args: From 130f0f5e72ea80a951e8be5d2379292e9ae163b1 Mon Sep 17 00:00:00 2001 From: GitHub Date: Tue, 4 Jul 2023 08:24:59 +0000 Subject: [PATCH 04/47] MAINT: implement updates from pre-commit hooks --- pyproject.toml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b6ff3287..9365c7b3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,50 +58,50 @@ show_error_codes = true warn_unused_configs = true [[tool.mypy.overrides]] -module = ["tests.*"] check_untyped_defs = true disallow_incomplete_defs = false disallow_untyped_defs = false +module = ["tests.*"] [[tool.mypy.overrides]] -module = ["typings.*"] ignore_errors = true +module = ["typings.*"] [[tool.mypy.overrides]] -module = ["IPython.*"] ignore_missing_imports = true +module = ["IPython.*"] [[tool.mypy.overrides]] -module = ["constraint.*"] ignore_missing_imports = true +module = ["constraint.*"] [[tool.mypy.overrides]] -module = ["jsonschema.*"] ignore_missing_imports = true +module = ["jsonschema.*"] [[tool.mypy.overrides]] -module = ["particle.*"] ignore_missing_imports = true +module = ["particle.*"] [[tool.mypy.overrides]] -module = ["pybtex.*"] ignore_missing_imports = true +module = ["pybtex.*"] [[tool.mypy.overrides]] -module = ["pydot.*"] ignore_missing_imports = true +module = ["pydot.*"] [[tool.mypy.overrides]] -module = ["sphinx.*"] ignore_missing_imports = true +module = ["sphinx.*"] [[tool.mypy.overrides]] -module = ["sphobjinv.*"] ignore_missing_imports = true +module = ["sphobjinv.*"] [[tool.mypy.overrides]] -module = ["tqdm.*"] ignore_missing_imports = true +module = ["tqdm.*"] [tool.pyright] exclude = [ @@ -154,8 +154,8 @@ filterwarnings = [ "ignore:Passing a schema to Validator.iter_errors is deprecated.*:DeprecationWarning", "ignore:unclosed .*:ResourceWarning", ] -norecursedirs = ["_build"] markers = ["slow: marks tests as slow (deselect with '-m \"not slow\"')"] +norecursedirs = ["_build"] testpaths = [ "docs", "src", @@ -163,6 +163,7 @@ testpaths = [ ] [tool.ruff] +extend-exclude = ["typings"] extend-select = [ "A", "B", @@ -208,13 +209,12 @@ ignore = [ "SIM108", ] show-fixes = true -target-version = "py37" -task-tags = ["cspell"] src = [ "src", "tests", ] -extend-exclude = ["typings"] +target-version = "py37" +task-tags = ["cspell"] [tool.ruff.per-file-ignores] "docs/*" = [ From 34a69e4f7ca7015c643bc44d3fbb6804d4a6a76f Mon Sep 17 00:00:00 2001 From: GitHub Date: Tue, 4 Jul 2023 08:57:06 +0000 Subject: [PATCH 05/47] MAINT: update pip constraints and pre-commit --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f1a05e64..3dc86694 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -38,7 +38,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/ComPWA/repo-maintenance - rev: 0.0.184 + rev: 0.0.185 hooks: - id: check-dev-files args: From 4a6907d9e971fe4c45306505933e0029f6a5f873 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 4 Jul 2023 10:58:57 +0200 Subject: [PATCH 06/47] FIX: remove non-existent hooks from `ci` section --- .pre-commit-config.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3dc86694..569ffa3e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,9 +2,7 @@ ci: autoupdate_commit_msg: "MAINT: update pip constraints and pre-commit" autoupdate_schedule: quarterly # already done by requirements-cron.yml skip: - - flake8 - mypy - - pylint - pyright - taplo From 6775046622d9fb4d559f9d5bc0c30b22250e69b2 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 4 Jul 2023 11:00:07 +0200 Subject: [PATCH 07/47] MAINT: install `ruff` instead of `flake8` etc --- setup.cfg | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/setup.cfg b/setup.cfg index dfc5b848..91abbb76 100644 --- a/setup.cfg +++ b/setup.cfg @@ -87,19 +87,6 @@ test = pytest-xdist format = black - isort -flake8 = - flake8 >=4; python_version >="3.8.0" - flake8-blind-except; python_version >="3.8.0" - flake8-bugbear; python_version >="3.8.0" - flake8-builtins; python_version >="3.8.0" - flake8-comprehensions; python_version >="3.8.0" - flake8-future-import; python_version >="3.8.0" - flake8-pytest-style; python_version >="3.8.0" - flake8-rst-docstrings; python_version >="3.8.0" - flake8-type-ignore; python_version >="3.8.0" - flake8-use-fstring; python_version >="3.8.0" - pep8-naming; python_version >="3.8.0" mypy = mypy >=0.730 # attrs and error code support types-docutils @@ -108,10 +95,8 @@ mypy = types-requests types-setuptools lint = - %(flake8)s %(mypy)s - pydocstyle - pylint >=2.5 # good-names-rgxs + ruff sty = %(format)s %(lint)s From 7255c699819ed0941a29b3d2fcb879559ccaf7fb Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 4 Jul 2023 11:00:09 +0200 Subject: [PATCH 08/47] MAINT: remove redundant quotation marks --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 569ffa3e..86dc2045 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -149,7 +149,7 @@ repos: - --py36-plus - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.0.276" + rev: v0.0.276 hooks: - id: ruff args: From 68ead31e3716c11ea71b65d1e1ae691b76356e95 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 4 Jul 2023 09:01:07 +0000 Subject: [PATCH 09/47] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/_relink_references.py | 3 +- docs/conf.py | 24 +++- docs/usage/conservation.ipynb | 10 +- setup.py | 1 - src/qrules/__init__.py | 50 ++++--- src/qrules/_implementers.py | 3 +- src/qrules/_system_control.py | 37 +++--- src/qrules/argument_handling.py | 47 +++++-- src/qrules/combinatorics.py | 52 +++++--- src/qrules/conservation_rules.py | 43 +++--- src/qrules/io/__init__.py | 20 +-- src/qrules/io/_dict.py | 2 +- src/qrules/io/_dot.py | 21 +-- src/qrules/particle.py | 83 +++++++----- src/qrules/quantum_numbers.py | 7 +- src/qrules/settings.py | 63 +++++---- src/qrules/solving.py | 49 ++++--- src/qrules/topology.py | 104 ++++++++++----- src/qrules/transition.py | 123 ++++++++++++------ tests/unit/conftest.py | 3 +- .../unit/conservation_rules/test_c_parity.py | 7 +- .../conservation_rules/test_clebsch_gordan.py | 12 +- .../conservation_rules/test_duck_typing.py | 7 +- .../unit/conservation_rules/test_g_parity.py | 7 +- .../test_gellmann_nishijima.py | 3 +- .../test_identical_particle_symmetrization.py | 6 +- .../test_parity_conservation.py | 8 +- tests/unit/conservation_rules/test_spin.py | 9 +- tests/unit/io/test_dot.py | 11 +- tests/unit/io/test_io.py | 8 +- tests/unit/test_combinatorics.py | 16 ++- tests/unit/test_particle.py | 16 ++- tests/unit/test_quantum_numbers.py | 2 +- tests/unit/test_settings.py | 9 +- tests/unit/test_system_control.py | 29 +++-- tests/unit/test_topology.py | 15 ++- tests/unit/test_transition.py | 8 +- 37 files changed, 577 insertions(+), 341 deletions(-) diff --git a/docs/_relink_references.py b/docs/_relink_references.py index cc9c087c..fc7c1daa 100644 --- a/docs/_relink_references.py +++ b/docs/_relink_references.py @@ -66,8 +66,7 @@ def _new_type_to_xref( if sphinx.version_info >= (4, 4): # https://github.com/sphinx-doc/sphinx/blob/v4.4.0/sphinx/domains/python.py#L110-L133 - from sphinx.domains.python import \ - parse_reftarget # type: ignore[attr-defined] + from sphinx.domains.python import parse_reftarget # type: ignore[attr-defined] reftype, target, title, refspecific = parse_reftarget(target, suppress_prefix) target = __TARGET_SUBSTITUTIONS.get(target, target) diff --git a/docs/conf.py b/docs/conf.py index a56b66b8..dc06241e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -4,6 +4,7 @@ documentation: https://www.sphinx-doc.org/en/master/usage/configuration.html """ +import contextlib import os import re import shutil @@ -12,14 +13,24 @@ from typing import Dict import requests + # pyright: reportMissingImports=false import sphobjinv as soi from pybtex.database import Entry 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 (FieldIsMissing, Node, _format_list, field, - href, join, node, sentence, words) +from pybtex.style.template import ( + FieldIsMissing, + Node, + _format_list, + field, + href, + join, + node, + sentence, + words, +) if sys.version_info < (3, 8): from importlib_metadata import PackageNotFoundError @@ -74,20 +85,19 @@ 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 # -- Generate API ------------------------------------------------------------ sys.path.insert(0, os.path.abspath(".")) -from _extend_docstrings import extend_docstrings # noqa: E402 -from _relink_references import relink_references # noqa: E402 +from _extend_docstrings import extend_docstrings +from _relink_references import relink_references extend_docstrings() relink_references() diff --git a/docs/usage/conservation.ipynb b/docs/usage/conservation.ipynb index 8938232b..6f0e3b42 100644 --- a/docs/usage/conservation.ipynb +++ b/docs/usage/conservation.ipynb @@ -81,9 +81,13 @@ "import graphviz\n", "\n", "import qrules\n", - "from qrules.conservation_rules import (SpinEdgeInput, SpinNodeInput,\n", - " parity_conservation, spin_conservation,\n", - " spin_magnitude_conservation)\n", + "from qrules.conservation_rules import (\n", + " SpinEdgeInput,\n", + " SpinNodeInput,\n", + " parity_conservation,\n", + " spin_conservation,\n", + " spin_magnitude_conservation,\n", + ")\n", "from qrules.quantum_numbers import Parity" ] }, diff --git a/setup.py b/setup.py index 2e577037..93296978 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,3 @@ -# noqa: D100 from setuptools import setup setup( diff --git a/src/qrules/__init__.py b/src/qrules/__init__.py index fe242055..1c1c8cd1 100644 --- a/src/qrules/__init__.py +++ b/src/qrules/__init__.py @@ -17,33 +17,44 @@ """ from itertools import product -from typing import (Dict, FrozenSet, Iterable, List, Optional, Sequence, Set, - Union) +from typing import Dict, FrozenSet, Iterable, List, Optional, Sequence, Set, Union import attrs from . import io from .combinatorics import InitialFacts, StateDefinition, create_initial_facts -from .conservation_rules import (BaryonNumberConservation, - BottomnessConservation, ChargeConservation, - CharmConservation, ElectronLNConservation, - GraphElementRule, MassConservation, - MuonLNConservation, StrangenessConservation, - TauLNConservation, c_parity_conservation, - clebsch_gordan_helicity_to_canonical, - g_parity_conservation, gellmann_nishijima, - identical_particle_symmetrization, - isospin_conservation, isospin_validity, - parity_conservation, - spin_magnitude_conservation) +from .conservation_rules import ( + BaryonNumberConservation, + BottomnessConservation, + ChargeConservation, + CharmConservation, + ElectronLNConservation, + GraphElementRule, + MassConservation, + MuonLNConservation, + StrangenessConservation, + TauLNConservation, + c_parity_conservation, + clebsch_gordan_helicity_to_canonical, + g_parity_conservation, + gellmann_nishijima, + identical_particle_symmetrization, + isospin_conservation, + isospin_validity, + parity_conservation, + spin_magnitude_conservation, +) from .particle import ParticleCollection, load_pdg from .quantum_numbers import InteractionProperties -from .settings import (ADDITIONAL_PARTICLES_DEFINITIONS_PATH, InteractionType, - _halves_domain, _int_domain) +from .settings import ( + ADDITIONAL_PARTICLES_DEFINITIONS_PATH, + InteractionType, + _halves_domain, + _int_domain, +) from .solving import NodeSettings, QNResult, Rule, validate_full_solution from .topology import MutableTransition, create_n_body_topology -from .transition import (EdgeSettings, ProblemSet, ReactionInfo, - StateTransitionManager) +from .transition import EdgeSettings, ProblemSet, ReactionInfo, StateTransitionManager def check_reaction_violations( # pylint: disable=too-many-arguments @@ -136,8 +147,9 @@ def check_pure_edge_rules() -> None: ) if edge_check_result.violated_edge_rules: + msg = f"Some edges violate {edge_check_result.violated_edge_rules.values()}" raise ValueError( - f"Some edges violate {edge_check_result.violated_edge_rules.values()}" + msg ) def check_edge_qn_conservation() -> Set[FrozenSet[str]]: diff --git a/src/qrules/_implementers.py b/src/qrules/_implementers.py index 788bfdc8..10e373c0 100644 --- a/src/qrules/_implementers.py +++ b/src/qrules/_implementers.py @@ -16,8 +16,9 @@ def implement_pretty_repr( ) -> Type[_DecoratedClass]: """Implement a pretty :code:`repr` in a class decorated by `attrs`.""" if not attrs.has(decorated_class): + msg = "Can only implement a pretty repr for a class created with attrs" raise TypeError( - "Can only implement a pretty repr for a class created with attrs" + msg ) def repr_pretty(self: Any, p: "PrettyPrinter", cycle: bool) -> None: diff --git a/src/qrules/_system_control.py b/src/qrules/_system_control.py index 49b876ee..f8334f55 100644 --- a/src/qrules/_system_control.py +++ b/src/qrules/_system_control.py @@ -7,9 +7,14 @@ import attrs from .particle import Particle, ParticleCollection, ParticleWithSpin -from .quantum_numbers import (EdgeQuantumNumber, EdgeQuantumNumbers, - InteractionProperties, NodeQuantumNumber, - NodeQuantumNumbers, Parity) +from .quantum_numbers import ( + EdgeQuantumNumber, + EdgeQuantumNumbers, + InteractionProperties, + NodeQuantumNumber, + NodeQuantumNumbers, + Parity, +) from .settings import InteractionType from .solving import GraphEdgePropertyMap, GraphNodePropertyMap, GraphSettings from .topology import MutableTransition @@ -66,10 +71,9 @@ def create_node_properties( if qn_name in node_qn_mapping: property_map[node_qn_mapping[qn_name]] = value else: + msg = f"Missmatch between InteractionProperties and NodeQuantumNumbers. NodeQuantumNumbers does not define {qn_name}" raise TypeError( - "Missmatch between InteractionProperties and" - " NodeQuantumNumbers. NodeQuantumNumbers does not define" - f" {qn_name}" + msg ) return property_map @@ -96,8 +100,9 @@ def find_particle( particle = particle_db.find(int(state[EdgeQuantumNumbers.pid])) spin_projection = state.get(EdgeQuantumNumbers.spin_projection) if spin_projection is None: + msg = f"{GraphEdgePropertyMap.__name__} does not contain a spin projection" raise ValueError( - f"{GraphEdgePropertyMap.__name__} does not contain a spin projection" + msg ) return particle, spin_projection @@ -242,18 +247,18 @@ def _check_equal_ignoring_qns( ) -> Optional[MutableTransition]: """Define equal operator for graphs, ignoring certain quantum numbers.""" if not isinstance(ref_graph, MutableTransition): - raise TypeError("Reference graph has to be of type MutableTransition") + msg = "Reference graph has to be of type MutableTransition" + raise TypeError(msg) found_graph = None interaction_comparator = NodePropertyComparator(ignored_qn_list) for graph in solutions: - if isinstance(graph, MutableTransition): - if graph.compare( - ref_graph, - state_comparator=lambda e1, e2: e1 == e2, - interaction_comparator=interaction_comparator, - ): - found_graph = graph - break + if isinstance(graph, MutableTransition) and graph.compare( + ref_graph, + state_comparator=lambda e1, e2: e1 == e2, + interaction_comparator=interaction_comparator, + ): + found_graph = graph + break return found_graph diff --git a/src/qrules/argument_handling.py b/src/qrules/argument_handling.py index c1b253aa..58d3023c 100644 --- a/src/qrules/argument_handling.py +++ b/src/qrules/argument_handling.py @@ -6,18 +6,32 @@ """ import inspect -from typing import (Any, Callable, Dict, Generic, List, Optional, Sequence, - Set, Tuple, Type, TypeVar, Union) +from typing import ( + Any, + Callable, + Dict, + Generic, + List, + Optional, + Sequence, + Set, + Tuple, + Type, + TypeVar, + Union, +) import attrs -from .conservation_rules import (ConservationRule, EdgeQNConservationRule, - GraphElementRule) +from .conservation_rules import ( + ConservationRule, + EdgeQNConservationRule, + GraphElementRule, +) from .quantum_numbers import EdgeQuantumNumber, NodeQuantumNumber, Parity Scalar = Union[int, float] -# InteractionRule = Union[EdgeQNConservationRule, ConservationRule] Rule = Union[GraphElementRule, EdgeQNConservationRule, ConservationRule] _ElementType = TypeVar("_ElementType") # pylint: disable=invalid-name @@ -78,7 +92,8 @@ def wrapper(props: GraphElementPropertyMap) -> bool: def _sequence_input_check(func: Callable) -> Callable[[Sequence], bool]: def wrapper(states_list: Sequence[Any]) -> bool: if not isinstance(states_list, (list, tuple)): - raise TypeError("Rule evaluated with invalid argument type...") + msg = "Rule evaluated with invalid argument type..." + raise TypeError(msg) return all(func(x) for x in states_list) @@ -153,7 +168,8 @@ def __call__( def _sequence_arg_builder(func: Callable) -> Callable[[Sequence], List[Any]]: def wrapper(states_list: Sequence[Any]) -> List[Any]: if not isinstance(states_list, (list, tuple)): - raise TypeError("Rule evaluated with invalid argument type...") + msg = "Rule evaluated with invalid argument type..." + raise TypeError(msg) return [func(x) for x in states_list if x] @@ -226,9 +242,9 @@ def __create_argument_builder( elif _is_node_quantum_number(qn_type): arg_builder = _ValueExtractor[NodeQuantumNumber](qn_type) else: + msg = f"Quantum number type {qn_type} is not supported. Has to be of type Edge/NodeQuantumNumber." raise TypeError( - f"Quantum number type {qn_type} is not supported." - " Has to be of type Edge/NodeQuantumNumber." + msg ) if is_list: @@ -246,12 +262,13 @@ def register_rule(self, rule: Rule) -> Tuple[Callable, Callable]: rule_annotations = [] rule_func_signature = inspect.signature(rule) if not rule_func_signature.return_annotation: - raise TypeError(f"missing return type annotation for rule {str(rule)}") + msg = f"missing return type annotation for rule {rule!s}" + raise TypeError(msg) for par in rule_func_signature.parameters.values(): if not par.annotation: + msg = f"missing type annotations for argument {par.name} of rule {rule!s}" raise TypeError( - f"missing type annotations for argument {par.name}" - f" of rule {str(rule)}" + msg ) rule_annotations.append(par.annotation) @@ -259,7 +276,8 @@ def register_rule(self, rule: Rule) -> Tuple[Callable, Callable]: try: self.__verify(rule_annotations) except TypeError as exception: - raise TypeError(f"rule {str(rule)}: {str(exception)}") from exception + msg = f"rule {rule!s}: {exception!s}" + raise TypeError(msg) from exception # then create requirements check function and add to dict self.__rule_to_requirements_check[rule] = self.__create_requirements_check( @@ -283,7 +301,8 @@ def get_required_qns( rule_annotations = [] for par in inspect.signature(rule).parameters.values(): if not par.annotation: - raise TypeError(f"missing type annotations for rule {str(rule)}") + msg = f"missing type annotations for rule {rule!s}" + raise TypeError(msg) rule_annotations.append(par.annotation) required_edge_qns: Set[Type[EdgeQuantumNumber]] = set() diff --git a/src/qrules/combinatorics.py b/src/qrules/combinatorics.py index fe6dd116..f6f484c9 100644 --- a/src/qrules/combinatorics.py +++ b/src/qrules/combinatorics.py @@ -9,13 +9,23 @@ import sys from collections import OrderedDict from copy import deepcopy -from typing import (Any, Callable, Dict, Iterable, List, Mapping, Optional, - Sequence, Set, Tuple, Union) +from typing import ( + Any, + Callable, + Dict, + Iterable, + List, + Mapping, + Optional, + Sequence, + Set, + Tuple, + Union, +) from qrules.particle import ParticleCollection, ParticleWithSpin from qrules.quantum_numbers import InteractionProperties, arange -from qrules.topology import (MutableTransition, Topology, - get_originating_node_list) +from qrules.topology import MutableTransition, Topology, get_originating_node_list if sys.version_info >= (3, 10): from typing import TypeAlias @@ -55,8 +65,9 @@ def __eq__(self, other: object) -> bool: self.initial_state == other.initial_state and self.final_state == other.final_state ) + msg = f"Cannot compare {type(self).__name__} with {type(other).__name__}" raise ValueError( - f"Cannot compare {type(self).__name__} with {type(other).__name__}" + msg ) def __repr__(self) -> str: @@ -89,10 +100,7 @@ def is_sublist( return False if sub_representation is None: return True - for group in sub_representation: - if group not in main_representation: - return False - return True + return all(group in main_representation for group in sub_representation) if isinstance(other, _KinematicRepresentation): return is_sublist(other.initial_state, self.initial_state) and is_sublist( @@ -101,12 +109,14 @@ def is_sublist( if isinstance(other, list): for item in other: if not isinstance(item, list): + msg = "Comparison representation needs to be a list of lists" raise ValueError( - "Comparison representation needs to be a list of lists" + msg ) return is_sublist(other, self.final_state) + msg = f"Cannot compare {type(self).__name__} with {type(other).__name__}" raise ValueError( - f"Cannot compare {type(self).__name__} with {type(other).__name__}" + msg ) @@ -120,7 +130,8 @@ def ensure_nested_list( if any(not isinstance(item, list) for item in nested_list): nested_list = [nested_list] # type: ignore[assignment] if any(not isinstance(i, str) for lst in nested_list for i in lst): - raise ValueError("Not all grouping items are particle names") + msg = "Not all grouping items are particle names" + raise ValueError(msg) return nested_list # type: ignore[return-value] @@ -208,8 +219,9 @@ def __create_states_with_spin_projections( particle_db: ParticleCollection, ) -> Dict[int, StateWithSpins]: if len(edge_ids) != len(state_definitions): + msg = "Number of state definitions is not same as number of edge IDs" raise ValueError( - "Number of state definitions is not same as number of edge IDs" + msg ) states = __safe_set_spin_projections(state_definitions, particle_db) return dict(zip(edge_ids, states)) @@ -224,9 +236,8 @@ def fill_spin_projections(state: StateDefinition) -> StateWithSpins: particle_name = state particle = particle_db[particle_name] spin_projections = set(arange(-particle.spin, particle.spin + 1, 1.0)) - if particle.mass == 0.0: - if 0.0 in spin_projections: - spin_projections.remove(0.0) + if particle.mass == 0.0 and 0.0 in spin_projections: + spin_projections.remove(0.0) return particle_name, sorted(spin_projections) return state @@ -353,7 +364,8 @@ def match_external_edges( graphs: "List[MutableTransition[ParticleWithSpin, InteractionProperties]]", ) -> None: if not isinstance(graphs, list): - raise TypeError("graphs argument is not of type list") + msg = "graphs argument is not of type list" + raise TypeError(msg) if not graphs: return ref_graph_id = 0 @@ -389,8 +401,9 @@ def _match_external_edge_ids( # pylint: disable=too-many-locals del ref_mapping_copy[key_2] break if len(ref_mapping_copy) != 0: + msg = "Unable to match graphs, due to inherent graph structure mismatch" raise ValueError( - "Unable to match graphs, due to inherent graph structure mismatch" + msg ) swappings = _calculate_swappings(edge_ids_mapping) for edge_id1, edge_id2 in swappings.items(): @@ -418,7 +431,8 @@ def perform_external_edge_identical_particle_combinatorics( particles, which do not enter or exit the same node allow for combinatorics! """ if not isinstance(graph, MutableTransition): - raise TypeError(f"graph argument is not of type {MutableTransition.__name__}") + msg = f"graph argument is not of type {MutableTransition.__name__}" + raise TypeError(msg) temp_new_graphs = _external_edge_identical_particle_combinatorics( graph, __get_final_state_edge_ids ) diff --git a/src/qrules/conservation_rules.py b/src/qrules/conservation_rules.py index 1c745664..88985b45 100644 --- a/src/qrules/conservation_rules.py +++ b/src/qrules/conservation_rules.py @@ -417,19 +417,18 @@ def _check_particles_identical( return False return True - if len(ingoing_parities) == 1: - if _check_particles_identical(outgoing_edge_qns): - if _is_boson(outgoing_edge_qns[0].spin_magnitude): - # we have a boson, check if parity of mother is even - parity = ingoing_parities[0] - if parity == -1: - # if its odd then return False - return False - else: - # its fermion - parity = ingoing_parities[0] - if parity == 1: - return False + if len(ingoing_parities) == 1 and _check_particles_identical(outgoing_edge_qns): + if _is_boson(outgoing_edge_qns[0].spin_magnitude): + # we have a boson, check if parity of mother is even + parity = ingoing_parities[0] + if parity == -1: + # if its odd then return False + return False + else: + # its fermion + parity = ingoing_parities[0] + if parity == 1: + return False return True @@ -452,12 +451,10 @@ def _is_clebsch_gordan_coefficient_zero( if (j_1 == j_2 and m_1 == m_2) or (m_1 == 0.0 and m_2 == 0.0): if abs(mag - j_1 - j_2) % 2 == 1: return True - if j_1 == mag and m_1 == -proj: - if abs(j_2 - j_1 - mag) % 2 == 1: - return True - if j_2 == mag and m_2 == -proj: - if abs(j_1 - j_2 - mag) % 2 == 1: - return True + if j_1 == mag and m_1 == -proj and abs(j_2 - j_1 - mag) % 2 == 1: + return True + if j_2 == mag and m_2 == -proj and abs(j_1 - j_2 - mag) % 2 == 1: + return True return False @@ -635,9 +632,7 @@ def isospin_conservation( Also checks :math:`I_{1,z} + I_{2,z} = I_z` and if Clebsch-Gordan coefficients are all 0. """ - if not sum(x.isospin_projection for x in ingoing_isospins) == sum( - x.isospin_projection for x in outgoing_isospins - ): + if sum(x.isospin_projection for x in ingoing_isospins) != sum(x.isospin_projection for x in outgoing_isospins): return False if not all(isospin_validity(x) for x in ingoing_isospins + outgoing_isospins): return False @@ -832,9 +827,9 @@ class GellMannNishijimaInput: def gellmann_nishijima(edge_qns: GellMannNishijimaInput) -> bool: - r"""Check the Gell-Mann–Nishijima formula. + r"""Check the Gell-Mann-Nishijima formula. - `Gell-Mann–Nishijima formula + `Gell-Mann-Nishijima formula `_: .. math:: diff --git a/src/qrules/io/__init__.py b/src/qrules/io/__init__.py index 29b7f887..edcadfbe 100644 --- a/src/qrules/io/__init__.py +++ b/src/qrules/io/__init__.py @@ -25,14 +25,15 @@ def asdict(instance: object) -> dict: return _dict.from_particle_collection(instance) if attrs.has(type(instance)): return _dict.from_attrs_decorated(instance) + msg = f"No conversion to dict available for class {type(instance).__name__}" raise NotImplementedError( - f"No conversion to dict available for class {type(instance).__name__}" + msg ) def fromdict(definition: dict) -> object: keys = set(definition.keys()) - if __REQUIRED_PARTICLE_FIELDS <= keys: + if keys >= __REQUIRED_PARTICLE_FIELDS: return _dict.build_particle(definition) if keys == {"particles"}: return _dict.build_particle_collection(definition) @@ -42,7 +43,8 @@ def fromdict(definition: dict) -> object: return _dict.build_transition(definition) if keys == __REQUIRED_TOPOLOGY_FIELDS: return _dict.build_topology(definition) - raise NotImplementedError(f"Could not determine type from keys {keys}") + msg = f"Could not determine type from keys {keys}" + raise NotImplementedError(msg) __REQUIRED_PARTICLE_FIELDS = { @@ -129,7 +131,8 @@ def load(filename: str) -> object: if file_extension in ["yaml", "yml"]: definition = yaml.load(stream, Loader=yaml.SafeLoader) return fromdict(definition) - raise NotImplementedError(f'No loader defined for file type "{file_extension}"') + msg = f'No loader defined for file type "{file_extension}"' + raise NotImplementedError(msg) class _IncreasedIndent(yaml.Dumper): @@ -167,16 +170,17 @@ def write(instance: object, filename: str) -> None: with open(filename, "w") as stream: stream.write(output_str) return - raise NotImplementedError(f'No writer defined for file type "{file_extension}"') + msg = f'No writer defined for file type "{file_extension}"' + raise NotImplementedError(msg) def _get_file_extension(filename: str) -> str: path = Path(filename) extension = path.suffix.lower() if not extension: - raise ValueError(f'No file extension in file name "{filename}"') - extension = extension[1:] - return extension + msg = f'No file extension in file name "{filename}"' + raise ValueError(msg) + return extension[1:] class JSONSetEncoder(json.JSONEncoder): diff --git a/src/qrules/io/_dict.py b/src/qrules/io/_dict.py index 4f875aed..b0015e6a 100644 --- a/src/qrules/io/_dict.py +++ b/src/qrules/io/_dict.py @@ -98,7 +98,7 @@ def build_state(definition: Any) -> State: particle = build_particle(definition["particle"]) spin_projection = float(definition["spin_projection"]) return State(particle, spin_projection) - raise NotImplementedError() + raise NotImplementedError def build_topology(definition: dict) -> Topology: diff --git a/src/qrules/io/_dot.py b/src/qrules/io/_dot.py index 033d56ae..ebc6e576 100644 --- a/src/qrules/io/_dot.py +++ b/src/qrules/io/_dot.py @@ -18,8 +18,7 @@ from qrules.particle import Particle, ParticleWithSpin, Spin from qrules.quantum_numbers import InteractionProperties, _to_fraction from qrules.solving import EdgeSettings, NodeSettings, QNProblemSet, QNResult -from qrules.topology import (FrozenTransition, MutableTransition, Topology, - Transition) +from qrules.topology import FrozenTransition, MutableTransition, Topology, Transition from qrules.transition import ProblemSet, ReactionInfo, State _LOGGER = logging.getLogger(__name__) @@ -30,9 +29,11 @@ def _check_booleans( ) -> None: # pylint: disable=unused-argument if instance.strip_spin and instance.collapse_graphs: - raise ValueError("Cannot both strip spin and collapse graphs") + msg = "Cannot both strip spin and collapse graphs" + raise ValueError(msg) if instance.collapse_graphs and instance.render_node: - raise ValueError("Collapsed graphs cannot be rendered with node properties") + msg = "Collapsed graphs cannot be rendered with node properties" + raise ValueError(msg) def _create_default_figure_style(style: Optional[Dict[str, Any]]) -> Dict[str, Any]: @@ -89,7 +90,8 @@ def _render(self, obj: Any) -> List[str]: return self._render_multiple_transitions(obj) if isinstance(obj, (ProblemSet, QNProblemSet, Topology, Transition)): return self._render_transition(obj) - raise NotImplementedError(f"No DOT rendering for type {type(obj).__name__}") + msg = f"No DOT rendering for type {type(obj).__name__}" + raise NotImplementedError(msg) def _render_multiple_transitions(self, obj: Iterable) -> List[str]: if self.collapse_graphs: @@ -125,7 +127,8 @@ def _render_transition( rendered_graph = obj topology = obj else: - raise NotImplementedError(f"Cannot render {type(obj).__name__} as dot") + msg = f"Cannot render {type(obj).__name__} as dot" + raise NotImplementedError(msg) for edge_id in topology.incoming_edge_ids | topology.outgoing_edge_ids: if edge_id in topology.incoming_edge_ids: render = self.render_initial_state_id @@ -377,7 +380,8 @@ def _(settings: Union[EdgeSettings, NodeSettings]) -> str: def __extract_priority(description: str) -> int: matches = re.match(r".* \- ([0-9]+)$", description) if matches is None: - raise ValueError(f"{description} does not contain a priority number") + msg = f"{description} does not contain a priority number" + raise ValueError(msg) priority = matches[1] return int(priority) @@ -463,8 +467,9 @@ def __to_particle(state: Any) -> Particle: return state.particle if isinstance(state, tuple) and len(state) == 2: return state[0] + msg = f"Cannot extract a particle from type {type(state).__name__}" raise NotImplementedError( - f"Cannot extract a particle from type {type(state).__name__}" + msg ) diff --git a/src/qrules/particle.py b/src/qrules/particle.py index e3919329..c4ee584b 100644 --- a/src/qrules/particle.py +++ b/src/qrules/particle.py @@ -16,8 +16,19 @@ from difflib import get_close_matches from functools import total_ordering from math import copysign -from typing import (TYPE_CHECKING, Any, Callable, Dict, Iterable, Iterator, - List, Optional, SupportsFloat, Tuple, Union) +from typing import ( + TYPE_CHECKING, + Any, + Callable, + Dict, + Iterable, + Iterator, + List, + Optional, + SupportsFloat, + Tuple, + Union, +) import attrs from attrs import field, frozen @@ -52,23 +63,24 @@ class Spin: def __attrs_post_init__(self) -> None: if self.magnitude % 0.5 != 0.0: + msg = f"Spin magnitude {self.magnitude} has to be a multitude of 0.5" raise ValueError( - f"Spin magnitude {self.magnitude} has to be a multitude of 0.5" + msg ) if abs(self.projection) > self.magnitude: if self.magnitude < 0.0: + msg = f"Spin magnitude has to be positive, but is {self.magnitude}" raise ValueError( - f"Spin magnitude has to be positive, but is {self.magnitude}" + msg ) + msg = f"Absolute value of spin projection cannot be larger than its magnitude:\n abs({self.projection}) > {self.magnitude}" raise ValueError( - "Absolute value of spin projection cannot be larger than its " - "magnitude:\n" - f" abs({self.projection}) > {self.magnitude}" + msg ) if not (self.projection - self.magnitude).is_integer(): + msg = f"{type(self).__name__}{self.magnitude, self.projection}: (projection - magnitude) should be integer" raise ValueError( - f"{type(self).__name__}{(self.magnitude, self.projection)}:" - " (projection - magnitude) should be integer" + msg ) def __eq__(self, other: object) -> bool: @@ -167,17 +179,9 @@ def __attrs_post_init__(self) -> None: tau_lepton_number=self.tau_lepton_number, ) ): + msg = f"Cannot construct particle {self.name}, because its quantum numbers don't agree with the Gell-Mann-Nishijima formula:\n Q[{self.charge}] != Iz[{self.isospin.projection if self.isospin else 0}] + 1/2 (B[{self.baryon_number}] + S[{self.strangeness}] + C[{self.charmness}] + B'[{self.bottomness}] + T[{self.strangeness}])" raise ValueError( - f"Cannot construct particle {self.name}, because its quantum" - " numbers don't agree with the Gell-Mann–Nishijima formula:\n" - f" Q[{self.charge}] != " - f"Iz[{self.isospin.projection if self.isospin else 0}] + 1/2 " - f"(B[{self.baryon_number}] + " - f" S[{self.strangeness}] + " - f" C[{self.charmness}] +" - f" B'[{self.bottomness}] +" - f" T[{self.strangeness}]" - ")" + msg ) def __gt__(self, other: Any) -> bool: @@ -193,8 +197,9 @@ def sorting_key(particle: Particle) -> tuple: ) return sorting_key(self) > sorting_key(other) + msg = f"Cannot compare {type(self).__name__} with {type(other).__name__}" raise NotImplementedError( - f"Cannot compare {type(self).__name__} with {type(other).__name__}" + msg ) def __neg__(self) -> "Particle": @@ -231,8 +236,7 @@ def _get_name_root(name: str) -> str: """Strip a string (particularly the `.Particle.name`) of specifications.""" name_root = name name_root = re.sub(r"\(.+\)", "", name_root) - name_root = re.sub(r"[\*\+\-~\d']", "", name_root) - return name_root + return re.sub(r"[\*\+\-~\d']", "", name_root) ParticleWithSpin = Tuple[Particle, float] @@ -254,13 +258,15 @@ def __contains__(self, instance: object) -> bool: return instance in self.__particles.values() if isinstance(instance, int): return instance in self.__pid_to_name - raise NotImplementedError(f"Cannot search for type {type(instance).__name__}") + msg = f"Cannot search for type {type(instance).__name__}" + raise NotImplementedError(msg) def __eq__(self, other: object) -> bool: if isinstance(other, abc.Iterable): return set(self) == set(other) + msg = f"Cannot compare {type(self).__name__} with {type(self).__name__}" raise NotImplementedError( - f"Cannot compare {type(self).__name__} with {type(self).__name__}" + msg ) def __getitem__(self, particle_name: str) -> Particle: @@ -294,7 +300,8 @@ def __iadd__( elif isinstance(other, ParticleCollection): self.update(other) else: - raise NotImplementedError(f"Cannot add {type(other).__name__}") + msg = f"Cannot add {type(other).__name__}" + raise NotImplementedError(msg) return self def __repr__(self) -> str: @@ -321,10 +328,10 @@ def add(self, value: Particle) -> None: if value in self.__particles.values(): equivalent_particles = {p for p in self if p == value} equivalent_particle = next(iter(equivalent_particles)) + msg = f'Added particle "{value.name}" is equivalent to existing particle "{equivalent_particle.name}"' raise ValueError( ( - f'Added particle "{value.name}" is equivalent to ' - f'existing particle "{equivalent_particle.name}"' + msg ), ) if value.name in self.__particles: @@ -344,8 +351,9 @@ def discard(self, value: Union[Particle, str]) -> None: elif isinstance(value, str): particle_name = value else: + msg = f"Cannot discard something of type {type(value).__name__}" raise NotImplementedError( - f"Cannot discard something of type {type(value).__name__}" + msg ) del self.__pid_to_name[self[particle_name].pid] del self.__particles[particle_name] @@ -357,11 +365,13 @@ def find(self, search_term: Union[int, str]) -> Particle: return self.__getitem__(particle_name) # pylint: disable=C2801 if isinstance(search_term, int): if search_term not in self.__pid_to_name: - raise KeyError(f"No particle with PID {search_term}") + msg = f"No particle with PID {search_term}" + raise KeyError(msg) particle_name = self.__pid_to_name[search_term] return self.__getitem__(particle_name) # pylint: disable=C2801 + msg = f"Cannot search for a search term of type {type(search_term)}" raise NotImplementedError( - f"Cannot search for a search term of type {type(search_term)}" + msg ) def filter( # noqa: A003 @@ -386,9 +396,9 @@ def filter( # noqa: A003 def update(self, other: Iterable[Particle]) -> None: if not isinstance(other, abc.Iterable): + msg = f"Cannot update {type(self).__name__} from non-iterable class {type(self).__name__}" raise TypeError( - f"Cannot update {type(self).__name__} from " - f"non-iterable class {type(self).__name__}" + msg ) for particle in other: self.add(particle) @@ -537,7 +547,8 @@ def convert_mass_width(value: Optional[float]) -> float: return float(value) / 1e3 # https://github.com/ComPWA/qrules/issues/14 if pdg_particle.charge is None: - raise ValueError(f"PDG instance has no charge:\n{pdg_particle}") + msg = f"PDG instance has no charge:\n{pdg_particle}" + raise ValueError(msg) quark_numbers = __compute_quark_numbers(pdg_particle) lepton_numbers = __compute_lepton_numbers(pdg_particle) if pdg_particle.pdgid.is_lepton: # convention: C(fermion)=+1 @@ -622,7 +633,8 @@ def __create_isospin(pdg_particle: "PdgDatabase") -> Optional[Spin]: def __isospin_projection_from_pdg(pdg_particle: "PdgDatabase") -> float: if pdg_particle.charge is None: - raise ValueError(f"PDG instance has no charge:\n{pdg_particle}") + msg = f"PDG instance has no charge:\n{pdg_particle}" + raise ValueError(msg) if "qq" in pdg_particle.quarks.lower(): strangeness, charmness, bottomness, topness = __compute_quark_numbers( pdg_particle @@ -639,7 +651,8 @@ def __isospin_projection_from_pdg(pdg_particle: "PdgDatabase") -> float: projection -= quark_content.count("U") + quark_content.count("d") projection *= 0.5 if pdg_particle.I is not None and not (pdg_particle.I - projection).is_integer(): - raise ValueError(f"Cannot have isospin {(pdg_particle.I, projection)}") + msg = f"Cannot have isospin {pdg_particle.I, projection}" + raise ValueError(msg) return projection diff --git a/src/qrules/quantum_numbers.py b/src/qrules/quantum_numbers.py index f99cf907..9e6bfe4f 100644 --- a/src/qrules/quantum_numbers.py +++ b/src/qrules/quantum_numbers.py @@ -20,12 +20,13 @@ def _check_plus_minus(_: Any, __: attrs.Attribute, value: Any) -> None: if not isinstance(value, int): + msg = f"Input for {Parity.__name__} has to be of type {int.__name__}, not {type(value).__name__}" raise TypeError( - f"Input for {Parity.__name__} has to be of type {int.__name__}," - f" not {type(value).__name__}" + msg ) if value not in [-1, +1]: - raise ValueError(f"Parity can only be +1 or -1, not {value}") + msg = f"Parity can only be +1 or -1, not {value}" + raise ValueError(msg) @total_ordering diff --git a/src/qrules/settings.py b/src/qrules/settings.py index 4e9f04bf..809df873 100644 --- a/src/qrules/settings.py +++ b/src/qrules/settings.py @@ -13,28 +13,34 @@ from os.path import dirname, join, realpath from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union -from qrules.conservation_rules import (BaryonNumberConservation, - BottomnessConservation, - ChargeConservation, CharmConservation, - ConservationRule, - EdgeQNConservationRule, - ElectronLNConservation, - GraphElementRule, MassConservation, - MuonLNConservation, - StrangenessConservation, - TauLNConservation, - c_parity_conservation, - clebsch_gordan_helicity_to_canonical, - g_parity_conservation, - gellmann_nishijima, - helicity_conservation, - identical_particle_symmetrization, - isospin_conservation, isospin_validity, - ls_spin_validity, parity_conservation, - parity_conservation_helicity, - spin_conservation, - spin_magnitude_conservation, - spin_validity) +from qrules.conservation_rules import ( + BaryonNumberConservation, + BottomnessConservation, + ChargeConservation, + CharmConservation, + ConservationRule, + EdgeQNConservationRule, + ElectronLNConservation, + GraphElementRule, + MassConservation, + MuonLNConservation, + StrangenessConservation, + TauLNConservation, + c_parity_conservation, + clebsch_gordan_helicity_to_canonical, + g_parity_conservation, + gellmann_nishijima, + helicity_conservation, + identical_particle_symmetrization, + isospin_conservation, + isospin_validity, + ls_spin_validity, + parity_conservation, + parity_conservation_helicity, + spin_conservation, + spin_magnitude_conservation, + spin_validity, +) from qrules.particle import Particle, ParticleCollection from qrules.quantum_numbers import EdgeQuantumNumbers as EdgeQN from qrules.quantum_numbers import NodeQuantumNumbers as NodeQN @@ -96,7 +102,8 @@ def from_str(description: str) -> "InteractionType": return InteractionType.STRONG if description_lower.startswith("w"): return InteractionType.WEAK - raise ValueError(f'Could not determine interaction type from "{description}"') + msg = f'Could not determine interaction type from "{description}"' + raise ValueError(msg) DEFAULT_INTERACTION_TYPES = [ @@ -284,9 +291,9 @@ def get(cls) -> int: def set(cls, n_cores: Optional[int]) -> None: # noqa: A003 """Set the number of threads; use `None` for all available cores.""" if n_cores is not None and not isinstance(n_cores, int): + msg = "Can only set the number of cores to an integer or to None (meaning all available cores)" raise TypeError( - "Can only set the number of cores to an integer or to None" - " (meaning all available cores)" + msg ) cls.__n_cores = n_cores @@ -307,9 +314,11 @@ def __positive_int_domain( def _halves_domain(start: float, stop: float) -> List[float]: if start % 0.5 != 0.0: - raise ValueError(f"Start value {start} needs to be multiple of 0.5") + msg = f"Start value {start} needs to be multiple of 0.5" + raise ValueError(msg) if stop % 0.5 != 0.0: - raise ValueError(f"Stop value {stop} needs to be multiple of 0.5") + msg = f"Stop value {stop} needs to be multiple of 0.5" + raise ValueError(msg) return [ int(v) if v.is_integer() else v for v in arange(start, stop + 0.25, delta=0.5) ] diff --git a/src/qrules/solving.py b/src/qrules/solving.py index 867788e3..180689ad 100644 --- a/src/qrules/solving.py +++ b/src/qrules/solving.py @@ -14,21 +14,37 @@ from abc import ABC, abstractmethod from collections import defaultdict from copy import copy -from typing import (Any, Callable, Dict, Generic, Iterable, List, Optional, - Set, Tuple, Type, TypeVar, Union) +from typing import ( + Any, + Callable, + Dict, + Generic, + Iterable, + List, + Optional, + Set, + Tuple, + Type, + TypeVar, + Union, +) import attrs from attrs import define, field, frozen -from constraint import (BacktrackingSolver, Constraint, Problem, Unassigned, - Variable) +from constraint import BacktrackingSolver, Constraint, Problem, Unassigned, Variable from qrules._implementers import implement_pretty_repr -from .argument_handling import (GraphEdgePropertyMap, GraphElementRule, - GraphNodePropertyMap, Rule, - RuleArgumentHandler, Scalar, get_required_qns) -from .quantum_numbers import (EdgeQuantumNumber, EdgeQuantumNumbers, - NodeQuantumNumber) +from .argument_handling import ( + GraphEdgePropertyMap, + GraphElementRule, + GraphNodePropertyMap, + Rule, + RuleArgumentHandler, + Scalar, + get_required_qns, +) +from .quantum_numbers import EdgeQuantumNumber, EdgeQuantumNumbers, NodeQuantumNumber from .topology import MutableTransition, Topology if sys.version_info >= (3, 10): @@ -163,10 +179,10 @@ class QNResult: def __attrs_post_init__(self) -> None: if self.solutions and (self.violated_node_rules or self.violated_edge_rules): + msg = f"Invalid {type(self).__name__}! Found {len(self.solutions)} solutions, but also violated rules." raise ValueError( ( - f"Invalid {type(self).__name__}! Found" - f" {len(self.solutions)} solutions, but also violated rules." + msg ), self.violated_node_rules, self.violated_edge_rules, @@ -819,7 +835,8 @@ def __init__( scoresheet: Callable[[bool], None], ) -> None: if not callable(rule): - raise TypeError("rule argument has to be a callable") + msg = "rule argument has to be a callable" + raise TypeError(msg) self.__rule = rule ( self.__check_rule_requirements, @@ -939,7 +956,8 @@ def __init__( score_callback: Callable[[bool], None], ) -> None: if not callable(rule): - raise TypeError("rule argument has to be a callable") + msg = "rule argument has to be a callable" + raise TypeError(msg) self.__rule = rule ( self.__check_rule_requirements, @@ -1067,8 +1085,7 @@ def __update_variable_lists( elif qn_type in self.__node_qns: self.__node_qns[qn_type] = value # type: ignore[index] else: + msg = f"The variable with name {qn_type.__name__} and a graph element index of {index} does not appear in the variable mapping" raise ValueError( - f"The variable with name {qn_type.__name__} and a graph" - f" element index of {index} does not appear in the" - " variable mapping" + msg ) diff --git a/src/qrules/topology.py b/src/qrules/topology.py index fdd112fd..61282636 100644 --- a/src/qrules/topology.py +++ b/src/qrules/topology.py @@ -22,10 +22,27 @@ from abc import ABC, abstractmethod from collections import abc from functools import total_ordering -from typing import (TYPE_CHECKING, Any, Callable, Dict, FrozenSet, Generic, - ItemsView, Iterable, Iterator, KeysView, List, Mapping, - Optional, Sequence, Set, Tuple, TypeVar, ValuesView, - overload) +from typing import ( + TYPE_CHECKING, + Any, + Callable, + Dict, + FrozenSet, + Generic, + ItemsView, + Iterable, + Iterator, + KeysView, + List, + Mapping, + Optional, + Sequence, + Set, + Tuple, + TypeVar, + ValuesView, + overload, +) import attrs from attrs import define, field, frozen @@ -112,9 +129,9 @@ def __gt__(self, other: Any) -> bool: sorted_other = _convert_mapping_to_sorted_tuple(other) return sorted_self > sorted_other + msg = f"Can only compare {type(self).__name__} with a mapping, not with {type(other).__name__}" raise NotImplementedError( - f"Can only compare {type(self).__name__} with a mapping," - f" not with {type(other).__name__}" + msg ) def __hash__(self) -> int: @@ -177,7 +194,6 @@ def _to_topology_edges(inst: Mapping[int, Edge]) -> FrozenDict[int, Edge]: @implement_pretty_repr @frozen(order=True) class Topology: - # noqa: D416 """Directed Feynman-like graph without edge or node properties. A `Topology` is **directed** in the sense that its edges are ingoing and outgoing to @@ -252,14 +268,17 @@ def __attrs_post_init__(self) -> None: inter = sorted(set(self.edges) - set(incoming) - set(outgoing)) expected = list(range(-len(incoming), 0)) if sorted(incoming) != expected: - raise ValueError(f"Incoming edge IDs should be {expected}, not {incoming}.") + msg = f"Incoming edge IDs should be {expected}, not {incoming}." + raise ValueError(msg) n_out = len(outgoing) expected = list(range(0, n_out)) if sorted(outgoing) != expected: - raise ValueError(f"Outgoing edge IDs should be {expected}, not {outgoing}.") + msg = f"Outgoing edge IDs should be {expected}, not {outgoing}." + raise ValueError(msg) expected = list(range(n_out, n_out + len(inter))) if sorted(inter) != expected: - raise ValueError(f"Intermediate edge IDs should be {expected}.") + msg = f"Intermediate edge IDs should be {expected}." + raise ValueError(msg) object.__setattr__(self, "incoming_edge_ids", frozenset(incoming)) object.__setattr__(self, "outgoing_edge_ids", frozenset(outgoing)) object.__setattr__(self, "intermediate_edge_ids", frozenset(inter)) @@ -269,13 +288,14 @@ def __verify(self) -> None: for edge_id, edge in self.edges.items(): connected_nodes = edge.get_connected_nodes() if not connected_nodes: + msg = f"Edge nr. {edge_id} is not connected to any other node ({edge})" raise ValueError( - f"Edge nr. {edge_id} is not connected to any other node ({edge})" + msg ) if not connected_nodes <= self.nodes: + msg = f"{edge} (ID: {edge_id}) has non-existing node IDs.\nAvailable node IDs: {self.nodes}" raise ValueError( - f"{edge} (ID: {edge_id}) has non-existing node IDs.\n" - f"Available node IDs: {self.nodes}" + msg ) self.__check_isolated_nodes() @@ -285,7 +305,8 @@ def __check_isolated_nodes(self) -> None: for node_id in self.nodes: surrounding_nodes = self.__get_surrounding_nodes(node_id) if not surrounding_nodes: - raise ValueError(f"Node {node_id} is not connected to any other node") + msg = f"Node {node_id} is not connected to any other node" + raise ValueError(msg) def __get_surrounding_nodes(self, node_id: int) -> Set[int]: surrounding_nodes = set() @@ -438,7 +459,8 @@ def add_node(self, node_id: int) -> None: ValueError: if :code:`node_id` already exists in `nodes`. """ if node_id in self.nodes: - raise ValueError(f"Node nr. {node_id} already exists") + msg = f"Node nr. {node_id} already exists" + raise ValueError(msg) self.nodes.add(node_id) def add_edges(self, edge_ids: Iterable[int]) -> None: @@ -449,7 +471,8 @@ def add_edges(self, edge_ids: Iterable[int]) -> None: """ for edge_id in edge_ids: if edge_id in self.edges: - raise ValueError(f"Edge nr. {edge_id} already exists") + msg = f"Edge nr. {edge_id} already exists" + raise ValueError(msg) self.edges[edge_id] = Edge() def attach_edges_to_node_ingoing( @@ -470,11 +493,12 @@ def attach_edges_to_node_ingoing( # first check if the ingoing edges are all available for edge_id in ingoing_edge_ids: if edge_id not in self.edges: - raise ValueError(f"Edge nr. {edge_id} does not exist") + msg = f"Edge nr. {edge_id} does not exist" + raise ValueError(msg) if self.edges[edge_id].ending_node_id is not None: + msg = f"Edge nr. {edge_id} is already ingoing to node {self.edges[edge_id].ending_node_id}" raise ValueError( - f"Edge nr. {edge_id} is already ingoing to" - f" node {self.edges[edge_id].ending_node_id}" + msg ) # update the newly connected edges @@ -491,11 +515,12 @@ def attach_edges_to_node_outgoing( # first check if the ingoing edges are all available for edge_id in outgoing_edge_ids: if edge_id not in self.edges: - raise ValueError(f"Edge nr. {edge_id} does not exist") + msg = f"Edge nr. {edge_id} does not exist" + raise ValueError(msg) if self.edges[edge_id].originating_node_id is not None: + msg = f"Edge nr. {edge_id} is already outgoing from node {self.edges[edge_id].originating_node_id}" raise ValueError( - f"Edge nr. {edge_id} is already outgoing from" - f" node {self.edges[edge_id].originating_node_id}" + msg ) # update the edges @@ -553,9 +578,11 @@ class InteractionNode: def __attrs_post_init__(self) -> None: if self.number_of_ingoing_edges < 1: - raise ValueError("Number of incoming edges has to be larger than 0") + msg = "Number of incoming edges has to be larger than 0" + raise ValueError(msg) if self.number_of_outgoing_edges < 1: - raise ValueError("Number of outgoing edges has to be larger than 0") + msg = "Number of outgoing edges has to be larger than 0" + raise ValueError(msg) class SimpleStateTransitionTopologyBuilder: @@ -567,7 +594,8 @@ class SimpleStateTransitionTopologyBuilder: def __init__(self, interaction_node_set: Iterable[InteractionNode]) -> None: if not isinstance(interaction_node_set, list): - raise TypeError("interaction_node_set must be a list") + msg = "interaction_node_set must be a list" + raise TypeError(msg) self.interaction_node_set: List[InteractionNode] = list(interaction_node_set) def build( @@ -576,9 +604,11 @@ def build( number_of_initial_edges = int(number_of_initial_edges) number_of_final_edges = int(number_of_final_edges) if number_of_initial_edges < 1: - raise ValueError("number_of_initial_edges has to be larger than 0") + msg = "number_of_initial_edges has to be larger than 0" + raise ValueError(msg) if number_of_final_edges < 1: - raise ValueError("number_of_final_edges has to be larger than 0") + msg = "number_of_final_edges has to be larger than 0" + raise ValueError(msg) _LOGGER.info("building topology graphs...") # result list @@ -671,7 +701,8 @@ def create_isobar_topologies( True """ if number_of_final_states < 2: - raise ValueError("At least two final states required for an isobar decay") + msg = "At least two final states required for an isobar decay" + raise ValueError(msg) builder = SimpleStateTransitionTopologyBuilder([InteractionNode(1, 2)]) topologies = builder.build( number_of_initial_edges=1, @@ -724,11 +755,12 @@ def create_n_body_topology( ) decay_name = f"{n_in} to {n_out}" if len(topologies) == 0: - raise ValueError(f"Could not create n-body decay for {decay_name}") + msg = f"Could not create n-body decay for {decay_name}" + raise ValueError(msg) if len(topologies) > 1: - raise RuntimeError(f"Several n-body decays for {decay_name}") - topology = next(iter(topologies)) - return topology + msg = f"Several n-body decays for {decay_name}" + raise RuntimeError(msg) + return next(iter(topologies)) def _attach_node_to_edges( @@ -953,9 +985,9 @@ def _assert_all_defined(items: Iterable, properties: Iterable) -> None: existing = set(items) defined = set(properties) if existing & defined != existing: + msg = f"Some items have no property assigned to them. Available items: {existing}, items with property: {defined}" raise ValueError( - "Some items have no property assigned to them." - f" Available items: {existing}, items with property: {defined}" + msg ) @@ -965,7 +997,7 @@ def _assert_not_overdefined(items: Iterable, properties: Iterable) -> None: defined = set(properties) over_defined = defined - existing if over_defined: + msg = f"Properties have been defined for items that don't exist. Available items: {existing}, over-defined: {over_defined}" raise ValueError( - "Properties have been defined for items that don't exist." - f" Available items: {existing}, over-defined: {over_defined}" + msg ) diff --git a/src/qrules/transition.py b/src/qrules/transition.py index 3919be33..1b06d71a 100644 --- a/src/qrules/transition.py +++ b/src/qrules/transition.py @@ -7,8 +7,19 @@ from copy import copy, deepcopy from enum import Enum, auto from multiprocessing import Pool -from typing import (TYPE_CHECKING, Dict, Iterable, List, Optional, Sequence, - Set, Tuple, Type, Union, overload) +from typing import ( + TYPE_CHECKING, + Dict, + Iterable, + List, + Optional, + Sequence, + Set, + Tuple, + Type, + Union, + overload, +) import attrs from attrs import define, field, frozen @@ -17,33 +28,68 @@ from qrules._implementers import implement_pretty_repr -from ._system_control import (GammaCheck, InteractionDeterminator, LeptonCheck, - create_edge_properties, - create_interaction_properties, - create_node_properties, filter_interaction_types, - find_particle, remove_duplicate_solutions) -from .combinatorics import (InitialFacts, StateDefinition, - create_initial_facts, ensure_nested_list, - match_external_edges, - permutate_topology_kinematically) -from .particle import (Particle, ParticleCollection, ParticleWithSpin, - _to_float, load_pdg) -from .quantum_numbers import (EdgeQuantumNumber, EdgeQuantumNumbers, - InteractionProperties, NodeQuantumNumber, - NodeQuantumNumbers) -from .settings import (DEFAULT_INTERACTION_TYPES, InteractionType, - NumberOfThreads, create_interaction_settings) -from .solving import (CSPSolver, EdgeSettings, GraphEdgePropertyMap, - GraphSettings, NodeSettings, QNProblemSet, QNResult) -from .topology import (FrozenDict, MutableTransition, Topology, - create_isobar_topologies, create_n_body_topology) +from ._system_control import ( + GammaCheck, + InteractionDeterminator, + LeptonCheck, + create_edge_properties, + create_interaction_properties, + create_node_properties, + filter_interaction_types, + find_particle, + remove_duplicate_solutions, +) +from .combinatorics import ( + InitialFacts, + StateDefinition, + create_initial_facts, + ensure_nested_list, + match_external_edges, + permutate_topology_kinematically, +) +from .particle import ( + Particle, + ParticleCollection, + ParticleWithSpin, + _to_float, + load_pdg, +) +from .quantum_numbers import ( + EdgeQuantumNumber, + EdgeQuantumNumbers, + InteractionProperties, + NodeQuantumNumber, + NodeQuantumNumbers, +) +from .settings import ( + DEFAULT_INTERACTION_TYPES, + InteractionType, + NumberOfThreads, + create_interaction_settings, +) +from .solving import ( + CSPSolver, + EdgeSettings, + GraphEdgePropertyMap, + GraphSettings, + NodeSettings, + QNProblemSet, + QNResult, +) +from .topology import ( + FrozenDict, + MutableTransition, + Topology, + create_isobar_topologies, + create_n_body_topology, +) if sys.version_info >= (3, 10): from typing import TypeAlias else: from typing_extensions import TypeAlias if TYPE_CHECKING: - from .topology import FrozenTransition # noqa: F401 + from .topology import FrozenTransition _LOGGER = logging.getLogger(__name__) @@ -111,10 +157,10 @@ def __attrs_post_init__(self) -> None: self.execution_info.violated_node_rules or self.execution_info.violated_edge_rules ): + msg = f"Invalid {type(self).__name__}! Found {len(self.solutions)} solutions, but also violated rules." raise ValueError( ( - f"Invalid {type(self).__name__}! Found" - f" {len(self.solutions)} solutions, but also violated rules." + msg ), self.execution_info.violated_node_rules, self.execution_info.violated_edge_rules, @@ -130,8 +176,7 @@ def extend( self.execution_info.extend(other.execution_info, intersect_violations) -if sys.version_info >= (3, 7): - attrs.resolve_types(_SolutionContainer, globals(), locals()) # type: ignore[type-var] +attrs.resolve_types(_SolutionContainer, globals(), locals()) # type: ignore[type-var] @implement_pretty_repr @@ -194,9 +239,7 @@ def __init__( # pylint: disable=too-many-arguments, too-many-branches, too-many final_state: Sequence[StateDefinition], particle_db: Optional[ParticleCollection] = None, allowed_intermediate_particles: Optional[List[str]] = None, - interaction_type_settings: Dict[ - InteractionType, Tuple[EdgeSettings, NodeSettings] - ] = None, # type: ignore[assignment] + interaction_type_settings: Optional[Dict[InteractionType, Tuple[EdgeSettings, NodeSettings]]] = None, # type: ignore[assignment] formalism: str = "helicity", topology_building: str = "isobar", solving_mode: SolvingMode = SolvingMode.FAST, @@ -217,9 +260,9 @@ def __init__( # pylint: disable=too-many-arguments, too-many-branches, too-many "canonical", ] if formalism not in allowed_formalisms: + msg = f'Formalism "{formalism}" not implemented. Use one of {allowed_formalisms} instead.' raise NotImplementedError( - f'Formalism "{formalism}" not implemented.' - f" Use one of {allowed_formalisms} instead." + msg ) self.__formalism = str(formalism) self.__particles = ParticleCollection() @@ -298,9 +341,9 @@ def set_allowed_intermediate_particles( # pylint: disable=cell-var-from-loop matches = _filter_by_name_pattern(self.__particles, pattern, regex) if len(matches) == 0: + msg = f'Could not find any matches for allowed intermediate particle pattern "{pattern}"' raise LookupError( - "Could not find any matches for allowed intermediate" - f' particle pattern "{pattern}"' + msg ) selected_particles.update(matches) self.__allowed_intermediate_states = [ @@ -317,7 +360,8 @@ def add_final_state_grouping( self, fs_group: Union[List[str], List[List[str]]] ) -> None: if not isinstance(fs_group, list): - raise ValueError("The final state grouping has to be of type list.") + msg = "The final state grouping has to be of type list." + raise ValueError(msg) if len(fs_group) > 0: if self.final_state_groupings is None: self.final_state_groupings = [] @@ -349,12 +393,14 @@ def set_allowed_interaction_types( # verify order for allowed_types in allowed_interaction_types: if not isinstance(allowed_types, InteractionType): + msg = "Allowed interaction types must be of type[InteractionType]" raise TypeError( - "Allowed interaction types must be of type[InteractionType]" + msg ) if allowed_types not in self.interaction_type_settings: _LOGGER.info(self.interaction_type_settings.keys()) - raise ValueError(f"Interaction {allowed_types} not found in settings") + msg = f"Interaction {allowed_types} not found in settings" + raise ValueError(msg) allowed_interaction_types = list(allowed_interaction_types) if node_id is None: self.__allowed_interaction_types = allowed_interaction_types @@ -534,7 +580,8 @@ def find_solutions( + ", ".join(not_executed_rules) ) if not final_solutions: - raise ValueError("No solutions were found") + msg = "No solutions were found" + raise ValueError(msg) match_external_edges(final_solutions) final_solutions = [ diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index 45ef8c92..7079aff5 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -35,7 +35,7 @@ def two_to_three_decay() -> Topology: / \ \ e-2 e0 e1 """ - topology = Topology( + return Topology( nodes={0, 1, 2}, edges={ -2: Edge(None, 0), @@ -47,4 +47,3 @@ def two_to_three_decay() -> Topology: 4: Edge(1, 2), }, ) - return topology diff --git a/tests/unit/conservation_rules/test_c_parity.py b/tests/unit/conservation_rules/test_c_parity.py index 16c8d344..095de29f 100644 --- a/tests/unit/conservation_rules/test_c_parity.py +++ b/tests/unit/conservation_rules/test_c_parity.py @@ -2,8 +2,11 @@ import pytest -from qrules.conservation_rules import (CParityEdgeInput, CParityNodeInput, - c_parity_conservation) +from qrules.conservation_rules import ( + CParityEdgeInput, + CParityNodeInput, + c_parity_conservation, +) from qrules.quantum_numbers import Parity diff --git a/tests/unit/conservation_rules/test_clebsch_gordan.py b/tests/unit/conservation_rules/test_clebsch_gordan.py index ae9fd959..b3a6f5b0 100644 --- a/tests/unit/conservation_rules/test_clebsch_gordan.py +++ b/tests/unit/conservation_rules/test_clebsch_gordan.py @@ -2,10 +2,14 @@ import pytest -from qrules.conservation_rules import (IsoSpinEdgeInput, SpinEdgeInput, - SpinNodeInput, - clebsch_gordan_helicity_to_canonical, - isospin_conservation, spin_conservation) +from qrules.conservation_rules import ( + IsoSpinEdgeInput, + SpinEdgeInput, + SpinNodeInput, + clebsch_gordan_helicity_to_canonical, + isospin_conservation, + spin_conservation, +) from qrules.particle import Spin from .test_spin import __create_two_body_decay_spin_data diff --git a/tests/unit/conservation_rules/test_duck_typing.py b/tests/unit/conservation_rules/test_duck_typing.py index f8ec8352..9063aa1f 100644 --- a/tests/unit/conservation_rules/test_duck_typing.py +++ b/tests/unit/conservation_rules/test_duck_typing.py @@ -12,8 +12,11 @@ from qrules import conservation_rules from qrules.particle import Particle -from qrules.quantum_numbers import (EdgeQuantumNumbers, InteractionProperties, - NodeQuantumNumbers) +from qrules.quantum_numbers import ( + EdgeQuantumNumbers, + InteractionProperties, + NodeQuantumNumbers, +) RULE_INPUT_CLASSES = { getattr(conservation_rules, name) diff --git a/tests/unit/conservation_rules/test_g_parity.py b/tests/unit/conservation_rules/test_g_parity.py index 949350d6..4c10fd2f 100644 --- a/tests/unit/conservation_rules/test_g_parity.py +++ b/tests/unit/conservation_rules/test_g_parity.py @@ -2,8 +2,11 @@ import pytest -from qrules.conservation_rules import (GParityEdgeInput, GParityNodeInput, - g_parity_conservation) +from qrules.conservation_rules import ( + GParityEdgeInput, + GParityNodeInput, + g_parity_conservation, +) from qrules.quantum_numbers import Parity diff --git a/tests/unit/conservation_rules/test_gellmann_nishijima.py b/tests/unit/conservation_rules/test_gellmann_nishijima.py index bc756efa..9b718e77 100644 --- a/tests/unit/conservation_rules/test_gellmann_nishijima.py +++ b/tests/unit/conservation_rules/test_gellmann_nishijima.py @@ -2,8 +2,7 @@ import pytest -from qrules.conservation_rules import (GellMannNishijimaInput, - gellmann_nishijima) +from qrules.conservation_rules import GellMannNishijimaInput, gellmann_nishijima @pytest.mark.parametrize( diff --git a/tests/unit/conservation_rules/test_identical_particle_symmetrization.py b/tests/unit/conservation_rules/test_identical_particle_symmetrization.py index 2e5218a3..20d1b5c9 100644 --- a/tests/unit/conservation_rules/test_identical_particle_symmetrization.py +++ b/tests/unit/conservation_rules/test_identical_particle_symmetrization.py @@ -1,7 +1,9 @@ import pytest -from qrules.conservation_rules import (IdenticalParticleSymmetryOutEdgeInput, - identical_particle_symmetrization) +from qrules.conservation_rules import ( + IdenticalParticleSymmetryOutEdgeInput, + identical_particle_symmetrization, +) from qrules.quantum_numbers import Parity diff --git a/tests/unit/conservation_rules/test_parity_conservation.py b/tests/unit/conservation_rules/test_parity_conservation.py index f96b2898..3d0dde31 100644 --- a/tests/unit/conservation_rules/test_parity_conservation.py +++ b/tests/unit/conservation_rules/test_parity_conservation.py @@ -2,9 +2,11 @@ import pytest -from qrules.conservation_rules import (HelicityParityEdgeInput, - parity_conservation, - parity_conservation_helicity) +from qrules.conservation_rules import ( + HelicityParityEdgeInput, + parity_conservation, + parity_conservation_helicity, +) from qrules.quantum_numbers import NodeQuantumNumbers, Parity diff --git a/tests/unit/conservation_rules/test_spin.py b/tests/unit/conservation_rules/test_spin.py index 91c2cbb2..9338f2a0 100644 --- a/tests/unit/conservation_rules/test_spin.py +++ b/tests/unit/conservation_rules/test_spin.py @@ -2,9 +2,12 @@ import pytest -from qrules.conservation_rules import (SpinEdgeInput, SpinNodeInput, - spin_conservation, - spin_magnitude_conservation) +from qrules.conservation_rules import ( + SpinEdgeInput, + SpinNodeInput, + spin_conservation, + spin_magnitude_conservation, +) from qrules.particle import Spin _SpinRuleInputType = Tuple[List[SpinEdgeInput], List[SpinEdgeInput], SpinNodeInput] diff --git a/tests/unit/io/test_dot.py b/tests/unit/io/test_dot.py index 215d14f0..8ff439d2 100644 --- a/tests/unit/io/test_dot.py +++ b/tests/unit/io/test_dot.py @@ -3,11 +3,14 @@ import qrules from qrules import io -from qrules.io._dot import (_collapse_graphs, _get_particle_graphs, - _strip_projections) +from qrules.io._dot import _collapse_graphs, _get_particle_graphs, _strip_projections from qrules.particle import Particle, ParticleCollection -from qrules.topology import (Edge, Topology, create_isobar_topologies, - create_n_body_topology) +from qrules.topology import ( + Edge, + Topology, + create_isobar_topologies, + create_n_body_topology, +) from qrules.transition import ReactionInfo diff --git a/tests/unit/io/test_io.py b/tests/unit/io/test_io.py index 458a2de8..8bc97ec5 100644 --- a/tests/unit/io/test_io.py +++ b/tests/unit/io/test_io.py @@ -4,8 +4,12 @@ from qrules import io from qrules.particle import Particle, ParticleCollection -from qrules.topology import (FrozenTransition, Topology, - create_isobar_topologies, create_n_body_topology) +from qrules.topology import ( + FrozenTransition, + Topology, + create_isobar_topologies, + create_n_body_topology, +) from qrules.transition import ReactionInfo diff --git a/tests/unit/test_combinatorics.py b/tests/unit/test_combinatorics.py index 254532bf..3c0edcfc 100644 --- a/tests/unit/test_combinatorics.py +++ b/tests/unit/test_combinatorics.py @@ -3,19 +3,21 @@ import pytest -from qrules.combinatorics import (_generate_kinematic_permutations, - _get_kinematic_representation, - _KinematicRepresentation, - _permutate_outer_edges, create_initial_facts, - permutate_topology_kinematically) +from qrules.combinatorics import ( + _generate_kinematic_permutations, + _get_kinematic_representation, + _KinematicRepresentation, + _permutate_outer_edges, + create_initial_facts, + permutate_topology_kinematically, +) from qrules.topology import Topology, create_isobar_topologies @pytest.fixture(scope="session") def three_body_decay() -> Topology: topologies = create_isobar_topologies(3) - topology = next(iter(topologies)) - return topology + return next(iter(topologies)) def test_create_initial_facts(three_body_decay, particle_database): diff --git a/tests/unit/test_particle.py b/tests/unit/test_particle.py index 21879e3a..3af3dc31 100644 --- a/tests/unit/test_particle.py +++ b/tests/unit/test_particle.py @@ -8,9 +8,15 @@ from attrs.exceptions import FrozenInstanceError from IPython.lib.pretty import pretty -from qrules.particle import (Particle, ParticleCollection, Spin, - _get_name_root, create_antiparticle, - create_particle) +from qrules.particle import ( + Particle, + ParticleCollection, + Spin, + _get_name_root, + create_antiparticle, + create_particle, +) + # For eval tests from qrules.quantum_numbers import Parity # noqa: F401 @@ -49,9 +55,9 @@ def test_exceptions(self): ) with pytest.raises(FrozenInstanceError): test_state.charge = 1 # type: ignore[misc] - with pytest.raises(ValueError, match=r"Fails Gell-Mann–Nishijima"): + with pytest.raises(ValueError, match=r"Fails Gell-Mann-Nishijima"): Particle( - name="Fails Gell-Mann–Nishijima formula", + name="Fails Gell-Mann-Nishijima formula", pid=666, mass=0.0, spin=1, diff --git a/tests/unit/test_quantum_numbers.py b/tests/unit/test_quantum_numbers.py index f4b7dc74..bcb36031 100644 --- a/tests/unit/test_quantum_numbers.py +++ b/tests/unit/test_quantum_numbers.py @@ -26,7 +26,7 @@ def test_comparison(self): assert pos >= neg assert pos >= 0 assert neg <= 0 - assert 0 < pos + assert pos > 0 def test_hash(self): neg = Parity(-1) diff --git a/tests/unit/test_settings.py b/tests/unit/test_settings.py index 7720296d..a8bb739e 100644 --- a/tests/unit/test_settings.py +++ b/tests/unit/test_settings.py @@ -2,8 +2,13 @@ from qrules.particle import ParticleCollection from qrules.quantum_numbers import EdgeQuantumNumbers as EdgeQN -from qrules.settings import (InteractionType, _create_domains, _halves_domain, - _int_domain, create_interaction_settings) +from qrules.settings import ( + InteractionType, + _create_domains, + _halves_domain, + _int_domain, + create_interaction_settings, +) class TestInteractionType: diff --git a/tests/unit/test_system_control.py b/tests/unit/test_system_control.py index a69a2567..1c2d1307 100644 --- a/tests/unit/test_system_control.py +++ b/tests/unit/test_system_control.py @@ -7,15 +7,24 @@ import pytest from qrules import InteractionType, ProblemSet, StateTransitionManager -from qrules._system_control import (create_edge_properties, filter_graphs, - remove_duplicate_solutions, - require_interaction_property) +from qrules._system_control import ( + create_edge_properties, + filter_graphs, + remove_duplicate_solutions, + require_interaction_property, +) from qrules.combinatorics import ( - ParticleWithSpin, _create_edge_id_particle_mapping, match_external_edges, - perform_external_edge_identical_particle_combinatorics) + ParticleWithSpin, + _create_edge_id_particle_mapping, + match_external_edges, + perform_external_edge_identical_particle_combinatorics, +) from qrules.particle import Particle -from qrules.quantum_numbers import (EdgeQuantumNumbers, InteractionProperties, - NodeQuantumNumbers) +from qrules.quantum_numbers import ( + EdgeQuantumNumbers, + InteractionProperties, + NodeQuantumNumbers, +) from qrules.topology import Edge, MutableTransition, Topology @@ -208,8 +217,7 @@ def make_ls_test_graph(angular_momentum_magnitude, coupled_spin_magnitude, parti ) } states: Dict[int, ParticleWithSpin] = {-1: (particle, 0)} - graph = MutableTransition(topology, states, interactions) # type: ignore[arg-type,var-annotated] - return graph + return MutableTransition(topology, states, interactions) # type: ignore[arg-type,var-annotated] def make_ls_test_graph_scrambled( @@ -226,8 +234,7 @@ def make_ls_test_graph_scrambled( ) } states: Dict[int, ParticleWithSpin] = {-1: (particle, 0)} - graph = MutableTransition(topology, states, interactions) # type: ignore[arg-type,var-annotated] - return graph + return MutableTransition(topology, states, interactions) # type: ignore[arg-type,var-annotated] class TestSolutionFilter: diff --git a/tests/unit/test_topology.py b/tests/unit/test_topology.py index 70c5d744..4d5cc2f6 100644 --- a/tests/unit/test_topology.py +++ b/tests/unit/test_topology.py @@ -6,11 +6,16 @@ from attrs.exceptions import FrozenInstanceError from IPython.lib.pretty import pretty -from qrules.topology import (Edge, FrozenDict, InteractionNode, # noqa: F401 - MutableTopology, - SimpleStateTransitionTopologyBuilder, Topology, - create_isobar_topologies, create_n_body_topology, - get_originating_node_list) +from qrules.topology import ( + Edge, + InteractionNode, + MutableTopology, + SimpleStateTransitionTopologyBuilder, + Topology, + create_isobar_topologies, + create_n_body_topology, + get_originating_node_list, +) class TestEdge: diff --git a/tests/unit/test_transition.py b/tests/unit/test_transition.py index a5a44ef5..a22a619e 100644 --- a/tests/unit/test_transition.py +++ b/tests/unit/test_transition.py @@ -5,12 +5,12 @@ import pytest from IPython.lib.pretty import pretty -from qrules.particle import (Parity, Particle, # noqa: F401 - ParticleCollection, Spin) +from qrules.particle import Parity, Particle, ParticleCollection, Spin # noqa: F401 from qrules.quantum_numbers import InteractionProperties # noqa: F401 from qrules.settings import InteractionType -from qrules.topology import (Edge, FrozenDict, FrozenTransition, # noqa: F401 - MutableTransition, Topology) +from qrules.topology import ( + FrozenTransition, + ) from qrules.transition import ReactionInfo, State, StateTransitionManager From be647c0fba47ce7000c1a8b3a405b73d3414e54a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 4 Jul 2023 09:04:21 +0000 Subject: [PATCH 10/47] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/qrules/__init__.py | 4 +- src/qrules/_implementers.py | 4 +- src/qrules/_system_control.py | 11 +++--- src/qrules/argument_handling.py | 14 ++++--- src/qrules/combinatorics.py | 20 +++------- src/qrules/conservation_rules.py | 4 +- src/qrules/io/__init__.py | 4 +- src/qrules/io/_dot.py | 4 +- src/qrules/particle.py | 65 +++++++++++++++----------------- src/qrules/quantum_numbers.py | 7 ++-- src/qrules/settings.py | 7 ++-- src/qrules/solving.py | 16 ++++---- src/qrules/topology.py | 46 +++++++++++----------- src/qrules/transition.py | 27 ++++++------- tests/unit/test_transition.py | 2 +- 15 files changed, 113 insertions(+), 122 deletions(-) diff --git a/src/qrules/__init__.py b/src/qrules/__init__.py index 1c1c8cd1..3c5db457 100644 --- a/src/qrules/__init__.py +++ b/src/qrules/__init__.py @@ -148,9 +148,7 @@ def check_pure_edge_rules() -> None: if edge_check_result.violated_edge_rules: msg = f"Some edges violate {edge_check_result.violated_edge_rules.values()}" - raise ValueError( - msg - ) + raise ValueError(msg) def check_edge_qn_conservation() -> Set[FrozenSet[str]]: """Check if edge quantum numbers are conserved. diff --git a/src/qrules/_implementers.py b/src/qrules/_implementers.py index 10e373c0..b7f8c3d4 100644 --- a/src/qrules/_implementers.py +++ b/src/qrules/_implementers.py @@ -17,9 +17,7 @@ def implement_pretty_repr( """Implement a pretty :code:`repr` in a class decorated by `attrs`.""" if not attrs.has(decorated_class): msg = "Can only implement a pretty repr for a class created with attrs" - raise TypeError( - msg - ) + raise TypeError(msg) def repr_pretty(self: Any, p: "PrettyPrinter", cycle: bool) -> None: class_name = type(self).__name__ diff --git a/src/qrules/_system_control.py b/src/qrules/_system_control.py index f8334f55..61777d8d 100644 --- a/src/qrules/_system_control.py +++ b/src/qrules/_system_control.py @@ -71,10 +71,11 @@ def create_node_properties( if qn_name in node_qn_mapping: property_map[node_qn_mapping[qn_name]] = value else: - msg = f"Missmatch between InteractionProperties and NodeQuantumNumbers. NodeQuantumNumbers does not define {qn_name}" - raise TypeError( - msg + msg = ( + "Missmatch between InteractionProperties and NodeQuantumNumbers." + f" NodeQuantumNumbers does not define {qn_name}" ) + raise TypeError(msg) return property_map @@ -101,9 +102,7 @@ def find_particle( spin_projection = state.get(EdgeQuantumNumbers.spin_projection) if spin_projection is None: msg = f"{GraphEdgePropertyMap.__name__} does not contain a spin projection" - raise ValueError( - msg - ) + raise ValueError(msg) return particle, spin_projection diff --git a/src/qrules/argument_handling.py b/src/qrules/argument_handling.py index 58d3023c..fdb425dc 100644 --- a/src/qrules/argument_handling.py +++ b/src/qrules/argument_handling.py @@ -242,10 +242,11 @@ def __create_argument_builder( elif _is_node_quantum_number(qn_type): arg_builder = _ValueExtractor[NodeQuantumNumber](qn_type) else: - msg = f"Quantum number type {qn_type} is not supported. Has to be of type Edge/NodeQuantumNumber." - raise TypeError( - msg + msg = ( + f"Quantum number type {qn_type} is not supported. Has to be of" + " type Edge/NodeQuantumNumber." ) + raise TypeError(msg) if is_list: arg_builder = _sequence_arg_builder(arg_builder) @@ -266,10 +267,11 @@ def register_rule(self, rule: Rule) -> Tuple[Callable, Callable]: raise TypeError(msg) for par in rule_func_signature.parameters.values(): if not par.annotation: - msg = f"missing type annotations for argument {par.name} of rule {rule!s}" - raise TypeError( - msg + msg = ( + f"missing type annotations for argument {par.name} of rule" + f" {rule!s}" ) + raise TypeError(msg) rule_annotations.append(par.annotation) # check type annotations are legal diff --git a/src/qrules/combinatorics.py b/src/qrules/combinatorics.py index f6f484c9..0d467de2 100644 --- a/src/qrules/combinatorics.py +++ b/src/qrules/combinatorics.py @@ -66,9 +66,7 @@ def __eq__(self, other: object) -> bool: and self.final_state == other.final_state ) msg = f"Cannot compare {type(self).__name__} with {type(other).__name__}" - raise ValueError( - msg - ) + raise ValueError(msg) def __repr__(self) -> str: return ( @@ -110,14 +108,10 @@ def is_sublist( for item in other: if not isinstance(item, list): msg = "Comparison representation needs to be a list of lists" - raise ValueError( - msg - ) + raise ValueError(msg) return is_sublist(other, self.final_state) msg = f"Cannot compare {type(self).__name__} with {type(other).__name__}" - raise ValueError( - msg - ) + raise ValueError(msg) def _sort_nested(nested_list: List[List[str]]) -> List[List[str]]: @@ -220,9 +214,7 @@ def __create_states_with_spin_projections( ) -> Dict[int, StateWithSpins]: if len(edge_ids) != len(state_definitions): msg = "Number of state definitions is not same as number of edge IDs" - raise ValueError( - msg - ) + raise ValueError(msg) states = __safe_set_spin_projections(state_definitions, particle_db) return dict(zip(edge_ids, states)) @@ -402,9 +394,7 @@ def _match_external_edge_ids( # pylint: disable=too-many-locals break if len(ref_mapping_copy) != 0: msg = "Unable to match graphs, due to inherent graph structure mismatch" - raise ValueError( - msg - ) + raise ValueError(msg) swappings = _calculate_swappings(edge_ids_mapping) for edge_id1, edge_id2 in swappings.items(): graph.swap_edges(edge_id1, edge_id2) diff --git a/src/qrules/conservation_rules.py b/src/qrules/conservation_rules.py index 88985b45..661336a6 100644 --- a/src/qrules/conservation_rules.py +++ b/src/qrules/conservation_rules.py @@ -632,7 +632,9 @@ def isospin_conservation( Also checks :math:`I_{1,z} + I_{2,z} = I_z` and if Clebsch-Gordan coefficients are all 0. """ - if sum(x.isospin_projection for x in ingoing_isospins) != sum(x.isospin_projection for x in outgoing_isospins): + if sum(x.isospin_projection for x in ingoing_isospins) != sum( + x.isospin_projection for x in outgoing_isospins + ): return False if not all(isospin_validity(x) for x in ingoing_isospins + outgoing_isospins): return False diff --git a/src/qrules/io/__init__.py b/src/qrules/io/__init__.py index edcadfbe..d4ef19e7 100644 --- a/src/qrules/io/__init__.py +++ b/src/qrules/io/__init__.py @@ -26,9 +26,7 @@ def asdict(instance: object) -> dict: if attrs.has(type(instance)): return _dict.from_attrs_decorated(instance) msg = f"No conversion to dict available for class {type(instance).__name__}" - raise NotImplementedError( - msg - ) + raise NotImplementedError(msg) def fromdict(definition: dict) -> object: diff --git a/src/qrules/io/_dot.py b/src/qrules/io/_dot.py index ebc6e576..41a4b8dd 100644 --- a/src/qrules/io/_dot.py +++ b/src/qrules/io/_dot.py @@ -468,9 +468,7 @@ def __to_particle(state: Any) -> Particle: if isinstance(state, tuple) and len(state) == 2: return state[0] msg = f"Cannot extract a particle from type {type(state).__name__}" - raise NotImplementedError( - msg - ) + raise NotImplementedError(msg) def _collapse_graphs( diff --git a/src/qrules/particle.py b/src/qrules/particle.py index c4ee584b..93b4a360 100644 --- a/src/qrules/particle.py +++ b/src/qrules/particle.py @@ -64,24 +64,22 @@ class Spin: def __attrs_post_init__(self) -> None: if self.magnitude % 0.5 != 0.0: msg = f"Spin magnitude {self.magnitude} has to be a multitude of 0.5" - raise ValueError( - msg - ) + raise ValueError(msg) if abs(self.projection) > self.magnitude: if self.magnitude < 0.0: msg = f"Spin magnitude has to be positive, but is {self.magnitude}" - raise ValueError( - msg - ) - msg = f"Absolute value of spin projection cannot be larger than its magnitude:\n abs({self.projection}) > {self.magnitude}" - raise ValueError( - msg + raise ValueError(msg) + msg = ( + "Absolute value of spin projection cannot be larger than its" + f" magnitude:\n abs({self.projection}) > {self.magnitude}" ) + raise ValueError(msg) if not (self.projection - self.magnitude).is_integer(): - msg = f"{type(self).__name__}{self.magnitude, self.projection}: (projection - magnitude) should be integer" - raise ValueError( - msg + msg = ( + f"{type(self).__name__}{self.magnitude, self.projection}: (projection -" + " magnitude) should be integer" ) + raise ValueError(msg) def __eq__(self, other: object) -> bool: if isinstance(other, Spin): @@ -179,10 +177,15 @@ def __attrs_post_init__(self) -> None: tau_lepton_number=self.tau_lepton_number, ) ): - msg = f"Cannot construct particle {self.name}, because its quantum numbers don't agree with the Gell-Mann-Nishijima formula:\n Q[{self.charge}] != Iz[{self.isospin.projection if self.isospin else 0}] + 1/2 (B[{self.baryon_number}] + S[{self.strangeness}] + C[{self.charmness}] + B'[{self.bottomness}] + T[{self.strangeness}])" - raise ValueError( - msg + msg = ( + f"Cannot construct particle {self.name}, because its quantum numbers" + " don't agree with the Gell-Mann-Nishijima formula:\n " + f" Q[{self.charge}] !=" + f" Iz[{self.isospin.projection if self.isospin else 0}] + 1/2" + f" (B[{self.baryon_number}] + S[{self.strangeness}] + " + f" C[{self.charmness}] + B'[{self.bottomness}] + T[{self.strangeness}])" ) + raise ValueError(msg) def __gt__(self, other: Any) -> bool: if isinstance(other, Particle): @@ -198,9 +201,7 @@ def sorting_key(particle: Particle) -> tuple: return sorting_key(self) > sorting_key(other) msg = f"Cannot compare {type(self).__name__} with {type(other).__name__}" - raise NotImplementedError( - msg - ) + raise NotImplementedError(msg) def __neg__(self) -> "Particle": return create_antiparticle(self) @@ -265,9 +266,7 @@ def __eq__(self, other: object) -> bool: if isinstance(other, abc.Iterable): return set(self) == set(other) msg = f"Cannot compare {type(self).__name__} with {type(self).__name__}" - raise NotImplementedError( - msg - ) + raise NotImplementedError(msg) def __getitem__(self, particle_name: str) -> Particle: if particle_name in self.__particles: @@ -328,11 +327,12 @@ def add(self, value: Particle) -> None: if value in self.__particles.values(): equivalent_particles = {p for p in self if p == value} equivalent_particle = next(iter(equivalent_particles)) - msg = f'Added particle "{value.name}" is equivalent to existing particle "{equivalent_particle.name}"' + msg = ( + f'Added particle "{value.name}" is equivalent to existing particle' + f' "{equivalent_particle.name}"' + ) raise ValueError( - ( - msg - ), + (msg), ) if value.name in self.__particles: _LOGGER.warning(f'Overwriting particle with name "{value.name}"') @@ -352,9 +352,7 @@ def discard(self, value: Union[Particle, str]) -> None: particle_name = value else: msg = f"Cannot discard something of type {type(value).__name__}" - raise NotImplementedError( - msg - ) + raise NotImplementedError(msg) del self.__pid_to_name[self[particle_name].pid] del self.__particles[particle_name] @@ -370,9 +368,7 @@ def find(self, search_term: Union[int, str]) -> Particle: particle_name = self.__pid_to_name[search_term] return self.__getitem__(particle_name) # pylint: disable=C2801 msg = f"Cannot search for a search term of type {type(search_term)}" - raise NotImplementedError( - msg - ) + raise NotImplementedError(msg) def filter( # noqa: A003 self, function: Callable[[Particle], bool] @@ -396,10 +392,11 @@ def filter( # noqa: A003 def update(self, other: Iterable[Particle]) -> None: if not isinstance(other, abc.Iterable): - msg = f"Cannot update {type(self).__name__} from non-iterable class {type(self).__name__}" - raise TypeError( - msg + msg = ( + f"Cannot update {type(self).__name__} from non-iterable class" + f" {type(self).__name__}" ) + raise TypeError(msg) for particle in other: self.add(particle) diff --git a/src/qrules/quantum_numbers.py b/src/qrules/quantum_numbers.py index 9e6bfe4f..f0764f5e 100644 --- a/src/qrules/quantum_numbers.py +++ b/src/qrules/quantum_numbers.py @@ -20,10 +20,11 @@ def _check_plus_minus(_: Any, __: attrs.Attribute, value: Any) -> None: if not isinstance(value, int): - msg = f"Input for {Parity.__name__} has to be of type {int.__name__}, not {type(value).__name__}" - raise TypeError( - msg + msg = ( + f"Input for {Parity.__name__} has to be of type {int.__name__}, not" + f" {type(value).__name__}" ) + raise TypeError(msg) if value not in [-1, +1]: msg = f"Parity can only be +1 or -1, not {value}" raise ValueError(msg) diff --git a/src/qrules/settings.py b/src/qrules/settings.py index 809df873..7235f32f 100644 --- a/src/qrules/settings.py +++ b/src/qrules/settings.py @@ -291,10 +291,11 @@ def get(cls) -> int: def set(cls, n_cores: Optional[int]) -> None: # noqa: A003 """Set the number of threads; use `None` for all available cores.""" if n_cores is not None and not isinstance(n_cores, int): - msg = "Can only set the number of cores to an integer or to None (meaning all available cores)" - raise TypeError( - msg + msg = ( + "Can only set the number of cores to an integer or to None (meaning all" + " available cores)" ) + raise TypeError(msg) cls.__n_cores = n_cores diff --git a/src/qrules/solving.py b/src/qrules/solving.py index 180689ad..2892b077 100644 --- a/src/qrules/solving.py +++ b/src/qrules/solving.py @@ -179,11 +179,12 @@ class QNResult: def __attrs_post_init__(self) -> None: if self.solutions and (self.violated_node_rules or self.violated_edge_rules): - msg = f"Invalid {type(self).__name__}! Found {len(self.solutions)} solutions, but also violated rules." + msg = ( + f"Invalid {type(self).__name__}! Found {len(self.solutions)} solutions," + " but also violated rules." + ) raise ValueError( - ( - msg - ), + (msg), self.violated_node_rules, self.violated_edge_rules, ) @@ -1085,7 +1086,8 @@ def __update_variable_lists( elif qn_type in self.__node_qns: self.__node_qns[qn_type] = value # type: ignore[index] else: - msg = f"The variable with name {qn_type.__name__} and a graph element index of {index} does not appear in the variable mapping" - raise ValueError( - msg + msg = ( + f"The variable with name {qn_type.__name__} and a graph element" + f" index of {index} does not appear in the variable mapping" ) + raise ValueError(msg) diff --git a/src/qrules/topology.py b/src/qrules/topology.py index 61282636..20dc9bbb 100644 --- a/src/qrules/topology.py +++ b/src/qrules/topology.py @@ -129,10 +129,11 @@ def __gt__(self, other: Any) -> bool: sorted_other = _convert_mapping_to_sorted_tuple(other) return sorted_self > sorted_other - msg = f"Can only compare {type(self).__name__} with a mapping, not with {type(other).__name__}" - raise NotImplementedError( - msg + msg = ( + f"Can only compare {type(self).__name__} with a mapping, not with" + f" {type(other).__name__}" ) + raise NotImplementedError(msg) def __hash__(self) -> int: return self.__hash @@ -289,14 +290,13 @@ def __verify(self) -> None: connected_nodes = edge.get_connected_nodes() if not connected_nodes: msg = f"Edge nr. {edge_id} is not connected to any other node ({edge})" - raise ValueError( - msg - ) + raise ValueError(msg) if not connected_nodes <= self.nodes: - msg = f"{edge} (ID: {edge_id}) has non-existing node IDs.\nAvailable node IDs: {self.nodes}" - raise ValueError( - msg + msg = ( + f"{edge} (ID: {edge_id}) has non-existing node IDs.\nAvailable node" + f" IDs: {self.nodes}" ) + raise ValueError(msg) self.__check_isolated_nodes() def __check_isolated_nodes(self) -> None: @@ -496,10 +496,11 @@ def attach_edges_to_node_ingoing( msg = f"Edge nr. {edge_id} does not exist" raise ValueError(msg) if self.edges[edge_id].ending_node_id is not None: - msg = f"Edge nr. {edge_id} is already ingoing to node {self.edges[edge_id].ending_node_id}" - raise ValueError( - msg + msg = ( + f"Edge nr. {edge_id} is already ingoing to node" + f" {self.edges[edge_id].ending_node_id}" ) + raise ValueError(msg) # update the newly connected edges for edge_id in ingoing_edge_ids: @@ -518,10 +519,11 @@ def attach_edges_to_node_outgoing( msg = f"Edge nr. {edge_id} does not exist" raise ValueError(msg) if self.edges[edge_id].originating_node_id is not None: - msg = f"Edge nr. {edge_id} is already outgoing from node {self.edges[edge_id].originating_node_id}" - raise ValueError( - msg + msg = ( + f"Edge nr. {edge_id} is already outgoing from node" + f" {self.edges[edge_id].originating_node_id}" ) + raise ValueError(msg) # update the edges for edge_id in outgoing_edge_ids: @@ -985,10 +987,11 @@ def _assert_all_defined(items: Iterable, properties: Iterable) -> None: existing = set(items) defined = set(properties) if existing & defined != existing: - msg = f"Some items have no property assigned to them. Available items: {existing}, items with property: {defined}" - raise ValueError( - msg + msg = ( + "Some items have no property assigned to them. Available items:" + f" {existing}, items with property: {defined}" ) + raise ValueError(msg) # pyright: reportUnusedFunction=false @@ -997,7 +1000,8 @@ def _assert_not_overdefined(items: Iterable, properties: Iterable) -> None: defined = set(properties) over_defined = defined - existing if over_defined: - msg = f"Properties have been defined for items that don't exist. Available items: {existing}, over-defined: {over_defined}" - raise ValueError( - msg + msg = ( + "Properties have been defined for items that don't exist. Available items:" + f" {existing}, over-defined: {over_defined}" ) + raise ValueError(msg) diff --git a/src/qrules/transition.py b/src/qrules/transition.py index 1b06d71a..89eb66d4 100644 --- a/src/qrules/transition.py +++ b/src/qrules/transition.py @@ -157,11 +157,12 @@ def __attrs_post_init__(self) -> None: self.execution_info.violated_node_rules or self.execution_info.violated_edge_rules ): - msg = f"Invalid {type(self).__name__}! Found {len(self.solutions)} solutions, but also violated rules." + msg = ( + f"Invalid {type(self).__name__}! Found {len(self.solutions)} solutions," + " but also violated rules." + ) raise ValueError( - ( - msg - ), + (msg), self.execution_info.violated_node_rules, self.execution_info.violated_edge_rules, ) @@ -260,10 +261,11 @@ def __init__( # pylint: disable=too-many-arguments, too-many-branches, too-many "canonical", ] if formalism not in allowed_formalisms: - msg = f'Formalism "{formalism}" not implemented. Use one of {allowed_formalisms} instead.' - raise NotImplementedError( - msg + msg = ( + f'Formalism "{formalism}" not implemented. Use one of' + f" {allowed_formalisms} instead." ) + raise NotImplementedError(msg) self.__formalism = str(formalism) self.__particles = ParticleCollection() if particle_db is not None: @@ -341,10 +343,11 @@ def set_allowed_intermediate_particles( # pylint: disable=cell-var-from-loop matches = _filter_by_name_pattern(self.__particles, pattern, regex) if len(matches) == 0: - msg = f'Could not find any matches for allowed intermediate particle pattern "{pattern}"' - raise LookupError( - msg + msg = ( + "Could not find any matches for allowed intermediate particle" + f' pattern "{pattern}"' ) + raise LookupError(msg) selected_particles.update(matches) self.__allowed_intermediate_states = [ create_edge_properties(x) @@ -394,9 +397,7 @@ def set_allowed_interaction_types( for allowed_types in allowed_interaction_types: if not isinstance(allowed_types, InteractionType): msg = "Allowed interaction types must be of type[InteractionType]" - raise TypeError( - msg - ) + raise TypeError(msg) if allowed_types not in self.interaction_type_settings: _LOGGER.info(self.interaction_type_settings.keys()) msg = f"Interaction {allowed_types} not found in settings" diff --git a/tests/unit/test_transition.py b/tests/unit/test_transition.py index a22a619e..3c980913 100644 --- a/tests/unit/test_transition.py +++ b/tests/unit/test_transition.py @@ -10,7 +10,7 @@ from qrules.settings import InteractionType from qrules.topology import ( FrozenTransition, - ) +) from qrules.transition import ReactionInfo, State, StateTransitionManager From f9e38e249a415f6e9c4e86194b8822617beed79a Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 4 Jul 2023 11:42:03 +0200 Subject: [PATCH 11/47] FIX: do not install Ruff on Python 3.6 --- .pre-commit-config.yaml | 2 +- setup.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 86dc2045..03c2cd6c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,7 +36,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/ComPWA/repo-maintenance - rev: 0.0.185 + rev: 0.0.186 hooks: - id: check-dev-files args: diff --git a/setup.cfg b/setup.cfg index 91abbb76..6d284c52 100644 --- a/setup.cfg +++ b/setup.cfg @@ -96,7 +96,7 @@ mypy = types-setuptools lint = %(mypy)s - ruff + ruff; python_version >="3.7.0" sty = %(format)s %(lint)s From 73ab995b2421a8d8758fb84caa22da36a7b0bf60 Mon Sep 17 00:00:00 2001 From: GitHub Date: Tue, 4 Jul 2023 09:43:56 +0000 Subject: [PATCH 12/47] MAINT: update pip constraints and pre-commit --- .constraints/py3.10.txt | 24 +----------------------- .constraints/py3.11.txt | 24 +----------------------- .constraints/py3.6.txt | 8 -------- .constraints/py3.7.txt | 11 ++--------- .constraints/py3.8.txt | 24 +----------------------- .constraints/py3.9.txt | 24 +----------------------- 6 files changed, 6 insertions(+), 109 deletions(-) diff --git a/.constraints/py3.10.txt b/.constraints/py3.10.txt index f1f84661..b564be98 100644 --- a/.constraints/py3.10.txt +++ b/.constraints/py3.10.txt @@ -13,7 +13,6 @@ aquirdturtle-collapsible-headings==3.1.0 argon2-cffi==21.3.0 argon2-cffi-bindings==21.2.0 arrow==1.2.3 -astroid==2.15.5 asttokens==2.2.1 attrs==23.1.0 babel==2.12.1 @@ -35,7 +34,6 @@ debugpy==1.6.7 decorator==5.1.1 defusedxml==0.7.1 deprecated==1.2.14 -dill==0.3.6 distlib==0.3.6 docutils==0.19 exceptiongroup==1.1.2 @@ -43,17 +41,6 @@ execnet==1.9.0 executing==1.2.0 fastjsonschema==2.17.1 filelock==3.12.2 -flake8==6.0.0 ; python_version >= "3.8.0" -flake8-blind-except==0.2.1 ; python_version >= "3.8.0" -flake8-bugbear==23.6.5 ; python_version >= "3.8.0" -flake8-builtins==2.1.0 ; python_version >= "3.8.0" -flake8-comprehensions==3.13.0 ; python_version >= "3.8.0" -flake8-future-import==0.4.7 ; python_version >= "3.8.0" -flake8-plugin-utils==1.3.3 -flake8-pytest-style==1.7.2 ; python_version >= "3.8.0" -flake8-rst-docstrings==0.3.0 ; python_version >= "3.8.0" -flake8-type-ignore==0.1.0.post2 ; python_version >= "3.8.0" -flake8-use-fstring==1.4 ; python_version >= "3.8.0" fqdn==1.5.1 gprof2dot==2022.7.29 graphviz==0.20.1 @@ -69,7 +56,6 @@ ipython==8.14.0 ipython-genutils==0.2.0 ipywidgets==8.0.6 isoduration==20.11.0 -isort==5.12.0 jedi==0.18.2 jinja2==3.1.2 json5==0.9.14 @@ -91,12 +77,10 @@ jupyterlab-pygments==0.2.2 jupyterlab-server==2.23.0 jupyterlab-widgets==3.0.7 latexcodec==2.0.1 -lazy-object-proxy==1.9.0 livereload==2.6.3 markdown-it-py==2.2.0 markupsafe==2.1.3 matplotlib-inline==0.1.6 -mccabe==0.7.0 mdit-py-plugins==0.3.5 mdurl==0.1.2 mistune==3.0.1 @@ -119,7 +103,6 @@ pandocfilters==1.5.0 parso==0.8.3 particle==0.23.0 pathspec==0.11.1 -pep8-naming==0.13.3 ; python_version >= "3.8.0" pexpect==4.8.0 pickleshare==0.7.5 platformdirs==3.8.0 @@ -132,15 +115,11 @@ ptyprocess==0.7.0 pure-eval==0.2.2 pybtex==0.24.0 pybtex-docutils==1.0.2 -pycodestyle==2.10.0 pycparser==2.21 pydantic==1.10.10 pydata-sphinx-theme==0.13.3 -pydocstyle==6.3.0 pydot==1.4.2 -pyflakes==3.0.1 pygments==2.15.1 -pylint==2.17.4 pyparsing==3.1.0 pyproject-api==1.5.2 pyrsistent==0.19.3 @@ -154,9 +133,9 @@ python-json-logger==2.0.7 pyyaml==6.0 pyzmq==25.1.0 requests==2.31.0 -restructuredtext-lint==1.4.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 +ruff==0.0.276 ; python_version >= "3.7.0" send2trash==1.8.2 six==1.16.0 sniffio==1.3.0 @@ -186,7 +165,6 @@ tabulate==0.9.0 terminado==0.17.1 tinycss2==1.2.1 tomli==2.0.1 -tomlkit==0.11.8 tornado==6.3.2 tox==4.6.3 tqdm==4.65.0 diff --git a/.constraints/py3.11.txt b/.constraints/py3.11.txt index 6c53ec07..30f4bd1b 100644 --- a/.constraints/py3.11.txt +++ b/.constraints/py3.11.txt @@ -13,7 +13,6 @@ aquirdturtle-collapsible-headings==3.1.0 argon2-cffi==21.3.0 argon2-cffi-bindings==21.2.0 arrow==1.2.3 -astroid==2.15.5 asttokens==2.2.1 attrs==23.1.0 babel==2.12.1 @@ -35,24 +34,12 @@ debugpy==1.6.7 decorator==5.1.1 defusedxml==0.7.1 deprecated==1.2.14 -dill==0.3.6 distlib==0.3.6 docutils==0.19 execnet==1.9.0 executing==1.2.0 fastjsonschema==2.17.1 filelock==3.12.2 -flake8==6.0.0 ; python_version >= "3.8.0" -flake8-blind-except==0.2.1 ; python_version >= "3.8.0" -flake8-bugbear==23.6.5 ; python_version >= "3.8.0" -flake8-builtins==2.1.0 ; python_version >= "3.8.0" -flake8-comprehensions==3.13.0 ; python_version >= "3.8.0" -flake8-future-import==0.4.7 ; python_version >= "3.8.0" -flake8-plugin-utils==1.3.3 -flake8-pytest-style==1.7.2 ; python_version >= "3.8.0" -flake8-rst-docstrings==0.3.0 ; python_version >= "3.8.0" -flake8-type-ignore==0.1.0.post2 ; python_version >= "3.8.0" -flake8-use-fstring==1.4 ; python_version >= "3.8.0" fqdn==1.5.1 gprof2dot==2022.7.29 graphviz==0.20.1 @@ -68,7 +55,6 @@ ipython==8.14.0 ipython-genutils==0.2.0 ipywidgets==8.0.6 isoduration==20.11.0 -isort==5.12.0 jedi==0.18.2 jinja2==3.1.2 json5==0.9.14 @@ -90,12 +76,10 @@ jupyterlab-pygments==0.2.2 jupyterlab-server==2.23.0 jupyterlab-widgets==3.0.7 latexcodec==2.0.1 -lazy-object-proxy==1.9.0 livereload==2.6.3 markdown-it-py==2.2.0 markupsafe==2.1.3 matplotlib-inline==0.1.6 -mccabe==0.7.0 mdit-py-plugins==0.3.5 mdurl==0.1.2 mistune==3.0.1 @@ -118,7 +102,6 @@ pandocfilters==1.5.0 parso==0.8.3 particle==0.23.0 pathspec==0.11.1 -pep8-naming==0.13.3 ; python_version >= "3.8.0" pexpect==4.8.0 pickleshare==0.7.5 platformdirs==3.8.0 @@ -131,15 +114,11 @@ ptyprocess==0.7.0 pure-eval==0.2.2 pybtex==0.24.0 pybtex-docutils==1.0.2 -pycodestyle==2.10.0 pycparser==2.21 pydantic==1.10.10 pydata-sphinx-theme==0.13.3 -pydocstyle==6.3.0 pydot==1.4.2 -pyflakes==3.0.1 pygments==2.15.1 -pylint==2.17.4 pyparsing==3.1.0 pyproject-api==1.5.2 pyrsistent==0.19.3 @@ -153,9 +132,9 @@ python-json-logger==2.0.7 pyyaml==6.0 pyzmq==25.1.0 requests==2.31.0 -restructuredtext-lint==1.4.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 +ruff==0.0.276 ; python_version >= "3.7.0" send2trash==1.8.2 six==1.16.0 sniffio==1.3.0 @@ -184,7 +163,6 @@ stack-data==0.6.2 tabulate==0.9.0 terminado==0.17.1 tinycss2==1.2.1 -tomlkit==0.11.8 tornado==6.3.2 tox==4.6.3 tqdm==4.65.0 diff --git a/.constraints/py3.6.txt b/.constraints/py3.6.txt index 7baac389..be736f6b 100644 --- a/.constraints/py3.6.txt +++ b/.constraints/py3.6.txt @@ -9,7 +9,6 @@ anyio==3.6.2 aquirdturtle-collapsible-headings==3.1.0 argon2-cffi==21.3.0 argon2-cffi-bindings==21.2.0 -astroid==2.11.7 async-generator==1.10 attrs==21.4.0 babel==2.11.0 @@ -28,7 +27,6 @@ coverage==6.2 dataclasses==0.8 decorator==5.1.1 defusedxml==0.7.1 -dill==0.3.4 distlib==0.3.6 docutils==0.16 entrypoints==0.4 @@ -51,7 +49,6 @@ ipykernel==5.5.6 ipython==7.16.3 ipython-genutils==0.2.0 ipywidgets==7.7.5 -isort==5.10.1 jedi==0.17.2 jinja2==3.0.3 json5==0.9.14 @@ -68,11 +65,9 @@ jupyterlab-pygments==0.1.2 jupyterlab-server==2.10.3 jupyterlab-widgets==1.1.4 latexcodec==2.0.1 -lazy-object-proxy==1.7.1 livereload==2.6.3 markdown-it-py==1.1.0 markupsafe==2.0.1 -mccabe==0.7.0 mdit-py-plugins==0.2.8 mistune==0.8.4 mypy==0.971 @@ -107,10 +102,8 @@ pybtex-docutils==1.0.2 pycparser==2.21 pydantic==1.9.2 pydata-sphinx-theme==0.7.2 -pydocstyle==6.3.0 pydot==1.4.2 pygments==2.14.0 -pylint==2.13.9 pyparsing==3.1.0 pyrsistent==0.18.0 pytest==7.0.1 @@ -171,7 +164,6 @@ webencodings==0.5.1 websocket-client==1.3.1 wheel==0.37.1 widgetsnbextension==3.6.4 -wrapt==1.15.0 zipp==3.6.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 7c8e4e8b..7efa8f84 100644 --- a/.constraints/py3.7.txt +++ b/.constraints/py3.7.txt @@ -13,7 +13,6 @@ aquirdturtle-collapsible-headings==3.1.0 argon2-cffi==21.3.0 argon2-cffi-bindings==21.2.0 arrow==1.2.3 -astroid==2.15.5 attrs==23.1.0 babel==2.12.1 backcall==0.2.0 @@ -32,7 +31,6 @@ debugpy==1.6.7 decorator==5.1.1 defusedxml==0.7.1 deprecated==1.2.14 -dill==0.3.6 distlib==0.3.6 docutils==0.19 entrypoints==0.4 @@ -48,7 +46,7 @@ hepunits==2.3.2 identify==2.5.24 idna==3.4 imagesize==1.4.1 -importlib-metadata==4.13.0 ; python_version < "3.8.0" +importlib-metadata==6.7.0 ; python_version < "3.8.0" importlib-resources==5.12.0 iniconfig==2.0.0 ipykernel==6.16.2 @@ -56,7 +54,6 @@ ipython==7.34.0 ipython-genutils==0.2.0 ipywidgets==8.0.6 isoduration==20.11.0 -isort==5.11.5 jedi==0.18.2 jinja2==3.1.2 json5==0.9.14 @@ -77,12 +74,10 @@ jupyterlab-pygments==0.2.2 jupyterlab-server==2.23.0 jupyterlab-widgets==3.0.7 latexcodec==2.0.1 -lazy-object-proxy==1.9.0 livereload==2.6.3 markdown-it-py==2.2.0 markupsafe==2.1.3 matplotlib-inline==0.1.6 -mccabe==0.7.0 mdit-py-plugins==0.3.5 mdurl==0.1.2 mistune==3.0.1 @@ -120,10 +115,8 @@ pybtex-docutils==1.0.2 pycparser==2.21 pydantic==1.10.10 pydata-sphinx-theme==0.13.3 -pydocstyle==6.3.0 pydot==1.4.2 pygments==2.15.1 -pylint==2.17.4 pyparsing==3.1.0 pyrsistent==0.19.3 pytest==7.4.0 @@ -139,6 +132,7 @@ pyzmq==25.1.0 requests==2.31.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 +ruff==0.0.276 ; python_version >= "3.7.0" send2trash==1.8.2 six==1.16.0 sniffio==1.3.0 @@ -167,7 +161,6 @@ tabulate==0.9.0 terminado==0.17.1 tinycss2==1.2.1 tomli==2.0.1 -tomlkit==0.11.8 tornado==6.2 tox==3.28.0 ; python_version < "3.8.0" tqdm==4.65.0 diff --git a/.constraints/py3.8.txt b/.constraints/py3.8.txt index 4f38b2f2..524b9a07 100644 --- a/.constraints/py3.8.txt +++ b/.constraints/py3.8.txt @@ -13,7 +13,6 @@ aquirdturtle-collapsible-headings==3.1.0 argon2-cffi==21.3.0 argon2-cffi-bindings==21.2.0 arrow==1.2.3 -astroid==2.15.5 asttokens==2.2.1 attrs==23.1.0 babel==2.12.1 @@ -35,7 +34,6 @@ debugpy==1.6.7 decorator==5.1.1 defusedxml==0.7.1 deprecated==1.2.14 -dill==0.3.6 distlib==0.3.6 docutils==0.19 exceptiongroup==1.1.2 @@ -43,17 +41,6 @@ execnet==1.9.0 executing==1.2.0 fastjsonschema==2.17.1 filelock==3.12.2 -flake8==6.0.0 ; python_version >= "3.8.0" -flake8-blind-except==0.2.1 ; python_version >= "3.8.0" -flake8-bugbear==23.6.5 ; python_version >= "3.8.0" -flake8-builtins==2.1.0 ; python_version >= "3.8.0" -flake8-comprehensions==3.13.0 ; python_version >= "3.8.0" -flake8-future-import==0.4.7 ; python_version >= "3.8.0" -flake8-plugin-utils==1.3.3 -flake8-pytest-style==1.7.2 ; python_version >= "3.8.0" -flake8-rst-docstrings==0.3.0 ; python_version >= "3.8.0" -flake8-type-ignore==0.1.0.post2 ; python_version >= "3.8.0" -flake8-use-fstring==1.4 ; python_version >= "3.8.0" fqdn==1.5.1 gprof2dot==2022.7.29 graphviz==0.20.1 @@ -70,7 +57,6 @@ ipython==8.12.2 ipython-genutils==0.2.0 ipywidgets==8.0.6 isoduration==20.11.0 -isort==5.12.0 jedi==0.18.2 jinja2==3.1.2 json5==0.9.14 @@ -92,12 +78,10 @@ jupyterlab-pygments==0.2.2 jupyterlab-server==2.23.0 jupyterlab-widgets==3.0.7 latexcodec==2.0.1 -lazy-object-proxy==1.9.0 livereload==2.6.3 markdown-it-py==2.2.0 markupsafe==2.1.3 matplotlib-inline==0.1.6 -mccabe==0.7.0 mdit-py-plugins==0.3.5 mdurl==0.1.2 mistune==3.0.1 @@ -120,7 +104,6 @@ pandocfilters==1.5.0 parso==0.8.3 particle==0.23.0 pathspec==0.11.1 -pep8-naming==0.13.3 ; python_version >= "3.8.0" pexpect==4.8.0 pickleshare==0.7.5 pkgutil-resolve-name==1.3.10 @@ -134,15 +117,11 @@ ptyprocess==0.7.0 pure-eval==0.2.2 pybtex==0.24.0 pybtex-docutils==1.0.2 -pycodestyle==2.10.0 pycparser==2.21 pydantic==1.10.10 pydata-sphinx-theme==0.13.3 -pydocstyle==6.3.0 pydot==1.4.2 -pyflakes==3.0.1 pygments==2.15.1 -pylint==2.17.4 pyparsing==3.1.0 pyproject-api==1.5.2 pyrsistent==0.19.3 @@ -157,9 +136,9 @@ pytz==2023.3 pyyaml==6.0 pyzmq==25.1.0 requests==2.31.0 -restructuredtext-lint==1.4.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 +ruff==0.0.276 ; python_version >= "3.7.0" send2trash==1.8.2 six==1.16.0 sniffio==1.3.0 @@ -189,7 +168,6 @@ tabulate==0.9.0 terminado==0.17.1 tinycss2==1.2.1 tomli==2.0.1 -tomlkit==0.11.8 tornado==6.3.2 tox==4.6.3 tqdm==4.65.0 diff --git a/.constraints/py3.9.txt b/.constraints/py3.9.txt index 8ec9eec4..6fcdf0fd 100644 --- a/.constraints/py3.9.txt +++ b/.constraints/py3.9.txt @@ -13,7 +13,6 @@ aquirdturtle-collapsible-headings==3.1.0 argon2-cffi==21.3.0 argon2-cffi-bindings==21.2.0 arrow==1.2.3 -astroid==2.15.5 asttokens==2.2.1 attrs==23.1.0 babel==2.12.1 @@ -35,7 +34,6 @@ debugpy==1.6.7 decorator==5.1.1 defusedxml==0.7.1 deprecated==1.2.14 -dill==0.3.6 distlib==0.3.6 docutils==0.19 exceptiongroup==1.1.2 @@ -43,17 +41,6 @@ execnet==1.9.0 executing==1.2.0 fastjsonschema==2.17.1 filelock==3.12.2 -flake8==6.0.0 ; python_version >= "3.8.0" -flake8-blind-except==0.2.1 ; python_version >= "3.8.0" -flake8-bugbear==23.6.5 ; python_version >= "3.8.0" -flake8-builtins==2.1.0 ; python_version >= "3.8.0" -flake8-comprehensions==3.13.0 ; python_version >= "3.8.0" -flake8-future-import==0.4.7 ; python_version >= "3.8.0" -flake8-plugin-utils==1.3.3 -flake8-pytest-style==1.7.2 ; python_version >= "3.8.0" -flake8-rst-docstrings==0.3.0 ; python_version >= "3.8.0" -flake8-type-ignore==0.1.0.post2 ; python_version >= "3.8.0" -flake8-use-fstring==1.4 ; python_version >= "3.8.0" fqdn==1.5.1 gprof2dot==2022.7.29 graphviz==0.20.1 @@ -69,7 +56,6 @@ ipython==8.14.0 ipython-genutils==0.2.0 ipywidgets==8.0.6 isoduration==20.11.0 -isort==5.12.0 jedi==0.18.2 jinja2==3.1.2 json5==0.9.14 @@ -91,12 +77,10 @@ jupyterlab-pygments==0.2.2 jupyterlab-server==2.23.0 jupyterlab-widgets==3.0.7 latexcodec==2.0.1 -lazy-object-proxy==1.9.0 livereload==2.6.3 markdown-it-py==2.2.0 markupsafe==2.1.3 matplotlib-inline==0.1.6 -mccabe==0.7.0 mdit-py-plugins==0.3.5 mdurl==0.1.2 mistune==3.0.1 @@ -119,7 +103,6 @@ pandocfilters==1.5.0 parso==0.8.3 particle==0.23.0 pathspec==0.11.1 -pep8-naming==0.13.3 ; python_version >= "3.8.0" pexpect==4.8.0 pickleshare==0.7.5 platformdirs==3.8.0 @@ -132,15 +115,11 @@ ptyprocess==0.7.0 pure-eval==0.2.2 pybtex==0.24.0 pybtex-docutils==1.0.2 -pycodestyle==2.10.0 pycparser==2.21 pydantic==1.10.10 pydata-sphinx-theme==0.13.3 -pydocstyle==6.3.0 pydot==1.4.2 -pyflakes==3.0.1 pygments==2.15.1 -pylint==2.17.4 pyparsing==3.1.0 pyproject-api==1.5.2 pyrsistent==0.19.3 @@ -154,9 +133,9 @@ python-json-logger==2.0.7 pyyaml==6.0 pyzmq==25.1.0 requests==2.31.0 -restructuredtext-lint==1.4.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 +ruff==0.0.276 ; python_version >= "3.7.0" send2trash==1.8.2 six==1.16.0 sniffio==1.3.0 @@ -186,7 +165,6 @@ tabulate==0.9.0 terminado==0.17.1 tinycss2==1.2.1 tomli==2.0.1 -tomlkit==0.11.8 tornado==6.3.2 tox==4.6.3 tqdm==4.65.0 From d0481a29fb25e17222f853f7f56ecc10c71c7e4c Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 4 Jul 2023 06:54:05 +0200 Subject: [PATCH 13/47] MAINT: remove redundant newline --- .pre-commit-config.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 03c2cd6c..628e7a5b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -61,7 +61,6 @@ repos: - id: nbqa-pyupgrade args: - --py36-plus - - id: nbqa-ruff args: - --fix From 6629f8260458ad9b4690630fb9e1954e21818997 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 4 Jul 2023 13:52:04 +0200 Subject: [PATCH 14/47] MAINT: sort `pyproject.toml` sections --- pyproject.toml | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9365c7b3..f1dc03eb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,22 +33,9 @@ target-version = [ "py39", ] -[tool.nbqa.addopts] -black = [ - "--line-length=85", -] -ruff = [ - "--extend-ignore=B018", - "--extend-ignore=C90", - "--extend-ignore=D", - "--extend-ignore=N806", - "--extend-ignore=N816", - "--extend-ignore=PLR09", - "--extend-ignore=PLR2004", - "--extend-ignore=PLW0602", - "--extend-ignore=PLW0603", - "--line-length=85", -] +[tool.coverage.run] +branch = true +source = ["src"] [tool.mypy] disallow_incomplete_defs = true @@ -103,6 +90,23 @@ module = ["sphobjinv.*"] ignore_missing_imports = true module = ["tqdm.*"] +[tool.nbqa.addopts] +black = [ + "--line-length=85", +] +ruff = [ + "--extend-ignore=B018", + "--extend-ignore=C90", + "--extend-ignore=D", + "--extend-ignore=N806", + "--extend-ignore=N816", + "--extend-ignore=PLR09", + "--extend-ignore=PLR2004", + "--extend-ignore=PLW0602", + "--extend-ignore=PLW0603", + "--line-length=85", +] + [tool.pyright] exclude = [ "**/.git", @@ -137,10 +141,6 @@ reportUnusedImport = true reportUnusedVariable = true typeCheckingMode = "strict" -[tool.coverage.run] -branch = true -source = ["src"] - [tool.pytest.ini_options] addopts = """ --color=yes From 8ca710b94b4011b9dd349df770fa3eb7c2b77b3e Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 4 Jul 2023 13:52:21 +0200 Subject: [PATCH 15/47] MAINT: move badge to correct location --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e58790d9..8c583494 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # Quantum Number Conservation Rules -[![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.5526360](https://zenodo.org/badge/doi/10.5281/zenodo.5526360.svg)](https://doi.org/10.5281/zenodo.5526360) [![GPLv3+ license](https://img.shields.io/badge/License-GPLv3+-blue.svg)](https://www.gnu.org/licenses/gpl-3.0-standalone.html) @@ -22,6 +21,7 @@ [![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) +[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) QRules is a Python package for **validating and generating particle reactions** using quantum number conservation rules. The user only has to provide a certain set of From 0fa9dde8d12e65953b7cf4dd84007797faa5e07d Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 4 Jul 2023 13:52:48 +0200 Subject: [PATCH 16/47] MAINT: sort settings --- .vscode/settings.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index f25cc168..bb870cbc 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -23,11 +23,11 @@ "[yaml]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, - "cSpell.enabled": true, "coverage-gutters.coverageFileNames": ["coverage.xml"], "coverage-gutters.coverageReportFileName": "**/htmlcov/index.html", "coverage-gutters.showGutterCoverage": false, "coverage-gutters.showLineCoverage": true, + "cSpell.enabled": true, "editor.formatOnSave": true, "editor.rulers": [88], "files.watcherExclude": { @@ -68,7 +68,6 @@ "ruff.organizeImports": true, "search.exclude": { "**/tests/**/__init__.py": true, - "*/.pydocstyle": true, ".constraints/*.txt": true }, "yaml.schemas": { From ffcbe93a58f71b0e4a908b4cd82b6fab39d2a83d Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 4 Jul 2023 14:10:19 +0200 Subject: [PATCH 17/47] FIX: import classes for `eval` in tests --- tests/unit/test_topology.py | 1 + tests/unit/test_transition.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/unit/test_topology.py b/tests/unit/test_topology.py index 4d5cc2f6..12ac83ac 100644 --- a/tests/unit/test_topology.py +++ b/tests/unit/test_topology.py @@ -8,6 +8,7 @@ from qrules.topology import ( Edge, + FrozenDict, # noqa: F401 InteractionNode, MutableTopology, SimpleStateTransitionTopologyBuilder, diff --git a/tests/unit/test_transition.py b/tests/unit/test_transition.py index 3c980913..88ff1e6a 100644 --- a/tests/unit/test_transition.py +++ b/tests/unit/test_transition.py @@ -8,8 +8,12 @@ from qrules.particle import Parity, Particle, ParticleCollection, Spin # noqa: F401 from qrules.quantum_numbers import InteractionProperties # noqa: F401 from qrules.settings import InteractionType -from qrules.topology import ( +from qrules.topology import ( # noqa: F401 + Edge, + FrozenDict, FrozenTransition, + MutableTransition, + Topology, ) from qrules.transition import ReactionInfo, State, StateTransitionManager From 6a46dddf6f8288598a0595f1312e861573854eec Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 4 Jul 2023 14:12:06 +0200 Subject: [PATCH 18/47] MAINT: minor formatting improvements after Ruff autofixes --- docs/conf.py | 1 - src/qrules/transition.py | 2 +- tests/unit/test_particle.py | 6 ++++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index dc06241e..99b74c59 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -90,7 +90,6 @@ def fetch_logo(url: str, output_path: str) -> None: url="https://raw.githubusercontent.com/ComPWA/ComPWA/04e5199/doc/images/logo.svg", output_path=LOGO_PATH, ) - if os.path.exists(LOGO_PATH): html_logo = LOGO_PATH diff --git a/src/qrules/transition.py b/src/qrules/transition.py index 89eb66d4..f8e2d63c 100644 --- a/src/qrules/transition.py +++ b/src/qrules/transition.py @@ -162,7 +162,7 @@ def __attrs_post_init__(self) -> None: " but also violated rules." ) raise ValueError( - (msg), + msg, self.execution_info.violated_node_rules, self.execution_info.violated_edge_rules, ) diff --git a/tests/unit/test_particle.py b/tests/unit/test_particle.py index 3af3dc31..37115573 100644 --- a/tests/unit/test_particle.py +++ b/tests/unit/test_particle.py @@ -55,9 +55,11 @@ def test_exceptions(self): ) with pytest.raises(FrozenInstanceError): test_state.charge = 1 # type: ignore[misc] - with pytest.raises(ValueError, match=r"Fails Gell-Mann-Nishijima"): + with pytest.raises( + ValueError, match=r"Fails Gell-Mann–Nishijima" # noqa: RUF001 + ): Particle( - name="Fails Gell-Mann-Nishijima formula", + name="Fails Gell-Mann–Nishijima formula", # noqa: RUF001 pid=666, mass=0.0, spin=1, From bde86b9026c686f36cd2684542b9bf6fa1b478be Mon Sep 17 00:00:00 2001 From: GitHub Date: Tue, 4 Jul 2023 12:14:56 +0000 Subject: [PATCH 19/47] MAINT: update pip constraints and pre-commit --- .constraints/py3.10.txt | 2 +- .constraints/py3.11.txt | 2 +- .constraints/py3.7.txt | 2 +- .constraints/py3.8.txt | 2 +- .constraints/py3.9.txt | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.constraints/py3.10.txt b/.constraints/py3.10.txt index b564be98..44b29942 100644 --- a/.constraints/py3.10.txt +++ b/.constraints/py3.10.txt @@ -109,7 +109,7 @@ platformdirs==3.8.0 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 diff --git a/.constraints/py3.11.txt b/.constraints/py3.11.txt index 30f4bd1b..44d7aeb8 100644 --- a/.constraints/py3.11.txt +++ b/.constraints/py3.11.txt @@ -108,7 +108,7 @@ platformdirs==3.8.0 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 diff --git a/.constraints/py3.7.txt b/.constraints/py3.7.txt index 7efa8f84..d1abc54d 100644 --- a/.constraints/py3.7.txt +++ b/.constraints/py3.7.txt @@ -106,7 +106,7 @@ platformdirs==3.8.0 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 py==1.11.0 diff --git a/.constraints/py3.8.txt b/.constraints/py3.8.txt index 524b9a07..1510d8f5 100644 --- a/.constraints/py3.8.txt +++ b/.constraints/py3.8.txt @@ -111,7 +111,7 @@ platformdirs==3.8.0 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 diff --git a/.constraints/py3.9.txt b/.constraints/py3.9.txt index 6fcdf0fd..d3907573 100644 --- a/.constraints/py3.9.txt +++ b/.constraints/py3.9.txt @@ -109,7 +109,7 @@ platformdirs==3.8.0 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 From 7f9a1bb200b7ae0c961f44ef4a8879094b3a21c8 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 4 Jul 2023 21:36:48 +0200 Subject: [PATCH 20/47] FIX: resolve attrs classes only in Python >=3.7 --- pyproject.toml | 1 + src/qrules/transition.py | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f1dc03eb..669885e3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -207,6 +207,7 @@ ignore = [ "D416", "E501", "SIM108", + "UP036", ] show-fixes = true src = [ diff --git a/src/qrules/transition.py b/src/qrules/transition.py index f8e2d63c..d4eae9be 100644 --- a/src/qrules/transition.py +++ b/src/qrules/transition.py @@ -177,7 +177,8 @@ def extend( self.execution_info.extend(other.execution_info, intersect_violations) -attrs.resolve_types(_SolutionContainer, globals(), locals()) # type: ignore[type-var] +if sys.version_info >= (3, 7): + attrs.resolve_types(_SolutionContainer, globals(), locals()) # type: ignore[type-var] @implement_pretty_repr @@ -535,10 +536,8 @@ def find_solutions( results = self._find_particle_transitions(problem_sets) for strength, result in results.items(): _LOGGER.info( - ( - f"Number of solutions for strength {strength} after" - f"QN solving: {len(result.solutions)}" - ), + f"Number of solutions for strength {strength} after" + f"QN solving: {len(result.solutions)}", ) final_result = _SolutionContainer() From b622cbb5efefdaa1b5f60af1307e21f2057e1708 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 4 Jul 2023 21:36:51 +0200 Subject: [PATCH 21/47] MAINT: update `particle` test values --- tests/unit/test_particle.py | 12 ++++-------- tests/unit/test_pdg.py | 3 ++- tests/unit/test_system_control.py | 4 ++-- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/tests/unit/test_particle.py b/tests/unit/test_particle.py index 37115573..dae2103f 100644 --- a/tests/unit/test_particle.py +++ b/tests/unit/test_particle.py @@ -1,7 +1,6 @@ # pylint: disable=eval-used redefined-outer-name # pyright: reportUnusedImport=false import logging -import sys from copy import deepcopy import pytest @@ -136,6 +135,7 @@ def test_total_ordering(self, particle_database: ParticleCollection): "f(0)(1370)", "f(0)(1500)", "f(0)(1710)", + "f(0)(2020)", ] @@ -214,9 +214,9 @@ def test_discard(self, particle_database: ParticleCollection): def test_filter(self, particle_database: ParticleCollection): search_result = particle_database.filter(lambda p: "f(0)" in p.name) + assert len(search_result) == 6 f0_1500_from_subset = search_result["f(0)(1500)"] - assert len(search_result) == 5 - assert f0_1500_from_subset.mass == 1.506 + assert f0_1500_from_subset.mass == 1.522 assert f0_1500_from_subset is particle_database["f(0)(1500)"] assert f0_1500_from_subset is not particle_database["f(0)(980)"] @@ -256,11 +256,7 @@ def test_find(self, particle_database: ParticleCollection): ("gama", "'gamma', 'Sigma0', 'Sigma-', 'Sigma+', 'Lambda'"), ( "omega", - ( - "'omega(782)', 'omega(1420)', 'omega(3)(1670)', 'omega(1650)'" - if sys.version_info < (3, 7) - else "'omega(782)', 'omega(3)(1670)', 'omega(1650)'" - ), + "'omega(782)', 'omega(1420)', 'omega(3)(1670)', 'omega(1650)'", ), ("p~~", "'p~'"), ("~", "'p~', 'n~'"), diff --git a/tests/unit/test_pdg.py b/tests/unit/test_pdg.py index a6d93b34..a4fd7ff2 100644 --- a/tests/unit/test_pdg.py +++ b/tests/unit/test_pdg.py @@ -36,7 +36,8 @@ def test_pdg_size(pdg: ParticleCollection): 512, # particle==0.13 519, # particle==0.14-0.15 531, # particle==0.16-0.20 - 530, # particle==0.21 + 530, # particle==0.21-0.22 + 537, # particle==0.23 } assert len(pdg.filter(lambda p: "~" in p.name)) in { 165, # particle==0.13 diff --git a/tests/unit/test_system_control.py b/tests/unit/test_system_control.py index 1c2d1307..21376d62 100644 --- a/tests/unit/test_system_control.py +++ b/tests/unit/test_system_control.py @@ -175,8 +175,8 @@ def test_external_edge_initialization( 1.0, { EdgeQuantumNumbers.pid: 225, - EdgeQuantumNumbers.mass: 1.2755, - EdgeQuantumNumbers.width: 0.18669999999999998, + EdgeQuantumNumbers.mass: 1.2754, + EdgeQuantumNumbers.width: 0.1866, EdgeQuantumNumbers.spin_magnitude: 2.0, EdgeQuantumNumbers.spin_projection: 1.0, EdgeQuantumNumbers.charge: 0, From d68b41a5cdfd25ebe3ece3ba2070027b882cd282 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 4 Jul 2023 21:36:54 +0200 Subject: [PATCH 22/47] MAINT: address Ruff issues --- docs/conf.py | 14 ++++++-------- docs/usage/conservation.ipynb | 1 + docs/usage/visualize.ipynb | 1 + pyproject.toml | 4 ++++ src/qrules/__init__.py | 10 ++++++++-- src/qrules/_system_control.py | 2 +- src/qrules/combinatorics.py | 2 +- src/qrules/conservation_rules.py | 11 ++++++----- src/qrules/io/_dict.py | 2 +- src/qrules/io/_dot.py | 2 +- src/qrules/solving.py | 4 ++-- src/qrules/transition.py | 14 ++++++++------ tests/unit/test_combinatorics.py | 2 +- tests/unit/test_particle.py | 2 +- 14 files changed, 42 insertions(+), 29 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 99b74c59..e458978b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -115,7 +115,7 @@ def fetch_logo(url: str, output_path: str) -> None: "--separate", ] ), - shell=True, + shell=True, # noqa: S602 ) # -- Convert sphinx object inventory ----------------------------------------- @@ -429,12 +429,11 @@ def et_al(children, data, sep="", sep2=None, last_sep=None): # type: ignore[no- 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: return Text(sep2).join(parts) - elif len(parts) == 3: + if len(parts) == 3: 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 @@ -444,7 +443,7 @@ def names(children, context, role, **kwargs): # type: ignore[no-untyped-def] 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 = [ @@ -461,8 +460,7 @@ def format_names(self, role: Entry, as_sentence: bool = 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_url(self, e: Entry) -> Node: return words[ diff --git a/docs/usage/conservation.ipynb b/docs/usage/conservation.ipynb index 6f0e3b42..4071d8f7 100644 --- a/docs/usage/conservation.ipynb +++ b/docs/usage/conservation.ipynb @@ -79,6 +79,7 @@ "source": [ "import attrs\n", "import graphviz\n", + "from IPython.display import display\n", "\n", "import qrules\n", "from qrules.conservation_rules import (\n", diff --git a/docs/usage/visualize.ipynb b/docs/usage/visualize.ipynb index b57bb1a3..cf196c5c 100644 --- a/docs/usage/visualize.ipynb +++ b/docs/usage/visualize.ipynb @@ -107,6 +107,7 @@ "outputs": [], "source": [ "import graphviz\n", + "from IPython.display import display\n", "\n", "import qrules\n", "from qrules.particle import Spin\n", diff --git a/pyproject.toml b/pyproject.toml index 669885e3..b251a897 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -206,6 +206,10 @@ ignore = [ "D407", "D416", "E501", + "PLR0913", + "PLR2004", + "PLR5501", + "PLW2901", "SIM108", "UP036", ] diff --git a/src/qrules/__init__.py b/src/qrules/__init__.py index 3c5db457..3e2f1f9d 100644 --- a/src/qrules/__init__.py +++ b/src/qrules/__init__.py @@ -57,7 +57,7 @@ from .transition import EdgeSettings, ProblemSet, ReactionInfo, StateTransitionManager -def check_reaction_violations( # pylint: disable=too-many-arguments +def check_reaction_violations( # pylint: disable=too-many-arguments # noqa: C901 initial_state: Union[StateDefinition, Sequence[StateDefinition]], final_state: Sequence[StateDefinition], mass_conservation_factor: Optional[float] = 3.0, @@ -378,6 +378,12 @@ def load_default_particles() -> ParticleCollection: """ particle_db = load_pdg() additional_particles = io.load(ADDITIONAL_PARTICLES_DEFINITIONS_PATH) - assert isinstance(additional_particles, ParticleCollection) + if not isinstance(additional_particles, ParticleCollection): + msg = ( + f"Object loaded from {ADDITIONAL_PARTICLES_DEFINITIONS_PATH} is not a" + f" {ParticleCollection.__name__}, but a" + f" {type(additional_particles).__name__}" + ) + raise TypeError(msg) particle_db.update(additional_particles) return particle_db diff --git a/src/qrules/_system_control.py b/src/qrules/_system_control.py index 61777d8d..dc5cb487 100644 --- a/src/qrules/_system_control.py +++ b/src/qrules/_system_control.py @@ -79,7 +79,7 @@ def create_node_properties( return property_map -def find_particle( +def find_particle( # noqa: D417 state: GraphEdgePropertyMap, particle_db: ParticleCollection ) -> ParticleWithSpin: """Create a Particle with spin projection from a qn dictionary. diff --git a/src/qrules/combinatorics.py b/src/qrules/combinatorics.py index 0d467de2..a7cfc656 100644 --- a/src/qrules/combinatorics.py +++ b/src/qrules/combinatorics.py @@ -108,7 +108,7 @@ def is_sublist( for item in other: if not isinstance(item, list): msg = "Comparison representation needs to be a list of lists" - raise ValueError(msg) + raise TypeError(msg) return is_sublist(other, self.final_state) msg = f"Cannot compare {type(self).__name__} with {type(other).__name__}" raise ValueError(msg) diff --git a/src/qrules/conservation_rules.py b/src/qrules/conservation_rules.py index 661336a6..3daf1c28 100644 --- a/src/qrules/conservation_rules.py +++ b/src/qrules/conservation_rules.py @@ -264,7 +264,7 @@ def _get_c_parity_multiparticle( return reduce(lambda x, y: x * y, c_parities_part, 1) # two particle case - if len(part_qns) == 2: + if len(part_qns) == 2: # noqa: SIM102 if _is_particle_antiparticle_pair(part_qns[0].pid, part_qns[1].pid): ang_mom = interaction_qns.l_magnitude # if boson @@ -302,7 +302,7 @@ class GParityNodeInput: s_magnitude: NodeQN.s_magnitude = field(converter=NodeQN.s_magnitude) -def g_parity_conservation( +def g_parity_conservation( # noqa: C901 ingoing_edge_qns: List[GParityEdgeInput], outgoing_edge_qns: List[GParityEdgeInput], interaction_qns: GParityNodeInput, @@ -448,9 +448,10 @@ def _is_clebsch_gordan_coefficient_zero( j_2 = spin2.magnitude proj = spin_coupled.projection mag = spin_coupled.magnitude - if (j_1 == j_2 and m_1 == m_2) or (m_1 == 0.0 and m_2 == 0.0): - if abs(mag - j_1 - j_2) % 2 == 1: - return True + if ((j_1 == j_2 and m_1 == m_2) or (m_1 == 0.0 and m_2 == 0.0)) and abs( + mag - j_1 - j_2 + ) % 2 == 1: + return True if j_1 == mag and m_1 == -proj and abs(j_2 - j_1 - mag) % 2 == 1: return True if j_2 == mag and m_2 == -proj and abs(j_1 - j_2 - mag) % 2 == 1: diff --git a/src/qrules/io/_dict.py b/src/qrules/io/_dict.py index b0015e6a..b50e5e3f 100644 --- a/src/qrules/io/_dict.py +++ b/src/qrules/io/_dict.py @@ -34,7 +34,7 @@ def _value_serializer( # pylint: disable=unused-argument if all(isinstance(p, Particle) for p in value.values()): return {k: v.name for k, v in value.items()} return dict(value) - if not isinstance(inst, (ReactionInfo, State, FrozenTransition)): + if not isinstance(inst, (ReactionInfo, State, FrozenTransition)): # noqa: SIM102 if isinstance(value, Particle): return value.name if isinstance(value, Parity): diff --git a/src/qrules/io/_dot.py b/src/qrules/io/_dot.py index 41a4b8dd..bd5c2ea4 100644 --- a/src/qrules/io/_dot.py +++ b/src/qrules/io/_dot.py @@ -108,7 +108,7 @@ def _render_multiple_transitions(self, obj: Iterable) -> List[str]: lines += self._render_transition(graph, prefix=f"T{i}_") return lines - def _render_transition( + def _render_transition( # noqa: C901, PLR0912, PLR0915 self, obj: Union[ProblemSet, QNProblemSet, Topology, Transition], prefix: str = "", diff --git a/src/qrules/solving.py b/src/qrules/solving.py index 2892b077..04958abc 100644 --- a/src/qrules/solving.py +++ b/src/qrules/solving.py @@ -285,7 +285,7 @@ def __is_sub_mapping( return True -def validate_full_solution(problem_set: QNProblemSet) -> QNResult: +def validate_full_solution(problem_set: QNProblemSet) -> QNResult: # noqa: C901 # pylint: disable=too-many-locals _LOGGER.debug("validating graph...") @@ -466,7 +466,7 @@ def __init__(self, allowed_intermediate_states: Iterable[GraphEdgePropertyMap]): self.__allowed_intermediate_states = tuple(allowed_intermediate_states) self.__scoresheet = Scoresheet() - def find_solutions(self, problem_set: QNProblemSet) -> QNResult: + def find_solutions(self, problem_set: QNProblemSet) -> QNResult: # noqa: C901 # pylint: disable=too-many-locals self.__initialize_constraints(problem_set) solutions = self.__problem.getSolutions() diff --git a/src/qrules/transition.py b/src/qrules/transition.py index d4eae9be..f3d6ccdc 100644 --- a/src/qrules/transition.py +++ b/src/qrules/transition.py @@ -235,7 +235,7 @@ class StateTransitionManager: # pylint: disable=too-many-instance-attributes .. seealso:: :doc:`/usage/reaction` and `.generate_transitions` """ - def __init__( # pylint: disable=too-many-arguments, too-many-branches, too-many-locals + def __init__( # noqa: C901, PLR0912 self, initial_state: Sequence[StateDefinition], final_state: Sequence[StateDefinition], @@ -365,7 +365,7 @@ def add_final_state_grouping( ) -> None: if not isinstance(fs_group, list): msg = "The final state grouping has to be of type list." - raise ValueError(msg) + raise TypeError(msg) if len(fs_group) > 0: if self.final_state_groupings is None: self.final_state_groupings = [] @@ -428,7 +428,7 @@ def create_problem_sets(self) -> Dict[float, List[ProblemSet]]: ] return _group_by_strength(problem_sets) - def __determine_graph_settings( + def __determine_graph_settings( # noqa: C901 self, topology: Topology, initial_facts: "InitialFacts" ) -> List[GraphSettings]: # pylint: disable=too-many-locals @@ -529,15 +529,17 @@ def create_edge_settings(edge_id: int) -> EdgeSettings: return graph_settings - def find_solutions( + def find_solutions( # noqa: C901 self, problem_sets: Dict[float, List[ProblemSet]] ) -> "ReactionInfo": """Check for solutions for a specific set of interaction settings.""" results = self._find_particle_transitions(problem_sets) for strength, result in results.items(): _LOGGER.info( - f"Number of solutions for strength {strength} after" - f"QN solving: {len(result.solutions)}", + ( + f"Number of solutions for strength {strength} after" + f"QN solving: {len(result.solutions)}" + ), ) final_result = _SolutionContainer() diff --git a/tests/unit/test_combinatorics.py b/tests/unit/test_combinatorics.py index 3c0edcfc..b86c4d5e 100644 --- a/tests/unit/test_combinatorics.py +++ b/tests/unit/test_combinatorics.py @@ -217,7 +217,7 @@ def test_in_operator(self): with pytest.raises(ValueError, match=r"Cannot compare "): assert float() in kinematic_representation with pytest.raises( - ValueError, + TypeError, match=r"Comparison representation needs to be a list of lists", ): assert ["should be nested list"] in kinematic_representation diff --git a/tests/unit/test_particle.py b/tests/unit/test_particle.py index dae2103f..b6c2ba34 100644 --- a/tests/unit/test_particle.py +++ b/tests/unit/test_particle.py @@ -354,7 +354,7 @@ def test_exceptions(self, magnitude, projection): ) regex_pattern = f"({regex_pattern})" with pytest.raises(ValueError, match=regex_pattern): - print(Spin(magnitude, projection)) + print(Spin(magnitude, projection)) # noqa: T201 @pytest.mark.parametrize( From ce97ece9e177ff5b55e3f74f8886203e07d74a2a Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 4 Jul 2023 21:36:57 +0200 Subject: [PATCH 23/47] MAINT: remove flake8 and pylint comments --- .cspell.json | 2 -- docs/_extend_docstrings.py | 20 ++++++++----------- docs/_relink_references.py | 3 +-- src/qrules/__init__.py | 6 ++---- src/qrules/_implementers.py | 1 - src/qrules/_system_control.py | 2 +- src/qrules/argument_handling.py | 3 +-- src/qrules/combinatorics.py | 3 +-- src/qrules/conservation_rules.py | 2 -- src/qrules/io/__init__.py | 3 --- src/qrules/io/_dict.py | 5 +---- src/qrules/io/_dot.py | 3 --- src/qrules/particle.py | 9 ++++----- src/qrules/quantum_numbers.py | 2 +- src/qrules/settings.py | 2 +- src/qrules/solving.py | 12 +---------- src/qrules/topology.py | 7 +------ src/qrules/transition.py | 4 +--- tests/channels/test_nbody_reactions.py | 1 - tests/channels/test_psi2s_to_eta_k_kstar.py | 1 - tests/unit/conftest.py | 1 - .../test_parity_conservation.py | 4 +--- tests/unit/io/test_dict.py | 1 - tests/unit/test_combinatorics.py | 5 +---- tests/unit/test_parity_prefactor.py | 1 - tests/unit/test_particle.py | 7 +++---- tests/unit/test_pdg.py | 1 - tests/unit/test_quantum_numbers.py | 1 - tests/unit/test_system_control.py | 2 -- tests/unit/test_topology.py | 4 +--- tests/unit/test_transition.py | 1 - 31 files changed, 30 insertions(+), 89 deletions(-) diff --git a/.cspell.json b/.cspell.json index 49c7238b..5ce525fe 100644 --- a/.cspell.json +++ b/.cspell.json @@ -130,7 +130,6 @@ "prereleased", "pygments", "pylance", - "pylintrc", "pypi", "pyproject", "pyright", @@ -205,7 +204,6 @@ "nishijima", "pydocstyle", "pydot", - "pylint", "pyplot", "pytest", "qrules", diff --git a/docs/_extend_docstrings.py b/docs/_extend_docstrings.py index acda9afc..44773019 100644 --- a/docs/_extend_docstrings.py +++ b/docs/_extend_docstrings.py @@ -1,10 +1,8 @@ -# flake8: noqa -# pylint: disable=import-error,import-outside-toplevel,invalid-name,protected-access -# pyright: reportMissingImports=false """Extend docstrings of the API. This small script is used by ``conf.py`` to dynamically modify docstrings. """ +# pyright: reportMissingImports=false import inspect import logging @@ -34,7 +32,8 @@ def extend_docstrings() -> None: continue function_arguments = inspect.signature(definition).parameters if len(function_arguments): - raise ValueError(f"Local function {name} should not have a signature") + msg = f"Local function {name} should not have a signature" + raise ValueError(msg) definition() @@ -42,10 +41,7 @@ def extend_create_isobar_topologies() -> None: from qrules.topology import create_isobar_topologies topologies = qrules.topology.create_isobar_topologies(4) - dot_renderings = map( - lambda t: qrules.io.asdot(t, render_resonance_id=True), - topologies, - ) + dot_renderings = (qrules.io.asdot(t, render_resonance_id=True) for t in topologies) images = [_graphviz_to_image(dot, indent=8) for dot in dot_renderings] _append_to_docstring( create_isobar_topologies, @@ -77,7 +73,7 @@ def extend_create_n_body_topology() -> None: ) -def extend_Topology() -> None: +def extend_Topology() -> None: # noqa: N802 from qrules.topology import Topology, create_isobar_topologies topologies = create_isobar_topologies(number_of_final_states=3) @@ -101,10 +97,10 @@ def _append_to_docstring(class_type: Union[Callable, Type], appended_text: str) _IMAGE_DIR = "_images" -def _graphviz_to_image( # pylint: disable=too-many-arguments +def _graphviz_to_image( dot: str, options: Optional[Dict[str, str]] = None, - format: str = "svg", + format: str = "svg", # noqa: A002 indent: int = 0, caption: str = "", label: str = "", @@ -113,7 +109,7 @@ def _graphviz_to_image( # pylint: disable=too-many-arguments if options is None: options = {} - global _GRAPHVIZ_COUNTER # pylint: disable=global-statement + global _GRAPHVIZ_COUNTER # noqa: PLW0603 output_file = f"graphviz_{_GRAPHVIZ_COUNTER}" _GRAPHVIZ_COUNTER += 1 # pyright: ignore[reportConstantRedefinition] graphviz.Source(dot).render(f"{_IMAGE_DIR}/{output_file}", format=format) diff --git a/docs/_relink_references.py b/docs/_relink_references.py index fc7c1daa..28f223eb 100644 --- a/docs/_relink_references.py +++ b/docs/_relink_references.py @@ -1,5 +1,3 @@ -# pylint: disable=import-error, import-outside-toplevel -# pyright: reportMissingImports=false """Abbreviated the annotations generated by sphinx-autodoc. It's not necessary to generate the full path of type hints, because they are rendered as @@ -7,6 +5,7 @@ See also https://github.com/sphinx-doc/sphinx/issues/5868. """ +# pyright: reportMissingImports=false from typing import TYPE_CHECKING, List diff --git a/src/qrules/__init__.py b/src/qrules/__init__.py index 3e2f1f9d..f1045ee0 100644 --- a/src/qrules/__init__.py +++ b/src/qrules/__init__.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines """A rule based system that facilitates particle reaction analysis. QRules generates allowed particle transitions from a set of conservation rules and @@ -57,7 +56,7 @@ from .transition import EdgeSettings, ProblemSet, ReactionInfo, StateTransitionManager -def check_reaction_violations( # pylint: disable=too-many-arguments # noqa: C901 +def check_reaction_violations( # noqa: C901 initial_state: Union[StateDefinition, Sequence[StateDefinition]], final_state: Sequence[StateDefinition], mass_conservation_factor: Optional[float] = 3.0, @@ -102,7 +101,6 @@ def check_reaction_violations( # pylint: disable=too-many-arguments # noqa: C9 .. seealso:: :ref:`usage:Check allowed reactions` """ - # pylint: disable=too-many-locals if not isinstance(initial_state, (list, tuple)): initial_state = [initial_state] # type: ignore[list-item] @@ -255,7 +253,7 @@ def check_edge_qn_conservation() -> Set[FrozenSet[str]]: return violations -def generate_transitions( # pylint: disable=too-many-arguments +def generate_transitions( initial_state: Union[StateDefinition, Sequence[StateDefinition]], final_state: Sequence[StateDefinition], allowed_intermediate_particles: Optional[List[str]] = None, diff --git a/src/qrules/_implementers.py b/src/qrules/_implementers.py index b7f8c3d4..0b93381b 100644 --- a/src/qrules/_implementers.py +++ b/src/qrules/_implementers.py @@ -36,6 +36,5 @@ def repr_pretty(self: Any, p: "PrettyPrinter", cycle: bool) -> None: p.breakable() p.text(")") - # pylint: disable=protected-access decorated_class._repr_pretty_ = repr_pretty # type: ignore[attr-defined] return decorated_class # type: ignore[return-value] diff --git a/src/qrules/_system_control.py b/src/qrules/_system_control.py index dc5cb487..3309c438 100644 --- a/src/qrules/_system_control.py +++ b/src/qrules/_system_control.py @@ -225,7 +225,7 @@ def remove_duplicate_solutions( return filtered_solutions -def _remove_qns_from_graph( # pylint: disable=too-many-branches +def _remove_qns_from_graph( graph: "MutableTransition[ParticleWithSpin, InteractionProperties]", qn_list: Set[Type[NodeQuantumNumber]], ) -> "MutableTransition[ParticleWithSpin, InteractionProperties]": diff --git a/src/qrules/argument_handling.py b/src/qrules/argument_handling.py index fdb425dc..cd47fe28 100644 --- a/src/qrules/argument_handling.py +++ b/src/qrules/argument_handling.py @@ -34,7 +34,7 @@ Rule = Union[GraphElementRule, EdgeQNConservationRule, ConservationRule] -_ElementType = TypeVar("_ElementType") # pylint: disable=invalid-name +_ElementType = TypeVar("_ElementType") GraphElementPropertyMap = Dict[Type[_ElementType], Scalar] GraphEdgePropertyMap = GraphElementPropertyMap[EdgeQuantumNumber] @@ -52,7 +52,6 @@ def _is_optional(field_type: Optional[type]) -> bool: def _is_sequence_type(input_type: type) -> bool: origin = getattr(input_type, "__origin__", None) - # pylint: disable=unhashable-member return origin in {list, tuple, List, Tuple} diff --git a/src/qrules/combinatorics.py b/src/qrules/combinatorics.py index a7cfc656..f799667b 100644 --- a/src/qrules/combinatorics.py +++ b/src/qrules/combinatorics.py @@ -365,7 +365,7 @@ def match_external_edges( _match_external_edge_ids(graphs, ref_graph_id, __get_initial_state_edge_ids) -def _match_external_edge_ids( # pylint: disable=too-many-locals +def _match_external_edge_ids( graphs: "List[MutableTransition[ParticleWithSpin, InteractionProperties]]", ref_graph_id: int, external_edge_getter_function: "Callable[[MutableTransition], Iterable[int]]", @@ -440,7 +440,6 @@ def _external_edge_identical_particle_combinatorics( graph: "MutableTransition[ParticleWithSpin, InteractionProperties]", external_edge_getter_function: Callable[[MutableTransition], Iterable[int]], ) -> List[MutableTransition]: - # pylint: disable=too-many-locals new_graphs = [graph] edge_particle_mapping = _create_edge_id_particle_mapping( graph, external_edge_getter_function(graph) diff --git a/src/qrules/conservation_rules.py b/src/qrules/conservation_rules.py index 3daf1c28..d627a8d2 100644 --- a/src/qrules/conservation_rules.py +++ b/src/qrules/conservation_rules.py @@ -116,7 +116,6 @@ def additive_quantum_number_rule( def decorator(rule_class: Any) -> EdgeQNConservationRule: def new_call( - # pylint: disable=unused-argument self: Type[EdgeQNConservationRule], ingoing_edge_qns: List[quantum_number], # type: ignore[valid-type] outgoing_edge_qns: List[quantum_number], # type: ignore[valid-type] @@ -798,7 +797,6 @@ def helicity_conservation( @frozen class GellMannNishijimaInput: - # pylint: disable=too-many-instance-attributes charge: EdgeQN.charge = field(converter=EdgeQN.charge) isospin_projection: Optional[EdgeQN.isospin_projection] = field( converter=optional(EdgeQN.isospin_projection), default=None diff --git a/src/qrules/io/__init__.py b/src/qrules/io/__init__.py index d4ef19e7..0cf8118f 100644 --- a/src/qrules/io/__init__.py +++ b/src/qrules/io/__init__.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-return-statements """Serialization module for the `qrules`. The `.io` module provides tools to export or import objects from `qrules` to and from @@ -20,7 +19,6 @@ def asdict(instance: object) -> dict: - # pylint: disable=protected-access if isinstance(instance, ParticleCollection): return _dict.from_particle_collection(instance) if attrs.has(type(instance)): @@ -134,7 +132,6 @@ def load(filename: str) -> object: class _IncreasedIndent(yaml.Dumper): - # pylint: disable=too-many-ancestors def increase_indent(self, flow: bool = False, indentless: bool = False) -> None: return super().increase_indent(flow, False) diff --git a/src/qrules/io/_dict.py b/src/qrules/io/_dict.py index b50e5e3f..f112e393 100644 --- a/src/qrules/io/_dict.py +++ b/src/qrules/io/_dict.py @@ -1,4 +1,3 @@ -# pylint: disable=import-outside-toplevel """Serialization from and to a `dict`.""" import json @@ -27,9 +26,7 @@ def from_attrs_decorated(inst: Any) -> dict: ) -def _value_serializer( # pylint: disable=unused-argument - inst: type, field: attrs.Attribute, value: Any -) -> Any: +def _value_serializer(inst: type, field: attrs.Attribute, value: Any) -> Any: if isinstance(value, abc.Mapping): if all(isinstance(p, Particle) for p in value.values()): return {k: v.name for k, v in value.items()} diff --git a/src/qrules/io/_dot.py b/src/qrules/io/_dot.py index bd5c2ea4..0110536a 100644 --- a/src/qrules/io/_dot.py +++ b/src/qrules/io/_dot.py @@ -27,7 +27,6 @@ def _check_booleans( instance: "GraphPrinter", attribute: Attribute, value: bool ) -> None: - # pylint: disable=unused-argument if instance.strip_spin and instance.collapse_graphs: msg = "Cannot both strip spin and collapse graphs" raise ValueError(msg) @@ -113,7 +112,6 @@ def _render_transition( # noqa: C901, PLR0912, PLR0915 obj: Union[ProblemSet, QNProblemSet, Topology, Transition], prefix: str = "", ) -> List[str]: - # pylint: disable=too-many-branches,too-many-locals,too-many-statements lines: List[str] = [] if isinstance(obj, tuple) and len(obj) == 2: topology: Topology = obj[0] @@ -311,7 +309,6 @@ def _(obj: dict) -> str: else: key_repr = key if value != 0 or any(s in key_repr for s in ["magnitude", "projection"]): - # pylint: disable=invalid-name pm = not any(s in key_repr for s in ["pid", "mass", "width", "magnitude"]) value_repr = __render_fraction(value, pm) lines.append(f"{key_repr} = {value_repr}") diff --git a/src/qrules/particle.py b/src/qrules/particle.py index 93b4a360..885adbc8 100644 --- a/src/qrules/particle.py +++ b/src/qrules/particle.py @@ -1,4 +1,3 @@ -# pylint: disable=import-outside-toplevel """A collection of particle info containers. The :mod:`.particle` module is the starting point of `qrules`. Its main interface is the @@ -122,7 +121,7 @@ def _to_spin(value: Union[Spin, Tuple[float, float]]) -> Spin: @total_ordering @frozen(kw_only=True, order=False, repr=True) -class Particle: # pylint: disable=too-many-instance-attributes +class Particle: """Immutable container of data defining a physical particle. A `Particle` is defined by the minimum set of the quantum numbers that every @@ -360,13 +359,13 @@ def find(self, search_term: Union[int, str]) -> Particle: """Search for a particle by either name (`str`) or PID (`int`).""" if isinstance(search_term, str): particle_name = search_term - return self.__getitem__(particle_name) # pylint: disable=C2801 + return self.__getitem__(particle_name) if isinstance(search_term, int): if search_term not in self.__pid_to_name: msg = f"No particle with PID {search_term}" raise KeyError(msg) particle_name = self.__pid_to_name[search_term] - return self.__getitem__(particle_name) # pylint: disable=C2801 + return self.__getitem__(particle_name) msg = f"Cannot search for a search term of type {type(search_term)}" raise NotImplementedError(msg) @@ -405,7 +404,7 @@ def names(self) -> List[str]: return [p.name for p in sorted(self)] -def create_particle( # pylint: disable=too-many-arguments,too-many-locals +def create_particle( template_particle: Particle, name: Optional[str] = None, latex: Optional[str] = None, diff --git a/src/qrules/quantum_numbers.py b/src/qrules/quantum_numbers.py index f0764f5e..dbce48c9 100644 --- a/src/qrules/quantum_numbers.py +++ b/src/qrules/quantum_numbers.py @@ -63,7 +63,7 @@ def _to_fraction(value: Union[float, int], render_plus: bool = False) -> str: @frozen(init=False) -class EdgeQuantumNumbers: # pylint: disable=too-many-instance-attributes +class EdgeQuantumNumbers: """Definition of quantum numbers for edges. This class defines the types that are used in the :mod:`.conservation_rules`, for diff --git a/src/qrules/settings.py b/src/qrules/settings.py index 7235f32f..38e8605f 100644 --- a/src/qrules/settings.py +++ b/src/qrules/settings.py @@ -113,7 +113,7 @@ def from_str(description: str) -> "InteractionType": ] -def create_interaction_settings( # pylint: disable=too-many-locals,too-many-arguments +def create_interaction_settings( formalism: str, particle_db: ParticleCollection, nbody_topology: bool = False, diff --git a/src/qrules/solving.py b/src/qrules/solving.py index 04958abc..6037640d 100644 --- a/src/qrules/solving.py +++ b/src/qrules/solving.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines """Functions to solve a particle reaction problem. This module is responsible for solving a particle reaction problem stated by a @@ -286,7 +285,6 @@ def __is_sub_mapping( def validate_full_solution(problem_set: QNProblemSet) -> QNResult: # noqa: C901 - # pylint: disable=too-many-locals _LOGGER.debug("validating graph...") rule_argument_handler = RuleArgumentHandler() @@ -450,7 +448,6 @@ class CSPSolver(Solver): wrapper class serves as an adapter. """ - # pylint: disable=too-many-instance-attributes def __init__(self, allowed_intermediate_states: Iterable[GraphEdgePropertyMap]): self.__variables: Set[Union[_EdgeVariableInfo, _NodeVariableInfo]] = set() self.__var_string_to_data: Dict[ @@ -467,7 +464,6 @@ def __init__(self, allowed_intermediate_states: Iterable[GraphEdgePropertyMap]): self.__scoresheet = Scoresheet() def find_solutions(self, problem_set: QNProblemSet) -> QNResult: # noqa: C901 - # pylint: disable=too-many-locals self.__initialize_constraints(problem_set) solutions = self.__problem.getSolutions() @@ -563,8 +559,6 @@ def __initialize_constraints(self, problem_set: QNProblemSet) -> None: role for this conservation law. Hence variables are also created within this method. """ - # pylint: disable=too-many-locals - self.__clear() def get_rules_by_priority( @@ -812,9 +806,7 @@ def rule_passes(self) -> Dict[Tuple[int, Rule], int]: return self.__rule_passes -_QNType = TypeVar( # pylint: disable=invalid-name - "_QNType", EdgeQuantumNumber, NodeQuantumNumber -) +_QNType = TypeVar("_QNType", EdgeQuantumNumber, NodeQuantumNumber) class _GraphElementConstraint( @@ -826,7 +818,6 @@ class _GraphElementConstraint( interface. """ - # pylint: disable=too-many-arguments def __init__( self, rule: GraphElementRule, @@ -948,7 +939,6 @@ class _ConservationRuleConstraintWrapper( interface. """ - # pylint: disable=too-many-instance-attributes def __init__( self, rule: Rule, diff --git a/src/qrules/topology.py b/src/qrules/topology.py index 20dc9bbb..2948ce36 100644 --- a/src/qrules/topology.py +++ b/src/qrules/topology.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines """Functionality for `Topology` and `Transition` instances. .. rubric:: Main interfaces @@ -72,9 +71,7 @@ def __lt__(self, other: Any) -> bool: @total_ordering -class FrozenDict( # pylint: disable=too-many-ancestors - abc.Hashable, abc.Mapping, Generic[KT, VT] -): +class FrozenDict(abc.Hashable, abc.Mapping, Generic[KT, VT]): """An **immutable** and **hashable** version of a `dict`. `FrozenDict` makes it possible to make classes hashable if they are decorated with @@ -799,7 +796,6 @@ def _attach_node_to_edges( return (temp_graph, new_open_end_lines) -# pylint: disable=invalid-name EdgeType = TypeVar("EdgeType") NodeType = TypeVar("NodeType") NewEdgeType = TypeVar("NewEdgeType") @@ -904,7 +900,6 @@ def convert( def convert(self, state_converter=None, interaction_converter=None): # type: ignore[no-untyped-def] """Cast the edge and/or node properties to another type.""" - # pylint: disable=unnecessary-lambda if state_converter is None: state_converter = _identity_function if interaction_converter is None: diff --git a/src/qrules/transition.py b/src/qrules/transition.py index f3d6ccdc..0cf375b2 100644 --- a/src/qrules/transition.py +++ b/src/qrules/transition.py @@ -229,7 +229,7 @@ def calculate_strength(node_interaction_settings: Dict[int, NodeSettings]) -> fl return strength_sorted_problem_sets -class StateTransitionManager: # pylint: disable=too-many-instance-attributes +class StateTransitionManager: """Main handler for decay topologies. .. seealso:: :doc:`/usage/reaction` and `.generate_transitions` @@ -341,7 +341,6 @@ def set_allowed_intermediate_particles( name_patterns = [name_patterns] selected_particles = ParticleCollection() for pattern in name_patterns: - # pylint: disable=cell-var-from-loop matches = _filter_by_name_pattern(self.__particles, pattern, regex) if len(matches) == 0: msg = ( @@ -431,7 +430,6 @@ def create_problem_sets(self) -> Dict[float, List[ProblemSet]]: def __determine_graph_settings( # noqa: C901 self, topology: Topology, initial_facts: "InitialFacts" ) -> List[GraphSettings]: - # pylint: disable=too-many-locals weak_edge_settings, _ = self.interaction_type_settings[InteractionType.WEAK] def create_intermediate_edge_qn_domains() -> Dict: diff --git a/tests/channels/test_nbody_reactions.py b/tests/channels/test_nbody_reactions.py index 1beb54a1..dea76413 100644 --- a/tests/channels/test_nbody_reactions.py +++ b/tests/channels/test_nbody_reactions.py @@ -1,4 +1,3 @@ -# pylint: disable=redefined-outer-name from typing import FrozenSet, Set, Union import pytest diff --git a/tests/channels/test_psi2s_to_eta_k_kstar.py b/tests/channels/test_psi2s_to_eta_k_kstar.py index 2b8a272e..f7679f25 100644 --- a/tests/channels/test_psi2s_to_eta_k_kstar.py +++ b/tests/channels/test_psi2s_to_eta_k_kstar.py @@ -1,4 +1,3 @@ -# pylint: disable=redefined-outer-name """Test for https://github.com/ComPWA/qrules/issues/165.""" import pytest diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index 7079aff5..ebb5ad1b 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -1,4 +1,3 @@ -# pylint: disable=redefined-outer-name import logging import pytest diff --git a/tests/unit/conservation_rules/test_parity_conservation.py b/tests/unit/conservation_rules/test_parity_conservation.py index 3d0dde31..e483fe5b 100644 --- a/tests/unit/conservation_rules/test_parity_conservation.py +++ b/tests/unit/conservation_rules/test_parity_conservation.py @@ -22,9 +22,7 @@ Parity(1), ], NodeQuantumNumbers.l_magnitude(l_magnitude), - parity_in - == parity_out1 - * (-1) ** (l_magnitude), # pylint: disable=undefined-variable + parity_in == parity_out1 * (-1) ** (l_magnitude), ) for parity_in, parity_out1, l_magnitude in product( [-1, 1], [-1, 1], range(0, 5) diff --git a/tests/unit/io/test_dict.py b/tests/unit/io/test_dict.py index f745168f..31768da7 100644 --- a/tests/unit/io/test_dict.py +++ b/tests/unit/io/test_dict.py @@ -1,4 +1,3 @@ -# pylint: disable=redefined-outer-name import pytest from qrules import io diff --git a/tests/unit/test_combinatorics.py b/tests/unit/test_combinatorics.py index b86c4d5e..0961b15a 100644 --- a/tests/unit/test_combinatorics.py +++ b/tests/unit/test_combinatorics.py @@ -1,4 +1,3 @@ -# pylint: disable=redefined-outer-name from typing import List import pytest @@ -199,9 +198,7 @@ def test_repr_and_equality(self): initial_state=[["J/psi"]], final_state=[["gamma", "pi0"], ["gamma", "pi0", "pi0"]], ) - constructed_from_repr = eval( # pylint: disable=eval-used - str(kinematic_representation) - ) + constructed_from_repr = eval(str(kinematic_representation)) assert constructed_from_repr == kinematic_representation def test_in_operator(self): diff --git a/tests/unit/test_parity_prefactor.py b/tests/unit/test_parity_prefactor.py index 3681bdf0..78c7cba2 100644 --- a/tests/unit/test_parity_prefactor.py +++ b/tests/unit/test_parity_prefactor.py @@ -57,7 +57,6 @@ def test_parity_prefactor( related_component_names: Tuple[str, str], relative_parity_prefactor: float, ) -> None: - # pylint: disable=unused-argument stm = StateTransitionManager( test_input.initial_state, test_input.final_state, diff --git a/tests/unit/test_particle.py b/tests/unit/test_particle.py index b6c2ba34..eec29678 100644 --- a/tests/unit/test_particle.py +++ b/tests/unit/test_particle.py @@ -1,5 +1,3 @@ -# pylint: disable=eval-used redefined-outer-name -# pyright: reportUnusedImport=false import logging from copy import deepcopy @@ -17,7 +15,9 @@ ) # For eval tests -from qrules.quantum_numbers import Parity # noqa: F401 +from qrules.quantum_numbers import ( + Parity, # noqa: F401 # pyright: ignore[reportUnusedImport] +) class TestParticle: @@ -394,7 +394,6 @@ def test_create_antiparticle_tilde(particle_database: ParticleCollection): def test_create_antiparticle_by_pid(particle_database: ParticleCollection): n_particles_with_neg_pid = 0 for particle in particle_database: - # pylint: disable=cell-var-from-loop anti_particles_by_pid = particle_database.filter( lambda p: p.pid == -particle.pid # noqa: B023 ) diff --git a/tests/unit/test_pdg.py b/tests/unit/test_pdg.py index a4fd7ff2..7d4c7f99 100644 --- a/tests/unit/test_pdg.py +++ b/tests/unit/test_pdg.py @@ -1,4 +1,3 @@ -# pylint: disable=redefined-outer-name import particle import pytest diff --git a/tests/unit/test_quantum_numbers.py b/tests/unit/test_quantum_numbers.py index bcb36031..38ac3e95 100644 --- a/tests/unit/test_quantum_numbers.py +++ b/tests/unit/test_quantum_numbers.py @@ -1,4 +1,3 @@ -# pylint: disable=eval-used import typing from copy import deepcopy diff --git a/tests/unit/test_system_control.py b/tests/unit/test_system_control.py index 21376d62..45b4a89b 100644 --- a/tests/unit/test_system_control.py +++ b/tests/unit/test_system_control.py @@ -1,4 +1,3 @@ -# pylint: disable=protected-access import sys from copy import deepcopy from typing import Dict, List @@ -353,7 +352,6 @@ def _create_graph( ], ) def test_edge_swap(particle_database, initial_state, final_state): - # pylint: disable=too-many-locals stm = StateTransitionManager( initial_state, final_state, diff --git a/tests/unit/test_topology.py b/tests/unit/test_topology.py index 12ac83ac..cff6c5bd 100644 --- a/tests/unit/test_topology.py +++ b/tests/unit/test_topology.py @@ -1,5 +1,3 @@ -# pylint: disable=eval-used redefined-outer-name too-many-arguments -# pyright: reportUnusedImport=false import typing import pytest @@ -8,7 +6,7 @@ from qrules.topology import ( Edge, - FrozenDict, # noqa: F401 + FrozenDict, # noqa: F401 # pyright: ignore[reportUnusedImport] InteractionNode, MutableTopology, SimpleStateTransitionTopologyBuilder, diff --git a/tests/unit/test_transition.py b/tests/unit/test_transition.py index 88ff1e6a..f1588ec9 100644 --- a/tests/unit/test_transition.py +++ b/tests/unit/test_transition.py @@ -1,5 +1,4 @@ # pyright: reportUnusedImport=false -# pylint: disable=eval-used from copy import deepcopy import pytest From fad2c59978c42fcfa70cebe6b55c0dc5bf0662fb Mon Sep 17 00:00:00 2001 From: GitHub Date: Tue, 4 Jul 2023 19:38:42 +0000 Subject: [PATCH 24/47] MAINT: update pip constraints and pre-commit --- .constraints/py3.10.txt | 10 +++++----- .constraints/py3.11.txt | 10 +++++----- .constraints/py3.6.txt | 4 ++-- .constraints/py3.7.txt | 12 ++++++------ .constraints/py3.8.txt | 10 +++++----- .constraints/py3.9.txt | 10 +++++----- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/.constraints/py3.10.txt b/.constraints/py3.10.txt index 44b29942..9f7fdde9 100644 --- a/.constraints/py3.10.txt +++ b/.constraints/py3.10.txt @@ -54,7 +54,7 @@ iniconfig==2.0.0 ipykernel==6.24.0 ipython==8.14.0 ipython-genutils==0.2.0 -ipywidgets==8.0.6 +ipywidgets==8.0.7 isoduration==20.11.0 jedi==0.18.2 jinja2==3.1.2 @@ -75,7 +75,7 @@ jupyterlab-code-formatter==2.2.1 jupyterlab-myst==2.0.0 ; python_version >= "3.7.0" jupyterlab-pygments==0.2.2 jupyterlab-server==2.23.0 -jupyterlab-widgets==3.0.7 +jupyterlab-widgets==3.0.8 latexcodec==2.0.1 livereload==2.6.3 markdown-it-py==2.2.0 @@ -116,7 +116,7 @@ pure-eval==0.2.2 pybtex==0.24.0 pybtex-docutils==1.0.2 pycparser==2.21 -pydantic==1.10.10 +pydantic==1.10.11 pydata-sphinx-theme==0.13.3 pydot==1.4.2 pygments==2.15.1 @@ -173,7 +173,7 @@ types-docutils==0.20.0.1 types-pkg-resources==0.1.3 types-pyyaml==6.0.12.10 types-requests==2.31.0.1 -types-setuptools==68.0.0.0 +types-setuptools==68.0.0.1 types-urllib3==1.26.25.13 typing-extensions==4.7.1 uri-template==1.3.0 @@ -184,7 +184,7 @@ webcolors==1.13 webencodings==0.5.1 websocket-client==1.6.1 wheel==0.40.0 -widgetsnbextension==4.0.7 +widgetsnbextension==4.0.8 wrapt==1.15.0 y-py==0.5.9 ypy-websocket==0.8.2 ; python_version >= "3.7.0" diff --git a/.constraints/py3.11.txt b/.constraints/py3.11.txt index 44d7aeb8..08087629 100644 --- a/.constraints/py3.11.txt +++ b/.constraints/py3.11.txt @@ -53,7 +53,7 @@ iniconfig==2.0.0 ipykernel==6.24.0 ipython==8.14.0 ipython-genutils==0.2.0 -ipywidgets==8.0.6 +ipywidgets==8.0.7 isoduration==20.11.0 jedi==0.18.2 jinja2==3.1.2 @@ -74,7 +74,7 @@ jupyterlab-code-formatter==2.2.1 jupyterlab-myst==2.0.0 ; python_version >= "3.7.0" jupyterlab-pygments==0.2.2 jupyterlab-server==2.23.0 -jupyterlab-widgets==3.0.7 +jupyterlab-widgets==3.0.8 latexcodec==2.0.1 livereload==2.6.3 markdown-it-py==2.2.0 @@ -115,7 +115,7 @@ pure-eval==0.2.2 pybtex==0.24.0 pybtex-docutils==1.0.2 pycparser==2.21 -pydantic==1.10.10 +pydantic==1.10.11 pydata-sphinx-theme==0.13.3 pydot==1.4.2 pygments==2.15.1 @@ -171,7 +171,7 @@ types-docutils==0.20.0.1 types-pkg-resources==0.1.3 types-pyyaml==6.0.12.10 types-requests==2.31.0.1 -types-setuptools==68.0.0.0 +types-setuptools==68.0.0.1 types-urllib3==1.26.25.13 typing-extensions==4.7.1 uri-template==1.3.0 @@ -182,7 +182,7 @@ webcolors==1.13 webencodings==0.5.1 websocket-client==1.6.1 wheel==0.40.0 -widgetsnbextension==4.0.7 +widgetsnbextension==4.0.8 wrapt==1.15.0 y-py==0.5.9 ypy-websocket==0.8.2 ; python_version >= "3.7.0" diff --git a/.constraints/py3.6.txt b/.constraints/py3.6.txt index be736f6b..ab694fcb 100644 --- a/.constraints/py3.6.txt +++ b/.constraints/py3.6.txt @@ -149,12 +149,12 @@ tornado==6.1 tox==3.28.0 ; python_version < "3.8.0" tqdm==4.64.1 traitlets==4.3.3 -typed-ast==1.5.4 +typed-ast==1.5.5 types-docutils==0.20.0.1 types-pkg-resources==0.1.3 types-pyyaml==6.0.12.10 types-requests==2.31.0.1 -types-setuptools==68.0.0.0 +types-setuptools==68.0.0.1 types-urllib3==1.26.25.13 typing-extensions==4.1.1 ; python_version < "3.10.0" urllib3==1.26.16 diff --git a/.constraints/py3.7.txt b/.constraints/py3.7.txt index d1abc54d..bb44a24b 100644 --- a/.constraints/py3.7.txt +++ b/.constraints/py3.7.txt @@ -52,7 +52,7 @@ iniconfig==2.0.0 ipykernel==6.16.2 ipython==7.34.0 ipython-genutils==0.2.0 -ipywidgets==8.0.6 +ipywidgets==8.0.7 isoduration==20.11.0 jedi==0.18.2 jinja2==3.1.2 @@ -72,7 +72,7 @@ jupyterlab-code-formatter==2.2.1 jupyterlab-myst==1.2.0 ; python_version >= "3.7.0" jupyterlab-pygments==0.2.2 jupyterlab-server==2.23.0 -jupyterlab-widgets==3.0.7 +jupyterlab-widgets==3.0.8 latexcodec==2.0.1 livereload==2.6.3 markdown-it-py==2.2.0 @@ -113,7 +113,7 @@ py==1.11.0 pybtex==0.24.0 pybtex-docutils==1.0.2 pycparser==2.21 -pydantic==1.10.10 +pydantic==1.10.11 pydata-sphinx-theme==0.13.3 pydot==1.4.2 pygments==2.15.1 @@ -165,12 +165,12 @@ tornado==6.2 tox==3.28.0 ; python_version < "3.8.0" tqdm==4.65.0 traitlets==5.9.0 -typed-ast==1.5.4 +typed-ast==1.5.5 types-docutils==0.20.0.1 types-pkg-resources==0.1.3 types-pyyaml==6.0.12.10 types-requests==2.31.0.1 -types-setuptools==68.0.0.0 +types-setuptools==68.0.0.1 types-urllib3==1.26.25.13 typing-extensions==4.7.1 ; python_version < "3.10.0" uri-template==1.3.0 @@ -181,7 +181,7 @@ webcolors==1.13 webencodings==0.5.1 websocket-client==1.6.1 wheel==0.40.0 -widgetsnbextension==4.0.7 +widgetsnbextension==4.0.8 wrapt==1.15.0 y-py==0.5.9 ypy-websocket==0.8.2 ; python_version >= "3.7.0" diff --git a/.constraints/py3.8.txt b/.constraints/py3.8.txt index 1510d8f5..5687ef5c 100644 --- a/.constraints/py3.8.txt +++ b/.constraints/py3.8.txt @@ -55,7 +55,7 @@ iniconfig==2.0.0 ipykernel==6.24.0 ipython==8.12.2 ipython-genutils==0.2.0 -ipywidgets==8.0.6 +ipywidgets==8.0.7 isoduration==20.11.0 jedi==0.18.2 jinja2==3.1.2 @@ -76,7 +76,7 @@ jupyterlab-code-formatter==2.2.1 jupyterlab-myst==2.0.0 ; python_version >= "3.7.0" jupyterlab-pygments==0.2.2 jupyterlab-server==2.23.0 -jupyterlab-widgets==3.0.7 +jupyterlab-widgets==3.0.8 latexcodec==2.0.1 livereload==2.6.3 markdown-it-py==2.2.0 @@ -118,7 +118,7 @@ pure-eval==0.2.2 pybtex==0.24.0 pybtex-docutils==1.0.2 pycparser==2.21 -pydantic==1.10.10 +pydantic==1.10.11 pydata-sphinx-theme==0.13.3 pydot==1.4.2 pygments==2.15.1 @@ -176,7 +176,7 @@ types-docutils==0.20.0.1 types-pkg-resources==0.1.3 types-pyyaml==6.0.12.10 types-requests==2.31.0.1 -types-setuptools==68.0.0.0 +types-setuptools==68.0.0.1 types-urllib3==1.26.25.13 typing-extensions==4.7.1 ; python_version < "3.10.0" uri-template==1.3.0 @@ -187,7 +187,7 @@ webcolors==1.13 webencodings==0.5.1 websocket-client==1.6.1 wheel==0.40.0 -widgetsnbextension==4.0.7 +widgetsnbextension==4.0.8 wrapt==1.15.0 y-py==0.5.9 ypy-websocket==0.8.2 ; python_version >= "3.7.0" diff --git a/.constraints/py3.9.txt b/.constraints/py3.9.txt index d3907573..d8162c65 100644 --- a/.constraints/py3.9.txt +++ b/.constraints/py3.9.txt @@ -54,7 +54,7 @@ iniconfig==2.0.0 ipykernel==6.24.0 ipython==8.14.0 ipython-genutils==0.2.0 -ipywidgets==8.0.6 +ipywidgets==8.0.7 isoduration==20.11.0 jedi==0.18.2 jinja2==3.1.2 @@ -75,7 +75,7 @@ jupyterlab-code-formatter==2.2.1 jupyterlab-myst==2.0.0 ; python_version >= "3.7.0" jupyterlab-pygments==0.2.2 jupyterlab-server==2.23.0 -jupyterlab-widgets==3.0.7 +jupyterlab-widgets==3.0.8 latexcodec==2.0.1 livereload==2.6.3 markdown-it-py==2.2.0 @@ -116,7 +116,7 @@ pure-eval==0.2.2 pybtex==0.24.0 pybtex-docutils==1.0.2 pycparser==2.21 -pydantic==1.10.10 +pydantic==1.10.11 pydata-sphinx-theme==0.13.3 pydot==1.4.2 pygments==2.15.1 @@ -173,7 +173,7 @@ types-docutils==0.20.0.1 types-pkg-resources==0.1.3 types-pyyaml==6.0.12.10 types-requests==2.31.0.1 -types-setuptools==68.0.0.0 +types-setuptools==68.0.0.1 types-urllib3==1.26.25.13 typing-extensions==4.7.1 ; python_version < "3.10.0" uri-template==1.3.0 @@ -184,7 +184,7 @@ webcolors==1.13 webencodings==0.5.1 websocket-client==1.6.1 wheel==0.40.0 -widgetsnbextension==4.0.7 +widgetsnbextension==4.0.8 wrapt==1.15.0 y-py==0.5.9 ypy-websocket==0.8.2 ; python_version >= "3.7.0" From 1b84c5a6f7263d9f16910d5bf8ddb34f96eda137 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 4 Jul 2023 22:02:09 +0200 Subject: [PATCH 25/47] FIX: update assert values after `particle` upgrade --- docs/usage/reaction.ipynb | 2 +- tests/unit/test_particle.py | 38 ++++++++++++++++++++++--------- tests/unit/test_system_control.py | 9 +++++--- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/docs/usage/reaction.ipynb b/docs/usage/reaction.ipynb index 0f6d5cbf..58a24f3b 100644 --- a/docs/usage/reaction.ipynb +++ b/docs/usage/reaction.ipynb @@ -450,7 +450,7 @@ "source": [ "stm.set_allowed_intermediate_particles(r\"f\\([02]\\)\", regex=True)\n", "reaction = stm.find_solutions(problem_sets)\n", - "assert len(reaction.get_intermediate_particles().names) == 11" + "assert len(reaction.get_intermediate_particles().names) == 12" ] }, { diff --git a/tests/unit/test_particle.py b/tests/unit/test_particle.py index eec29678..d57f30d0 100644 --- a/tests/unit/test_particle.py +++ b/tests/unit/test_particle.py @@ -1,4 +1,5 @@ import logging +import sys from copy import deepcopy import pytest @@ -124,19 +125,28 @@ def test_neg(self, particle_database: ParticleCollection): pim = particle_database.find(-211) assert pip == -pim - def test_total_ordering(self, particle_database: ParticleCollection): pdg = particle_database - assert [ + f0_mesons = [ particle.name for particle in sorted(pdg.filter(lambda p: p.name.startswith("f(0)"))) - ] == [ - "f(0)(500)", - "f(0)(980)", - "f(0)(1370)", - "f(0)(1500)", - "f(0)(1710)", - "f(0)(2020)", ] + if sys.version_info > (3, 7): + assert f0_mesons == [ + "f(0)(500)", + "f(0)(980)", + "f(0)(1370)", + "f(0)(1500)", + "f(0)(1710)", + "f(0)(2020)", + ] + else: + assert f0_mesons == [ + "f(0)(500)", + "f(0)(980)", + "f(0)(1370)", + "f(0)(1500)", + "f(0)(1710)", + ] class TestParticleCollection: @@ -214,9 +224,15 @@ def test_discard(self, particle_database: ParticleCollection): def test_filter(self, particle_database: ParticleCollection): search_result = particle_database.filter(lambda p: "f(0)" in p.name) - assert len(search_result) == 6 + if sys.version_info > (3, 7): + assert len(search_result) == 6 + else: + assert len(search_result) == 5 f0_1500_from_subset = search_result["f(0)(1500)"] - assert f0_1500_from_subset.mass == 1.522 + if sys.version_info > (3, 7): + assert f0_1500_from_subset.mass == 1.522 + else: + assert f0_1500_from_subset.mass == 1.506 assert f0_1500_from_subset is particle_database["f(0)(1500)"] assert f0_1500_from_subset is not particle_database["f(0)(980)"] diff --git a/tests/unit/test_system_control.py b/tests/unit/test_system_control.py index 45b4a89b..a3d140ca 100644 --- a/tests/unit/test_system_control.py +++ b/tests/unit/test_system_control.py @@ -174,8 +174,12 @@ def test_external_edge_initialization( 1.0, { EdgeQuantumNumbers.pid: 225, - EdgeQuantumNumbers.mass: 1.2754, - EdgeQuantumNumbers.width: 0.1866, + EdgeQuantumNumbers.mass: ( + 1.2754 if sys.version_info > (3, 7) else 1.2755 + ), + EdgeQuantumNumbers.width: ( + 0.1866 if sys.version_info > (3, 7) else 0.18669999999999998 + ), EdgeQuantumNumbers.spin_magnitude: 2.0, EdgeQuantumNumbers.spin_projection: 1.0, EdgeQuantumNumbers.charge: 0, @@ -200,7 +204,6 @@ def test_create_edge_properties( particle_name, spin_projection, expected_properties, particle_database ): particle = particle_database[particle_name] - assert create_edge_properties(particle, spin_projection) == expected_properties From 9d09542aa807eb553c4b0dfd1a2593c4b8b00b93 Mon Sep 17 00:00:00 2001 From: Remco de Boer Date: Wed, 5 Jul 2023 11:27:20 +0200 Subject: [PATCH 26/47] MAINT: remove `ypy-websocket` restriction --- setup.cfg | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 6d284c52..3fa20b0d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -108,7 +108,6 @@ jupyter = jupyterlab jupyterlab-code-formatter jupyterlab-myst; python_version >="3.7.0" - ypy-websocket <0.8.3; python_version >="3.7.0" # https://github.com/ComPWA/qrules/actions/runs/4350315417/jobs/7600906057#step:3:79 dev = %(all)s %(doc)s From 28a4a0727e5313d37f3bdb4e5872cd7ded5c231a Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Wed, 5 Jul 2023 11:31:31 +0200 Subject: [PATCH 27/47] Revert "MAINT: remove `ypy-websocket` restriction" This reverts commit 9d09542aa807eb553c4b0dfd1a2593c4b8b00b93. --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index 3fa20b0d..6d284c52 100644 --- a/setup.cfg +++ b/setup.cfg @@ -108,6 +108,7 @@ jupyter = jupyterlab jupyterlab-code-formatter jupyterlab-myst; python_version >="3.7.0" + ypy-websocket <0.8.3; python_version >="3.7.0" # https://github.com/ComPWA/qrules/actions/runs/4350315417/jobs/7600906057#step:3:79 dev = %(all)s %(doc)s From 57dea966e080f74e16d23c528d78c0761f51f5bd Mon Sep 17 00:00:00 2001 From: GitHub Date: Wed, 5 Jul 2023 09:33:37 +0000 Subject: [PATCH 28/47] MAINT: update pip constraints and pre-commit --- .constraints/py3.10.txt | 4 ++-- .constraints/py3.11.txt | 4 ++-- .constraints/py3.7.txt | 2 +- .constraints/py3.8.txt | 4 ++-- .constraints/py3.9.txt | 4 ++-- .pre-commit-config.yaml | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.constraints/py3.10.txt b/.constraints/py3.10.txt index 9f7fdde9..14817d63 100644 --- a/.constraints/py3.10.txt +++ b/.constraints/py3.10.txt @@ -72,7 +72,7 @@ jupyter-server-ydoc==0.8.0 jupyter-ydoc==0.2.4 jupyterlab==3.6.5 jupyterlab-code-formatter==2.2.1 -jupyterlab-myst==2.0.0 ; python_version >= "3.7.0" +jupyterlab-myst==2.0.1 ; python_version >= "3.7.0" jupyterlab-pygments==0.2.2 jupyterlab-server==2.23.0 jupyterlab-widgets==3.0.8 @@ -135,7 +135,7 @@ pyzmq==25.1.0 requests==2.31.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 -ruff==0.0.276 ; python_version >= "3.7.0" +ruff==0.0.277 ; python_version >= "3.7.0" send2trash==1.8.2 six==1.16.0 sniffio==1.3.0 diff --git a/.constraints/py3.11.txt b/.constraints/py3.11.txt index 08087629..986ec320 100644 --- a/.constraints/py3.11.txt +++ b/.constraints/py3.11.txt @@ -71,7 +71,7 @@ jupyter-server-ydoc==0.8.0 jupyter-ydoc==0.2.4 jupyterlab==3.6.5 jupyterlab-code-formatter==2.2.1 -jupyterlab-myst==2.0.0 ; python_version >= "3.7.0" +jupyterlab-myst==2.0.1 ; python_version >= "3.7.0" jupyterlab-pygments==0.2.2 jupyterlab-server==2.23.0 jupyterlab-widgets==3.0.8 @@ -134,7 +134,7 @@ pyzmq==25.1.0 requests==2.31.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 -ruff==0.0.276 ; python_version >= "3.7.0" +ruff==0.0.277 ; python_version >= "3.7.0" send2trash==1.8.2 six==1.16.0 sniffio==1.3.0 diff --git a/.constraints/py3.7.txt b/.constraints/py3.7.txt index bb44a24b..483503f7 100644 --- a/.constraints/py3.7.txt +++ b/.constraints/py3.7.txt @@ -132,7 +132,7 @@ pyzmq==25.1.0 requests==2.31.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 -ruff==0.0.276 ; python_version >= "3.7.0" +ruff==0.0.277 ; python_version >= "3.7.0" send2trash==1.8.2 six==1.16.0 sniffio==1.3.0 diff --git a/.constraints/py3.8.txt b/.constraints/py3.8.txt index 5687ef5c..932f87dc 100644 --- a/.constraints/py3.8.txt +++ b/.constraints/py3.8.txt @@ -73,7 +73,7 @@ jupyter-server-ydoc==0.8.0 jupyter-ydoc==0.2.4 jupyterlab==3.6.5 jupyterlab-code-formatter==2.2.1 -jupyterlab-myst==2.0.0 ; python_version >= "3.7.0" +jupyterlab-myst==2.0.1 ; python_version >= "3.7.0" jupyterlab-pygments==0.2.2 jupyterlab-server==2.23.0 jupyterlab-widgets==3.0.8 @@ -138,7 +138,7 @@ pyzmq==25.1.0 requests==2.31.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 -ruff==0.0.276 ; python_version >= "3.7.0" +ruff==0.0.277 ; python_version >= "3.7.0" send2trash==1.8.2 six==1.16.0 sniffio==1.3.0 diff --git a/.constraints/py3.9.txt b/.constraints/py3.9.txt index d8162c65..df841d49 100644 --- a/.constraints/py3.9.txt +++ b/.constraints/py3.9.txt @@ -72,7 +72,7 @@ jupyter-server-ydoc==0.8.0 jupyter-ydoc==0.2.4 jupyterlab==3.6.5 jupyterlab-code-formatter==2.2.1 -jupyterlab-myst==2.0.0 ; python_version >= "3.7.0" +jupyterlab-myst==2.0.1 ; python_version >= "3.7.0" jupyterlab-pygments==0.2.2 jupyterlab-server==2.23.0 jupyterlab-widgets==3.0.8 @@ -135,7 +135,7 @@ pyzmq==25.1.0 requests==2.31.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 -ruff==0.0.276 ; python_version >= "3.7.0" +ruff==0.0.277 ; python_version >= "3.7.0" send2trash==1.8.2 six==1.16.0 sniffio==1.3.0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 628e7a5b..c88d6612 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -148,7 +148,7 @@ repos: - --py36-plus - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.276 + rev: v0.0.277 hooks: - id: ruff args: From 52b28390347bc12e395c33eb8cf4a1cd3a0be9d9 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Wed, 5 Jul 2023 11:38:07 +0200 Subject: [PATCH 29/47] MAINT: remove `virtualenv` restriction --- setup.cfg | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 6d284c52..b1e06c9a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -120,7 +120,6 @@ dev = tox !=4.*; python_version <"3.8.0" # https://github.com/ComPWA/qrules/actions/runs/4116409504/jobs/7106431526#step:3:92 virtualenv !=20.16.*; python_version <"3.7.0" # https://github.com/ComPWA/qrules/actions/runs/4116487921/jobs/7106603597#step:3:78 virtualenv !=20.17.*; python_version <"3.7.0" # https://github.com/ComPWA/qrules/actions/runs/4116447949/jobs/7106515800#step:3:78 - virtualenv <20.22.0; python_version <"3.8.0" # importlib-metadata conflict [options.packages.find] where = src From 7a727771b9f2457d1c616a2a1d42602500a6937e Mon Sep 17 00:00:00 2001 From: GitHub Date: Wed, 5 Jul 2023 09:39:52 +0000 Subject: [PATCH 30/47] MAINT: update pip constraints and pre-commit --- .constraints/py3.6.txt | 2 +- .constraints/py3.7.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.constraints/py3.6.txt b/.constraints/py3.6.txt index ab694fcb..6bcb6822 100644 --- a/.constraints/py3.6.txt +++ b/.constraints/py3.6.txt @@ -158,7 +158,7 @@ types-setuptools==68.0.0.1 types-urllib3==1.26.25.13 typing-extensions==4.1.1 ; python_version < "3.10.0" urllib3==1.26.16 -virtualenv==20.15.1 ; python_version < "3.8.0" +virtualenv==20.15.1 ; python_version < "3.7.0" wcwidth==0.2.6 webencodings==0.5.1 websocket-client==1.3.1 diff --git a/.constraints/py3.7.txt b/.constraints/py3.7.txt index 483503f7..4b3bf941 100644 --- a/.constraints/py3.7.txt +++ b/.constraints/py3.7.txt @@ -175,7 +175,7 @@ types-urllib3==1.26.25.13 typing-extensions==4.7.1 ; python_version < "3.10.0" uri-template==1.3.0 urllib3==2.0.3 -virtualenv==20.21.1 ; python_version < "3.8.0" +virtualenv==20.23.1 wcwidth==0.2.6 webcolors==1.13 webencodings==0.5.1 From 2d84467668da97b0a61746d80c823bd40806b3e8 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Wed, 5 Jul 2023 14:41:34 +0200 Subject: [PATCH 31/47] MAINT: ignore new Ruff rule S307 --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index b251a897..9e54f31c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -237,6 +237,7 @@ task-tags = ["cspell"] "PLR0913", "PLR2004", "S101", + "S307", ] [tool.ruff.pydocstyle] From daa78e14b654ec74a7444e87bc46f19a8c36d1c7 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Wed, 5 Jul 2023 16:42:31 +0200 Subject: [PATCH 32/47] MAINT: make `tests` runnable on all `particle` versions --- setup.cfg | 1 + tests/channels/test_lc_to_p_km_pip.py | 8 +- tests/conftest.py | 16 +++ tests/unit/io/test_dict.py | 12 ++- tests/unit/io/test_dot.py | 3 +- tests/unit/test_particle.py | 141 +++++++++++++++----------- tests/unit/test_system_control.py | 50 ++++++--- 7 files changed, 153 insertions(+), 78 deletions(-) diff --git a/setup.cfg b/setup.cfg index b1e06c9a..01d65511 100644 --- a/setup.cfg +++ b/setup.cfg @@ -76,6 +76,7 @@ doc = sphinxcontrib-hep-pdgref sphobjinv test = + importlib-metadata; python_version <"3.8.0" ipython nbmake nbmake !=1.3.* # https://github.com/ComPWA/qrules/actions/runs/4116315964/jobs/7106216956#step:3:84 diff --git a/tests/channels/test_lc_to_p_km_pip.py b/tests/channels/test_lc_to_p_km_pip.py index c0f3afcf..a54ae66e 100644 --- a/tests/channels/test_lc_to_p_km_pip.py +++ b/tests/channels/test_lc_to_p_km_pip.py @@ -13,9 +13,9 @@ def test_resonances(): stm.set_allowed_intermediate_particles([r"Delta..(?!9)", r"^K", r"^L"], regex=True) problem_sets = stm.create_problem_sets() reaction = stm.find_solutions(problem_sets) - resonances = reaction.get_intermediate_particles().names + sorted_resonances = sorted(reaction.get_intermediate_particles().names) # https://lc2pkpi-polarimetry.docs.cern.ch/amplitude-model.html#resonances-and-ls-scheme - assert resonances == [ + expected = { "Delta(1232)++", "Delta(1600)++", "Delta(1620)++", @@ -32,4 +32,6 @@ def test_resonances(): "Lambda(1810)", "Lambda(1800)", "Lambda(1890)", - ] + } + sorted_expected = sorted(expected) + assert sorted_resonances == sorted_expected diff --git a/tests/conftest.py b/tests/conftest.py index 78b4bd2d..56334410 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,9 +1,16 @@ +import sys + import pytest from qrules import load_default_particles from qrules.particle import ParticleCollection from qrules.settings import NumberOfThreads +if sys.version_info < (3, 8): + from importlib_metadata import version +else: + from importlib.metadata import version + # Ensure consistent test coverage when running pytest multithreaded # https://github.com/ComPWA/qrules/issues/11 NumberOfThreads.set(1) @@ -17,3 +24,12 @@ def particle_database() -> ParticleCollection: @pytest.fixture(scope="session") def output_dir(pytestconfig) -> str: return f"{pytestconfig.rootpath}/tests/output/" + + +@pytest.fixture(scope="session") +def skh_particle_version() -> str: + major, minor, *_ = (int(i) for i in version("particle").split(".")) + particle_version = f"{major}.{minor}" + if (major, minor) < (0, 11): + pytest.skip(f"Version {particle_version} is not supported in the tests") + return particle_version diff --git a/tests/unit/io/test_dict.py b/tests/unit/io/test_dict.py index 31768da7..038e3af1 100644 --- a/tests/unit/io/test_dict.py +++ b/tests/unit/io/test_dict.py @@ -17,13 +17,19 @@ def test_not_implemented_errors( io.write(666, output_dir + "wont_work_anyway.yml") -def test_serialization(output_dir: str, particle_selection: ParticleCollection): +def test_serialization( + output_dir: str, particle_selection: ParticleCollection, skh_particle_version: str +): io.write(particle_selection, output_dir + "particle_selection.yml") - assert len(particle_selection) == 193 + n_particles = len(particle_selection) + if skh_particle_version < "0.16": + assert n_particles == 181 + else: + assert n_particles == 193 asdict = io.asdict(particle_selection) imported_collection = io.fromdict(asdict) assert isinstance(imported_collection, ParticleCollection) - assert len(particle_selection) == len(imported_collection) + assert n_particles == len(imported_collection) for particle in particle_selection: exported = particle_selection[particle.name] imported = imported_collection[particle.name] diff --git a/tests/unit/io/test_dot.py b/tests/unit/io/test_dot.py index 8ff439d2..c124436d 100644 --- a/tests/unit/io/test_dot.py +++ b/tests/unit/io/test_dot.py @@ -230,7 +230,8 @@ def test_get_particle_graphs( assert graphs[0].states[i] is graphs[1].states[i] -def test_strip_projections(): +def test_strip_projections(skh_particle_version: str): + assert skh_particle_version is not None # skips test if particle version too low resonance = "Sigma(1670)~-" reaction = qrules.generate_transitions( initial_state=[("J/psi(1S)", [+1])], diff --git a/tests/unit/test_particle.py b/tests/unit/test_particle.py index d57f30d0..4f3dd420 100644 --- a/tests/unit/test_particle.py +++ b/tests/unit/test_particle.py @@ -1,6 +1,7 @@ import logging import sys from copy import deepcopy +from typing import List, Union import pytest from attrs.exceptions import FrozenInstanceError @@ -20,6 +21,11 @@ Parity, # noqa: F401 # pyright: ignore[reportUnusedImport] ) +if sys.version_info < (3, 8): + from importlib_metadata import version +else: + from importlib.metadata import version + class TestParticle: @pytest.mark.parametrize("repr_method", [repr, pretty]) @@ -120,33 +126,36 @@ def test_gt(self, name1, name2, particle_database: ParticleCollection): pdg = particle_database assert pdg[name1] > pdg[name2] - def test_neg(self, particle_database: ParticleCollection): + def test_neg( + self, particle_database: ParticleCollection, skh_particle_version: str + ): pip = particle_database.find(211) pim = particle_database.find(-211) assert pip == -pim pdg = particle_database - f0_mesons = [ + f0_mesons = sorted( particle.name for particle in sorted(pdg.filter(lambda p: p.name.startswith("f(0)"))) - ] - if sys.version_info > (3, 7): - assert f0_mesons == [ - "f(0)(500)", - "f(0)(980)", - "f(0)(1370)", - "f(0)(1500)", - "f(0)(1710)", - "f(0)(2020)", - ] - else: - assert f0_mesons == [ - "f(0)(500)", - "f(0)(980)", - "f(0)(1370)", - "f(0)(1500)", - "f(0)(1710)", - ] + ) + expected = { + "f(0)(500)", + "f(0)(980)", + "f(0)(1370)", + "f(0)(1500)", + "f(0)(1710)", + } + if skh_particle_version > "0.22": + expected.add("f(0)(2020)") + sorted_expected = sorted(expected) + assert f0_mesons == sorted_expected + + +def _get_omega_mesons() -> List[str]: + scikit_hep_particle_version = ".".join(version("particle").split(".")[:2]) + if scikit_hep_particle_version in {"0.21", "0.22"}: + return ["omega(782)", "omega(3)(1670)", "omega(1650)"] + return ["omega(782)", "omega(1420)", "omega(3)(1670)", "omega(1650)"] class TestParticleCollection: @@ -222,17 +231,19 @@ def test_discard(self, particle_database: ParticleCollection): with pytest.raises(NotImplementedError): pions.discard(111) # type: ignore[arg-type] - def test_filter(self, particle_database: ParticleCollection): + def test_filter( + self, particle_database: ParticleCollection, skh_particle_version: str + ): search_result = particle_database.filter(lambda p: "f(0)" in p.name) - if sys.version_info > (3, 7): - assert len(search_result) == 6 - else: + if skh_particle_version < "0.23": assert len(search_result) == 5 - f0_1500_from_subset = search_result["f(0)(1500)"] - if sys.version_info > (3, 7): - assert f0_1500_from_subset.mass == 1.522 else: + assert len(search_result) == 6 + f0_1500_from_subset = search_result["f(0)(1500)"] + if skh_particle_version < "0.23": assert f0_1500_from_subset.mass == 1.506 + else: + assert f0_1500_from_subset.mass == 1.522 assert f0_1500_from_subset is particle_database["f(0)(1500)"] assert f0_1500_from_subset is not particle_database["f(0)(980)"] @@ -247,12 +258,19 @@ def test_filter(self, particle_database: ParticleCollection): and p.spin == 2 and p.strangeness == 1 ) - assert filtered_result.names == [ - "K(2)(1820)0", + sorted_result = sorted(filtered_result.names) + expected = { "K(2)(1820)+", - "K(2)*(1980)0", - "K(2)*(1980)+", - ] + "K(2)(1820)0", + } + if skh_particle_version > "0.15": + additional_particles = { + "K(2)*(1980)+", + "K(2)*(1980)0", + } + expected.update(additional_particles) + sorted_expected = sorted(expected) + assert sorted_result == sorted_expected def test_find(self, particle_database: ParticleCollection): f2_1950 = particle_database.find(9050225) @@ -268,28 +286,30 @@ def test_find(self, particle_database: ParticleCollection): (666, None), ("non-existing", None), # cspell:disable - ("gamm", "'gamma'"), - ("gama", "'gamma', 'Sigma0', 'Sigma-', 'Sigma+', 'Lambda'"), - ( - "omega", - "'omega(782)', 'omega(1420)', 'omega(3)(1670)', 'omega(1650)'", - ), - ("p~~", "'p~'"), - ("~", "'p~', 'n~'"), - ("lambda", "'Lambda', 'Lambda~', 'Lambda(c)+', 'Lambda(b)0'"), + ("gamm", "gamma"), + ("gama", ["gamma", "Sigma0", "Sigma-", "Sigma+", "Lambda"]), + ("omega", _get_omega_mesons()), + ("p~~", "p~"), + ("~", ["p~", "n~"]), + ("lambda", ["Lambda", "Lambda~", "Lambda(c)+", "Lambda(b)0"]), # cspell:enable ], ) def test_find_fail( - self, particle_database: ParticleCollection, search_term, expected + self, + particle_database: ParticleCollection, + search_term, + expected: Union[List[str], str], ): with pytest.raises(LookupError) as exception: particle_database.find(search_term) if expected is not None: message = str(exception.value.args[0]) - message = message.strip("?") - message = message.strip("]") - assert message.endswith(expected) + list_str = message.strip("?") + *_, list_str = list_str.split("Did you mean ") + *_, list_str = list_str.split("one of these? ") + found_particles = eval(list_str) + assert found_particles == expected def test_exceptions(self, particle_database: ParticleCollection): gamma = particle_database["gamma"] @@ -389,13 +409,16 @@ def test_create_antiparticle( assert anti_particle == comparison_particle -def test_create_antiparticle_tilde(particle_database: ParticleCollection): +def test_create_antiparticle_tilde( + particle_database: ParticleCollection, skh_particle_version: str +): anti_particles = particle_database.filter(lambda p: "~" in p.name) - assert len(anti_particles) in { - 165, # particle==0.13 - 172, # particle==0.14, 0.15 - 175, # particle==0.16 - } + if skh_particle_version < "0.14": + assert len(anti_particles) == 165 + elif skh_particle_version < "0.16": + assert len(anti_particles) == 172 + else: + assert len(anti_particles) == 175 for anti_particle in anti_particles: particle_name = anti_particle.name.replace("~", "") if "+" in particle_name: @@ -403,11 +426,12 @@ def test_create_antiparticle_tilde(particle_database: ParticleCollection): elif "-" in particle_name: particle_name = particle_name.replace("-", "+") created_particle = create_antiparticle(anti_particle, particle_name) - assert created_particle == particle_database[particle_name] -def test_create_antiparticle_by_pid(particle_database: ParticleCollection): +def test_create_antiparticle_by_pid( + particle_database: ParticleCollection, skh_particle_version: str +): n_particles_with_neg_pid = 0 for particle in particle_database: anti_particles_by_pid = particle_database.filter( @@ -419,11 +443,12 @@ def test_create_antiparticle_by_pid(particle_database: ParticleCollection): anti_particle = next(iter(anti_particles_by_pid)) particle_from_anti = -anti_particle assert particle == particle_from_anti - assert n_particles_with_neg_pid in [ - 428, # particle==0.13 - 442, # particle==0.14,0.15 - 454, # particle==0.16 - ] + if skh_particle_version < "0.14": + assert n_particles_with_neg_pid == 428 + elif skh_particle_version < "0.16": + assert n_particles_with_neg_pid == 442 + else: + assert n_particles_with_neg_pid == 454 @pytest.mark.parametrize( diff --git a/tests/unit/test_system_control.py b/tests/unit/test_system_control.py index a3d140ca..34c0cd3a 100644 --- a/tests/unit/test_system_control.py +++ b/tests/unit/test_system_control.py @@ -1,6 +1,6 @@ import sys from copy import deepcopy -from typing import Dict, List +from typing import Dict, List, Tuple import attrs import pytest @@ -26,6 +26,11 @@ ) from qrules.topology import Edge, MutableTransition, Topology +if sys.version_info < (3, 8): + from importlib_metadata import version +else: + from importlib.metadata import version + @pytest.mark.parametrize( ( @@ -114,6 +119,26 @@ def test_external_edge_initialization( assert len(list(problem_sets.values())[0]) == result_graph_count +def get_pi0_width() -> float: + if version("particle") < "0.16": + return 7.73e-09 + return 7.81e-09 + + +def __get_d_pos() -> Tuple[float, float]: + if version("particle") < "0.16": + return 1.86965, 6.33e-13 + if version("particle") < "0.21": + return 1.86966, 6.33e-13 + return 1.86966, 6.37e-13 + + +def __get_f2_1270_pos() -> Tuple[float, float]: + if version("particle") < "0.23": + return 1.2755, 0.18669999999999998 + return 1.2754, 0.1866 + + @pytest.mark.parametrize( ("particle_name", "spin_projection", "expected_properties"), [ @@ -123,7 +148,7 @@ def test_external_edge_initialization( { EdgeQuantumNumbers.pid: 111, EdgeQuantumNumbers.mass: 0.1349768, - EdgeQuantumNumbers.width: 7.81e-09, + EdgeQuantumNumbers.width: get_pi0_width(), EdgeQuantumNumbers.spin_magnitude: 0.0, EdgeQuantumNumbers.spin_projection: 0, EdgeQuantumNumbers.charge: 0, @@ -147,10 +172,8 @@ def test_external_edge_initialization( 0, { EdgeQuantumNumbers.pid: 411, - EdgeQuantumNumbers.mass: 1.86966, - EdgeQuantumNumbers.width: ( - 6.33e-13 if sys.version_info < (3, 7) else 6.37e-13 - ), + EdgeQuantumNumbers.mass: __get_d_pos()[0], + EdgeQuantumNumbers.width: __get_d_pos()[1], EdgeQuantumNumbers.spin_magnitude: 0.0, EdgeQuantumNumbers.spin_projection: 0, EdgeQuantumNumbers.charge: 1, @@ -174,12 +197,8 @@ def test_external_edge_initialization( 1.0, { EdgeQuantumNumbers.pid: 225, - EdgeQuantumNumbers.mass: ( - 1.2754 if sys.version_info > (3, 7) else 1.2755 - ), - EdgeQuantumNumbers.width: ( - 0.1866 if sys.version_info > (3, 7) else 0.18669999999999998 - ), + EdgeQuantumNumbers.mass: __get_f2_1270_pos()[0], + EdgeQuantumNumbers.width: __get_f2_1270_pos()[1], EdgeQuantumNumbers.spin_magnitude: 2.0, EdgeQuantumNumbers.spin_projection: 1.0, EdgeQuantumNumbers.charge: 0, @@ -201,10 +220,15 @@ def test_external_edge_initialization( ], ) def test_create_edge_properties( - particle_name, spin_projection, expected_properties, particle_database + particle_name, + spin_projection, + expected_properties, + particle_database, + skh_particle_version: str, ): particle = particle_database[particle_name] assert create_edge_properties(particle, spin_projection) == expected_properties + assert skh_particle_version is not None # dummy for skip tests def make_ls_test_graph(angular_momentum_magnitude, coupled_spin_magnitude, particle): From 2085aefda586395da69e0b920a7d4e423b125bda Mon Sep 17 00:00:00 2001 From: GitHub Date: Thu, 6 Jul 2023 20:57:01 +0000 Subject: [PATCH 33/47] MAINT: update pip constraints and pre-commit --- .constraints/py3.10.txt | 16 +++++++++------- .constraints/py3.11.txt | 16 +++++++++------- .constraints/py3.6.txt | 2 +- .constraints/py3.7.txt | 6 +++--- .constraints/py3.8.txt | 16 +++++++++------- .constraints/py3.9.txt | 16 +++++++++------- .pre-commit-config.yaml | 2 +- 7 files changed, 41 insertions(+), 33 deletions(-) diff --git a/.constraints/py3.10.txt b/.constraints/py3.10.txt index 14817d63..2bd24bc2 100644 --- a/.constraints/py3.10.txt +++ b/.constraints/py3.10.txt @@ -8,7 +8,7 @@ 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 aquirdturtle-collapsible-headings==3.1.0 argon2-cffi==21.3.0 argon2-cffi-bindings==21.2.0 @@ -26,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 coverage==7.2.7 @@ -60,7 +60,8 @@ 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-cache==0.6.1 jupyter-client==8.3.0 jupyter-core==5.3.1 @@ -121,8 +122,7 @@ pydata-sphinx-theme==0.13.3 pydot==1.4.2 pygments==2.15.1 pyparsing==3.1.0 -pyproject-api==1.5.2 -pyrsistent==0.19.3 +pyproject-api==1.5.3 pytest==7.4.0 pytest-cov==4.1.0 pytest-profiling==1.7.0 @@ -132,9 +132,11 @@ python-dateutil==2.8.2 python-json-logger==2.0.7 pyyaml==6.0 pyzmq==25.1.0 +referencing==0.29.1 requests==2.31.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 +rpds-py==0.8.8 ruff==0.0.277 ; python_version >= "3.7.0" send2trash==1.8.2 six==1.16.0 @@ -159,14 +161,14 @@ sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 sphobjinv==2.3.1 -sqlalchemy==2.0.17 +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 tqdm==4.65.0 traitlets==5.9.0 types-docutils==0.20.0.1 diff --git a/.constraints/py3.11.txt b/.constraints/py3.11.txt index 986ec320..122e2a37 100644 --- a/.constraints/py3.11.txt +++ b/.constraints/py3.11.txt @@ -8,7 +8,7 @@ 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 aquirdturtle-collapsible-headings==3.1.0 argon2-cffi==21.3.0 argon2-cffi-bindings==21.2.0 @@ -26,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 coverage==7.2.7 @@ -59,7 +59,8 @@ 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-cache==0.6.1 jupyter-client==8.3.0 jupyter-core==5.3.1 @@ -120,8 +121,7 @@ pydata-sphinx-theme==0.13.3 pydot==1.4.2 pygments==2.15.1 pyparsing==3.1.0 -pyproject-api==1.5.2 -pyrsistent==0.19.3 +pyproject-api==1.5.3 pytest==7.4.0 pytest-cov==4.1.0 pytest-profiling==1.7.0 @@ -131,9 +131,11 @@ python-dateutil==2.8.2 python-json-logger==2.0.7 pyyaml==6.0 pyzmq==25.1.0 +referencing==0.29.1 requests==2.31.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 +rpds-py==0.8.8 ruff==0.0.277 ; python_version >= "3.7.0" send2trash==1.8.2 six==1.16.0 @@ -158,13 +160,13 @@ sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 sphobjinv==2.3.1 -sqlalchemy==2.0.17 +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 tqdm==4.65.0 traitlets==5.9.0 types-docutils==0.20.0.1 diff --git a/.constraints/py3.6.txt b/.constraints/py3.6.txt index 6bcb6822..36d22486 100644 --- a/.constraints/py3.6.txt +++ b/.constraints/py3.6.txt @@ -140,7 +140,7 @@ sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 sphobjinv==2.3.1 -sqlalchemy==1.4.48 +sqlalchemy==1.4.49 terminado==0.12.1 testpath==0.6.0 toml==0.10.2 diff --git a/.constraints/py3.7.txt b/.constraints/py3.7.txt index 4b3bf941..4535e27b 100644 --- a/.constraints/py3.7.txt +++ b/.constraints/py3.7.txt @@ -8,7 +8,7 @@ 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 aquirdturtle-collapsible-headings==3.1.0 argon2-cffi==21.3.0 argon2-cffi-bindings==21.2.0 @@ -24,7 +24,7 @@ certifi==2023.5.7 cffi==1.15.1 cfgv==3.3.1 charset-normalizer==3.1.0 -click==8.1.3 +click==8.1.4 colorama==0.4.6 coverage==7.2.7 debugpy==1.6.7 @@ -156,7 +156,7 @@ sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 sphobjinv==2.3.1 -sqlalchemy==1.4.48 +sqlalchemy==1.4.49 tabulate==0.9.0 terminado==0.17.1 tinycss2==1.2.1 diff --git a/.constraints/py3.8.txt b/.constraints/py3.8.txt index 932f87dc..d2a80f06 100644 --- a/.constraints/py3.8.txt +++ b/.constraints/py3.8.txt @@ -8,7 +8,7 @@ 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 aquirdturtle-collapsible-headings==3.1.0 argon2-cffi==21.3.0 argon2-cffi-bindings==21.2.0 @@ -26,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 coverage==7.2.7 @@ -61,7 +61,8 @@ 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-cache==0.6.1 jupyter-client==8.3.0 jupyter-core==5.3.1 @@ -123,8 +124,7 @@ pydata-sphinx-theme==0.13.3 pydot==1.4.2 pygments==2.15.1 pyparsing==3.1.0 -pyproject-api==1.5.2 -pyrsistent==0.19.3 +pyproject-api==1.5.3 pytest==7.4.0 pytest-cov==4.1.0 pytest-profiling==1.7.0 @@ -135,9 +135,11 @@ python-json-logger==2.0.7 pytz==2023.3 pyyaml==6.0 pyzmq==25.1.0 +referencing==0.29.1 requests==2.31.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 +rpds-py==0.8.8 ruff==0.0.277 ; python_version >= "3.7.0" send2trash==1.8.2 six==1.16.0 @@ -162,14 +164,14 @@ sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 sphobjinv==2.3.1 -sqlalchemy==2.0.17 +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 tqdm==4.65.0 traitlets==5.9.0 types-docutils==0.20.0.1 diff --git a/.constraints/py3.9.txt b/.constraints/py3.9.txt index df841d49..6ed08794 100644 --- a/.constraints/py3.9.txt +++ b/.constraints/py3.9.txt @@ -8,7 +8,7 @@ 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 aquirdturtle-collapsible-headings==3.1.0 argon2-cffi==21.3.0 argon2-cffi-bindings==21.2.0 @@ -26,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 coverage==7.2.7 @@ -60,7 +60,8 @@ 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-cache==0.6.1 jupyter-client==8.3.0 jupyter-core==5.3.1 @@ -121,8 +122,7 @@ pydata-sphinx-theme==0.13.3 pydot==1.4.2 pygments==2.15.1 pyparsing==3.1.0 -pyproject-api==1.5.2 -pyrsistent==0.19.3 +pyproject-api==1.5.3 pytest==7.4.0 pytest-cov==4.1.0 pytest-profiling==1.7.0 @@ -132,9 +132,11 @@ python-dateutil==2.8.2 python-json-logger==2.0.7 pyyaml==6.0 pyzmq==25.1.0 +referencing==0.29.1 requests==2.31.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 +rpds-py==0.8.8 ruff==0.0.277 ; python_version >= "3.7.0" send2trash==1.8.2 six==1.16.0 @@ -159,14 +161,14 @@ sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 sphobjinv==2.3.1 -sqlalchemy==2.0.17 +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 tqdm==4.65.0 traitlets==5.9.0 types-docutils==0.20.0.1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c88d6612..fc5201ac 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -131,7 +131,7 @@ 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 From 65743153e5f14744032b90b0807ee4eb7c6101ea Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Thu, 6 Jul 2023 23:43:16 +0200 Subject: [PATCH 34/47] MAINT: remove remaining `pydocstyle` config --- typings/.pydocstyle | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 typings/.pydocstyle diff --git a/typings/.pydocstyle b/typings/.pydocstyle deleted file mode 100644 index 26d0703b..00000000 --- a/typings/.pydocstyle +++ /dev/null @@ -1,4 +0,0 @@ -; ignore all pydocstyle errors in this folder - -[pydocstyle] -add_ignore = D From f153d066112c7b07ea0ff4e305037ac98dbc632f Mon Sep 17 00:00:00 2001 From: GitHub Date: Thu, 6 Jul 2023 22:08:48 +0000 Subject: [PATCH 35/47] MAINT: update pip constraints and pre-commit --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fc5201ac..140fb329 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,7 +36,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/ComPWA/repo-maintenance - rev: 0.0.186 + rev: 0.0.187 hooks: - id: check-dev-files args: From a149cfb91900c807b150bc9d88db0c09518a0b89 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 6 Jul 2023 22:09:28 +0000 Subject: [PATCH 36/47] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .gitpod.yml | 1 + .vscode/extensions.json | 1 + .vscode/settings.json | 5 +++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitpod.yml b/.gitpod.yml index 91999103..11d00d80 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -24,6 +24,7 @@ vscode: - github.vscode-github-actions - github.vscode-pull-request-github - joaompinto.vscode-graphviz + - ms-python.mypy-type-checker - ms-python.python - ms-python.vscode-pylance - ms-vscode.live-server diff --git a/.vscode/extensions.json b/.vscode/extensions.json index b00915fb..6fa95bff 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -11,6 +11,7 @@ "github.vscode-github-actions", "github.vscode-pull-request-github", "joaompinto.vscode-graphviz", + "ms-python.mypy-type-checker", "ms-python.python", "ms-python.vscode-pylance", "ms-vscode.live-server", diff --git a/.vscode/settings.json b/.vscode/settings.json index bb870cbc..5d6ae475 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -23,11 +23,11 @@ "[yaml]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, + "cSpell.enabled": true, "coverage-gutters.coverageFileNames": ["coverage.xml"], "coverage-gutters.coverageReportFileName": "**/htmlcov/index.html", "coverage-gutters.showGutterCoverage": false, "coverage-gutters.showLineCoverage": true, - "cSpell.enabled": true, "editor.formatOnSave": true, "editor.rulers": [88], "files.watcherExclude": { @@ -49,6 +49,7 @@ } ], "livePreview.defaultPreviewPath": "docs/_build/html", + "mypy-type-checker.importStrategy": "fromEnvironment", "python.analysis.autoImportCompletions": false, "python.analysis.inlayHints.pytestParameters": true, "python.analysis.typeCheckingMode": "strict", @@ -56,7 +57,7 @@ "python.linting.banditEnabled": false, "python.linting.enabled": true, "python.linting.flake8Enabled": false, - "python.linting.mypyEnabled": true, + "python.linting.mypyEnabled": false, "python.linting.pydocstyleEnabled": false, "python.linting.pylamaEnabled": false, "python.linting.pylintEnabled": false, From db180c464cc916e8720e70fa8cb63a9aa57db10e Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Fri, 7 Jul 2023 00:28:53 +0200 Subject: [PATCH 37/47] DX: recommend VSCode mypy extension --- .cspell.json | 1 - .pre-commit-config.yaml | 2 +- .vscode/settings.json | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.cspell.json b/.cspell.json index 5ce525fe..21dd573d 100644 --- a/.cspell.json +++ b/.cspell.json @@ -202,7 +202,6 @@ "mathbb", "mypy", "nishijima", - "pydocstyle", "pydot", "pyplot", "pytest", diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 140fb329..474f8a47 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,7 +36,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/ComPWA/repo-maintenance - rev: 0.0.187 + rev: 0.0.189 hooks: - id: check-dev-files args: diff --git a/.vscode/settings.json b/.vscode/settings.json index 5d6ae475..4a7281fa 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -23,11 +23,11 @@ "[yaml]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, - "cSpell.enabled": true, "coverage-gutters.coverageFileNames": ["coverage.xml"], "coverage-gutters.coverageReportFileName": "**/htmlcov/index.html", "coverage-gutters.showGutterCoverage": false, "coverage-gutters.showLineCoverage": true, + "cSpell.enabled": true, "editor.formatOnSave": true, "editor.rulers": [88], "files.watcherExclude": { From a19df6a340a290c34398640a472235ccca7e0aa3 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Fri, 7 Jul 2023 01:52:30 +0200 Subject: [PATCH 38/47] DX!: remove `aquirdturtle-collapsible-headings` --- setup.cfg | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 01d65511..55abca44 100644 --- a/setup.cfg +++ b/setup.cfg @@ -104,7 +104,6 @@ sty = %(test)s # for pytest type hints pre-commit >=1.4.0 jupyter = - aquirdturtle-collapsible-headings ipywidgets jupyterlab jupyterlab-code-formatter From 44fe8eac6d187099cdcaf266fcb28fddd30f46e2 Mon Sep 17 00:00:00 2001 From: GitHub Date: Thu, 6 Jul 2023 23:54:26 +0000 Subject: [PATCH 39/47] MAINT: update pip constraints and pre-commit --- .constraints/py3.10.txt | 11 +++-------- .constraints/py3.11.txt | 11 +++-------- .constraints/py3.6.txt | 1 - .constraints/py3.7.txt | 1 - .constraints/py3.8.txt | 11 +++-------- .constraints/py3.9.txt | 11 +++-------- 6 files changed, 12 insertions(+), 34 deletions(-) diff --git a/.constraints/py3.10.txt b/.constraints/py3.10.txt index 2bd24bc2..127c71ee 100644 --- a/.constraints/py3.10.txt +++ b/.constraints/py3.10.txt @@ -9,11 +9,11 @@ aiofiles==22.1.0 aiosqlite==0.19.0 alabaster==0.7.13 anyio==3.7.1 -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 @@ -53,7 +53,6 @@ importlib-metadata==6.7.0 iniconfig==2.0.0 ipykernel==6.24.0 ipython==8.14.0 -ipython-genutils==0.2.0 ipywidgets==8.0.7 isoduration==20.11.0 jedi==0.18.2 @@ -66,12 +65,10 @@ jupyter-cache==0.6.1 jupyter-client==8.3.0 jupyter-core==5.3.1 jupyter-events==0.6.3 +jupyter-lsp==2.2.0 jupyter-server==2.7.0 -jupyter-server-fileid==0.9.0 jupyter-server-terminals==0.4.4 -jupyter-server-ydoc==0.8.0 -jupyter-ydoc==0.2.4 -jupyterlab==3.6.5 +jupyterlab==4.0.2 jupyterlab-code-formatter==2.2.1 jupyterlab-myst==2.0.1 ; python_version >= "3.7.0" jupyterlab-pygments==0.2.2 @@ -89,14 +86,12 @@ mypy==1.4.1 mypy-extensions==1.0.0 myst-nb==0.17.2 myst-parser==0.18.1 -nbclassic==1.0.0 nbclient==0.5.13 nbconvert==7.6.0 nbformat==5.9.0 nbmake==1.2.1 nest-asyncio==1.5.6 nodeenv==1.8.0 -notebook==6.5.4 notebook-shim==0.2.3 overrides==7.3.1 packaging==23.1 diff --git a/.constraints/py3.11.txt b/.constraints/py3.11.txt index 122e2a37..b7c6b7ca 100644 --- a/.constraints/py3.11.txt +++ b/.constraints/py3.11.txt @@ -9,11 +9,11 @@ aiofiles==22.1.0 aiosqlite==0.19.0 alabaster==0.7.13 anyio==3.7.1 -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 @@ -52,7 +52,6 @@ importlib-metadata==6.7.0 iniconfig==2.0.0 ipykernel==6.24.0 ipython==8.14.0 -ipython-genutils==0.2.0 ipywidgets==8.0.7 isoduration==20.11.0 jedi==0.18.2 @@ -65,12 +64,10 @@ jupyter-cache==0.6.1 jupyter-client==8.3.0 jupyter-core==5.3.1 jupyter-events==0.6.3 +jupyter-lsp==2.2.0 jupyter-server==2.7.0 -jupyter-server-fileid==0.9.0 jupyter-server-terminals==0.4.4 -jupyter-server-ydoc==0.8.0 -jupyter-ydoc==0.2.4 -jupyterlab==3.6.5 +jupyterlab==4.0.2 jupyterlab-code-formatter==2.2.1 jupyterlab-myst==2.0.1 ; python_version >= "3.7.0" jupyterlab-pygments==0.2.2 @@ -88,14 +85,12 @@ mypy==1.4.1 mypy-extensions==1.0.0 myst-nb==0.17.2 myst-parser==0.18.1 -nbclassic==1.0.0 nbclient==0.5.13 nbconvert==7.6.0 nbformat==5.9.0 nbmake==1.2.1 nest-asyncio==1.5.6 nodeenv==1.8.0 -notebook==6.5.4 notebook-shim==0.2.3 overrides==7.3.1 packaging==23.1 diff --git a/.constraints/py3.6.txt b/.constraints/py3.6.txt index 36d22486..d4af84b2 100644 --- a/.constraints/py3.6.txt +++ b/.constraints/py3.6.txt @@ -6,7 +6,6 @@ # alabaster==0.7.13 anyio==3.6.2 -aquirdturtle-collapsible-headings==3.1.0 argon2-cffi==21.3.0 argon2-cffi-bindings==21.2.0 async-generator==1.10 diff --git a/.constraints/py3.7.txt b/.constraints/py3.7.txt index 4535e27b..926014f2 100644 --- a/.constraints/py3.7.txt +++ b/.constraints/py3.7.txt @@ -9,7 +9,6 @@ aiofiles==22.1.0 aiosqlite==0.19.0 alabaster==0.7.13 anyio==3.7.1 -aquirdturtle-collapsible-headings==3.1.0 argon2-cffi==21.3.0 argon2-cffi-bindings==21.2.0 arrow==1.2.3 diff --git a/.constraints/py3.8.txt b/.constraints/py3.8.txt index d2a80f06..f496ccd8 100644 --- a/.constraints/py3.8.txt +++ b/.constraints/py3.8.txt @@ -9,11 +9,11 @@ aiofiles==22.1.0 aiosqlite==0.19.0 alabaster==0.7.13 anyio==3.7.1 -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 @@ -54,7 +54,6 @@ importlib-resources==5.12.0 iniconfig==2.0.0 ipykernel==6.24.0 ipython==8.12.2 -ipython-genutils==0.2.0 ipywidgets==8.0.7 isoduration==20.11.0 jedi==0.18.2 @@ -67,12 +66,10 @@ jupyter-cache==0.6.1 jupyter-client==8.3.0 jupyter-core==5.3.1 jupyter-events==0.6.3 +jupyter-lsp==2.2.0 jupyter-server==2.7.0 -jupyter-server-fileid==0.9.0 jupyter-server-terminals==0.4.4 -jupyter-server-ydoc==0.8.0 -jupyter-ydoc==0.2.4 -jupyterlab==3.6.5 +jupyterlab==4.0.2 jupyterlab-code-formatter==2.2.1 jupyterlab-myst==2.0.1 ; python_version >= "3.7.0" jupyterlab-pygments==0.2.2 @@ -90,14 +87,12 @@ mypy==1.4.1 mypy-extensions==1.0.0 myst-nb==0.17.2 myst-parser==0.18.1 -nbclassic==1.0.0 nbclient==0.5.13 nbconvert==7.6.0 nbformat==5.9.0 nbmake==1.2.1 nest-asyncio==1.5.6 nodeenv==1.8.0 -notebook==6.5.4 notebook-shim==0.2.3 overrides==7.3.1 packaging==23.1 diff --git a/.constraints/py3.9.txt b/.constraints/py3.9.txt index 6ed08794..bf0e1da9 100644 --- a/.constraints/py3.9.txt +++ b/.constraints/py3.9.txt @@ -9,11 +9,11 @@ aiofiles==22.1.0 aiosqlite==0.19.0 alabaster==0.7.13 anyio==3.7.1 -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 @@ -53,7 +53,6 @@ importlib-metadata==6.7.0 iniconfig==2.0.0 ipykernel==6.24.0 ipython==8.14.0 -ipython-genutils==0.2.0 ipywidgets==8.0.7 isoduration==20.11.0 jedi==0.18.2 @@ -66,12 +65,10 @@ jupyter-cache==0.6.1 jupyter-client==8.3.0 jupyter-core==5.3.1 jupyter-events==0.6.3 +jupyter-lsp==2.2.0 jupyter-server==2.7.0 -jupyter-server-fileid==0.9.0 jupyter-server-terminals==0.4.4 -jupyter-server-ydoc==0.8.0 -jupyter-ydoc==0.2.4 -jupyterlab==3.6.5 +jupyterlab==4.0.2 jupyterlab-code-formatter==2.2.1 jupyterlab-myst==2.0.1 ; python_version >= "3.7.0" jupyterlab-pygments==0.2.2 @@ -89,14 +86,12 @@ mypy==1.4.1 mypy-extensions==1.0.0 myst-nb==0.17.2 myst-parser==0.18.1 -nbclassic==1.0.0 nbclient==0.5.13 nbconvert==7.6.0 nbformat==5.9.0 nbmake==1.2.1 nest-asyncio==1.5.6 nodeenv==1.8.0 -notebook==6.5.4 notebook-shim==0.2.3 overrides==7.3.1 packaging==23.1 From 7e88b668289b82bf524b9e035735ba2dca5dd484 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Fri, 7 Jul 2023 01:57:52 +0200 Subject: [PATCH 40/47] MAINT: remove `ypy-websocket` restriction --- setup.cfg | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 55abca44..3e4c3f1a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -108,7 +108,6 @@ jupyter = jupyterlab jupyterlab-code-formatter jupyterlab-myst; python_version >="3.7.0" - ypy-websocket <0.8.3; python_version >="3.7.0" # https://github.com/ComPWA/qrules/actions/runs/4350315417/jobs/7600906057#step:3:79 dev = %(all)s %(doc)s From feecbba8dc663f74374110057d07649e8f1af9e1 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Fri, 7 Jul 2023 02:06:16 +0200 Subject: [PATCH 41/47] FIX: restrict `ypy-websocket` below Python 3.8 --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index 3e4c3f1a..07729ced 100644 --- a/setup.cfg +++ b/setup.cfg @@ -108,6 +108,7 @@ jupyter = jupyterlab jupyterlab-code-formatter jupyterlab-myst; python_version >="3.7.0" + ypy-websocket <0.8.3; python_version <"3.8.0" dev = %(all)s %(doc)s From 0addc3bb7ee25a552c5b16e52b691c899d85d70b Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Fri, 7 Jul 2023 02:06:32 +0200 Subject: [PATCH 42/47] MAINT: remove `tox` restriction --- setup.cfg | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 07729ced..1166c50d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -117,7 +117,6 @@ dev = %(test)s sphinx-autobuild tox >=1.9 # for skip_install, use_develop - tox !=4.*; python_version <"3.8.0" # https://github.com/ComPWA/qrules/actions/runs/4116409504/jobs/7106431526#step:3:92 virtualenv !=20.16.*; python_version <"3.7.0" # https://github.com/ComPWA/qrules/actions/runs/4116487921/jobs/7106603597#step:3:78 virtualenv !=20.17.*; python_version <"3.7.0" # https://github.com/ComPWA/qrules/actions/runs/4116447949/jobs/7106515800#step:3:78 From 048bf78f21bcdab9c25e7e8fcdbad0fa78b4c3fa Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Fri, 7 Jul 2023 02:14:58 +0200 Subject: [PATCH 43/47] FIX: use correct `ypy-websocket` syntax --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 1166c50d..b1be7c83 100644 --- a/setup.cfg +++ b/setup.cfg @@ -108,7 +108,7 @@ jupyter = jupyterlab jupyterlab-code-formatter jupyterlab-myst; python_version >="3.7.0" - ypy-websocket <0.8.3; python_version <"3.8.0" + ypy-websocket <0.8.3; python_version=="3.7.*" dev = %(all)s %(doc)s From 75843ae52d8752721d9984a41f5fcfd3703b94db Mon Sep 17 00:00:00 2001 From: GitHub Date: Fri, 7 Jul 2023 00:17:00 +0000 Subject: [PATCH 44/47] MAINT: update pip constraints and pre-commit --- .constraints/py3.10.txt | 6 +----- .constraints/py3.11.txt | 6 +----- .constraints/py3.6.txt | 2 +- .constraints/py3.7.txt | 10 ++++++---- .constraints/py3.8.txt | 6 +----- .constraints/py3.9.txt | 6 +----- 6 files changed, 11 insertions(+), 25 deletions(-) diff --git a/.constraints/py3.10.txt b/.constraints/py3.10.txt index 127c71ee..d67f0592 100644 --- a/.constraints/py3.10.txt +++ b/.constraints/py3.10.txt @@ -5,8 +5,6 @@ # 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.1 argon2-cffi==21.3.0 @@ -101,7 +99,7 @@ particle==0.23.0 pathspec==0.11.1 pexpect==4.8.0 pickleshare==0.7.5 -platformdirs==3.8.0 +platformdirs==3.8.1 pluggy==1.2.0 pre-commit==3.3.3 prometheus-client==0.17.0 @@ -183,8 +181,6 @@ websocket-client==1.6.1 wheel==0.40.0 widgetsnbextension==4.0.8 wrapt==1.15.0 -y-py==0.5.9 -ypy-websocket==0.8.2 ; python_version >= "3.7.0" 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 b7c6b7ca..c9e6d94e 100644 --- a/.constraints/py3.11.txt +++ b/.constraints/py3.11.txt @@ -5,8 +5,6 @@ # 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.1 argon2-cffi==21.3.0 @@ -100,7 +98,7 @@ particle==0.23.0 pathspec==0.11.1 pexpect==4.8.0 pickleshare==0.7.5 -platformdirs==3.8.0 +platformdirs==3.8.1 pluggy==1.2.0 pre-commit==3.3.3 prometheus-client==0.17.0 @@ -181,8 +179,6 @@ websocket-client==1.6.1 wheel==0.40.0 widgetsnbextension==4.0.8 wrapt==1.15.0 -y-py==0.5.9 -ypy-websocket==0.8.2 ; python_version >= "3.7.0" zipp==3.15.0 # The following packages are considered to be unsafe in a requirements file: diff --git a/.constraints/py3.6.txt b/.constraints/py3.6.txt index d4af84b2..c80a8bf0 100644 --- a/.constraints/py3.6.txt +++ b/.constraints/py3.6.txt @@ -145,7 +145,7 @@ testpath==0.6.0 toml==0.10.2 tomli==1.2.3 tornado==6.1 -tox==3.28.0 ; python_version < "3.8.0" +tox==3.28.0 tqdm==4.64.1 traitlets==4.3.3 typed-ast==1.5.5 diff --git a/.constraints/py3.7.txt b/.constraints/py3.7.txt index 926014f2..4dbea0d1 100644 --- a/.constraints/py3.7.txt +++ b/.constraints/py3.7.txt @@ -19,9 +19,11 @@ beautifulsoup4==4.12.2 black==23.3.0 bleach==6.0.0 cached-property==1.5.2 +cachetools==5.3.1 certifi==2023.5.7 cffi==1.15.1 cfgv==3.3.1 +chardet==5.1.0 charset-normalizer==3.1.0 click==8.1.4 colorama==0.4.6 @@ -101,14 +103,13 @@ pathspec==0.11.1 pexpect==4.8.0 pickleshare==0.7.5 pkgutil-resolve-name==1.3.10 -platformdirs==3.8.0 +platformdirs==3.8.1 pluggy==1.2.0 pre-commit==2.21.0 prometheus-client==0.17.0 prompt-toolkit==3.0.39 psutil==5.9.5 ptyprocess==0.7.0 -py==1.11.0 pybtex==0.24.0 pybtex-docutils==1.0.2 pycparser==2.21 @@ -117,6 +118,7 @@ pydata-sphinx-theme==0.13.3 pydot==1.4.2 pygments==2.15.1 pyparsing==3.1.0 +pyproject-api==1.5.3 pyrsistent==0.19.3 pytest==7.4.0 pytest-cov==4.1.0 @@ -161,7 +163,7 @@ 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.6.4 tqdm==4.65.0 traitlets==5.9.0 typed-ast==1.5.5 @@ -183,7 +185,7 @@ wheel==0.40.0 widgetsnbextension==4.0.8 wrapt==1.15.0 y-py==0.5.9 -ypy-websocket==0.8.2 ; python_version >= "3.7.0" +ypy-websocket==0.8.2 ; python_version == "3.7.*" 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 f496ccd8..4551a6ae 100644 --- a/.constraints/py3.8.txt +++ b/.constraints/py3.8.txt @@ -5,8 +5,6 @@ # 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.1 argon2-cffi==21.3.0 @@ -103,7 +101,7 @@ pathspec==0.11.1 pexpect==4.8.0 pickleshare==0.7.5 pkgutil-resolve-name==1.3.10 -platformdirs==3.8.0 +platformdirs==3.8.1 pluggy==1.2.0 pre-commit==3.3.3 prometheus-client==0.17.0 @@ -186,8 +184,6 @@ websocket-client==1.6.1 wheel==0.40.0 widgetsnbextension==4.0.8 wrapt==1.15.0 -y-py==0.5.9 -ypy-websocket==0.8.2 ; python_version >= "3.7.0" 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 bf0e1da9..bd036fe7 100644 --- a/.constraints/py3.9.txt +++ b/.constraints/py3.9.txt @@ -5,8 +5,6 @@ # 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.1 argon2-cffi==21.3.0 @@ -101,7 +99,7 @@ particle==0.23.0 pathspec==0.11.1 pexpect==4.8.0 pickleshare==0.7.5 -platformdirs==3.8.0 +platformdirs==3.8.1 pluggy==1.2.0 pre-commit==3.3.3 prometheus-client==0.17.0 @@ -183,8 +181,6 @@ websocket-client==1.6.1 wheel==0.40.0 widgetsnbextension==4.0.8 wrapt==1.15.0 -y-py==0.5.9 -ypy-websocket==0.8.2 ; python_version >= "3.7.0" zipp==3.15.0 # The following packages are considered to be unsafe in a requirements file: From aa4f973cfaeef8faaf14af0241e57bfdd15497e3 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Fri, 7 Jul 2023 02:21:32 +0200 Subject: [PATCH 45/47] MAINT: remove `nbmake` restrictions --- .constraints/py3.8.txt | 4 ++-- setup.cfg | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.constraints/py3.8.txt b/.constraints/py3.8.txt index 4551a6ae..1342192c 100644 --- a/.constraints/py3.8.txt +++ b/.constraints/py3.8.txt @@ -85,10 +85,10 @@ mypy==1.4.1 mypy-extensions==1.0.0 myst-nb==0.17.2 myst-parser==0.18.1 -nbclient==0.5.13 +nbclient==0.6.8 nbconvert==7.6.0 nbformat==5.9.0 -nbmake==1.2.1 +nbmake==1.4.1 nest-asyncio==1.5.6 nodeenv==1.8.0 notebook-shim==0.2.3 diff --git a/setup.cfg b/setup.cfg index b1be7c83..e532af51 100644 --- a/setup.cfg +++ b/setup.cfg @@ -79,8 +79,6 @@ test = importlib-metadata; python_version <"3.8.0" ipython nbmake - nbmake !=1.3.* # https://github.com/ComPWA/qrules/actions/runs/4116315964/jobs/7106216956#step:3:84 - nbmake !=1.4.* # https://github.com/ComPWA/qrules/actions/runs/4115785437/jobs/7104974879#step:3:82 pydot pytest pytest-cov From 729f6943f4abef97d205021e10204aacfd2a4bc3 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Fri, 7 Jul 2023 02:29:25 +0200 Subject: [PATCH 46/47] MAINT: restrict `nbmake` only for Python 3.7 --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index e532af51..376c6931 100644 --- a/setup.cfg +++ b/setup.cfg @@ -79,6 +79,7 @@ test = importlib-metadata; python_version <"3.8.0" ipython nbmake + nbmake <1.3; python_version=="3.7.*" pydot pytest pytest-cov From fb142b920aa7f6f7a15d35f6b15fd1c34a157c74 Mon Sep 17 00:00:00 2001 From: GitHub Date: Fri, 7 Jul 2023 00:31:11 +0000 Subject: [PATCH 47/47] MAINT: update pip constraints and pre-commit --- .constraints/py3.10.txt | 4 ++-- .constraints/py3.11.txt | 4 ++-- .constraints/py3.7.txt | 2 +- .constraints/py3.9.txt | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.constraints/py3.10.txt b/.constraints/py3.10.txt index d67f0592..35d2f964 100644 --- a/.constraints/py3.10.txt +++ b/.constraints/py3.10.txt @@ -84,10 +84,10 @@ mypy==1.4.1 mypy-extensions==1.0.0 myst-nb==0.17.2 myst-parser==0.18.1 -nbclient==0.5.13 +nbclient==0.6.8 nbconvert==7.6.0 nbformat==5.9.0 -nbmake==1.2.1 +nbmake==1.4.1 nest-asyncio==1.5.6 nodeenv==1.8.0 notebook-shim==0.2.3 diff --git a/.constraints/py3.11.txt b/.constraints/py3.11.txt index c9e6d94e..0c603f0b 100644 --- a/.constraints/py3.11.txt +++ b/.constraints/py3.11.txt @@ -83,10 +83,10 @@ mypy==1.4.1 mypy-extensions==1.0.0 myst-nb==0.17.2 myst-parser==0.18.1 -nbclient==0.5.13 +nbclient==0.6.8 nbconvert==7.6.0 nbformat==5.9.0 -nbmake==1.2.1 +nbmake==1.4.1 nest-asyncio==1.5.6 nodeenv==1.8.0 notebook-shim==0.2.3 diff --git a/.constraints/py3.7.txt b/.constraints/py3.7.txt index 4dbea0d1..dd43ccc0 100644 --- a/.constraints/py3.7.txt +++ b/.constraints/py3.7.txt @@ -90,7 +90,7 @@ nbclassic==1.0.0 nbclient==0.5.13 nbconvert==7.6.0 nbformat==5.8.0 -nbmake==1.2.1 +nbmake==1.2.1 ; python_version == "3.7.*" nest-asyncio==1.5.6 nodeenv==1.8.0 notebook==6.5.4 diff --git a/.constraints/py3.9.txt b/.constraints/py3.9.txt index bd036fe7..d9f6e978 100644 --- a/.constraints/py3.9.txt +++ b/.constraints/py3.9.txt @@ -84,10 +84,10 @@ mypy==1.4.1 mypy-extensions==1.0.0 myst-nb==0.17.2 myst-parser==0.18.1 -nbclient==0.5.13 +nbclient==0.6.8 nbconvert==7.6.0 nbformat==5.9.0 -nbmake==1.2.1 +nbmake==1.4.1 nest-asyncio==1.5.6 nodeenv==1.8.0 notebook-shim==0.2.3