From 837923872c85e43b765ee7c5a3d6e415d8e330ad Mon Sep 17 00:00:00 2001 From: Remco de Boer Date: Sun, 30 Jan 2022 23:27:37 +0100 Subject: [PATCH] docs: automatically link code examples to API (#147) * build: install jupyterlab-myst * build: install sphinx-codeautolink * chore: rename to abbreviate_signature script to _relink_references.py * ci: update pip constraints and pre-commit config * ci: use black --preview flag * docs: activate sphinx_codeautolink extension * fix: use correct syntax for myst refs * style: format with black 22.1.0 style Co-authored-by: GitHub Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .constraints/py3.10.txt | 14 ++++---- .constraints/py3.6.txt | 10 +++--- .constraints/py3.7.txt | 14 ++++---- .constraints/py3.8.txt | 14 ++++---- .constraints/py3.9.txt | 14 ++++---- .cspell.json | 1 + .pre-commit-config.yaml | 8 +++-- ...ate_signature.py => _relink_references.py} | 34 +++++++++++-------- docs/conf.py | 6 ++-- docs/usage.ipynb | 8 +++++ docs/usage/conservation.ipynb | 8 +++++ docs/usage/custom-topology.ipynb | 8 +++++ docs/usage/ls-coupling.ipynb | 10 +++++- docs/usage/particle.ipynb | 8 +++++ docs/usage/reaction.ipynb | 10 +++++- docs/usage/visualize.ipynb | 12 +++++-- pyproject.toml | 2 +- setup.cfg | 2 ++ src/qrules/particle.py | 2 +- 19 files changed, 131 insertions(+), 54 deletions(-) rename docs/{abbreviate_signature.py => _relink_references.py} (64%) diff --git a/.constraints/py3.10.txt b/.constraints/py3.10.txt index 51b286d0..1d6ce413 100644 --- a/.constraints/py3.10.txt +++ b/.constraints/py3.10.txt @@ -15,12 +15,12 @@ attrs==21.4.0 babel==2.9.1 backcall==0.2.0 beautifulsoup4==4.10.0 -black==21.12b0 +black==22.1.0 bleach==4.1.0 certifi==2021.10.8 cffi==1.15.0 cfgv==3.3.1 -charset-normalizer==2.0.10 +charset-normalizer==2.0.11 click==8.0.3 colorama==0.4.4 coverage==6.3 @@ -45,7 +45,6 @@ flake8-pytest-style==1.6.0 flake8-rst-docstrings==0.2.5 flake8-type-ignore==0.1.0.post2 ; python_version >= "3.8.0" flake8-use-fstring==1.3 -fuzzywuzzy==0.18.0 gitdb==4.0.9 gitpython==3.1.26 gprof2dot==2021.2.21 @@ -76,6 +75,8 @@ jupyter-server-mathjax==0.2.3 jupyter-sphinx==0.3.2 jupyterlab==3.2.8 jupyterlab-code-formatter==1.4.10 +jupyterlab-markup==1.0.1 +jupyterlab-myst==0.1.6 ; python_version >= "3.7.0" jupyterlab-pygments==0.1.2 jupyterlab-server==2.10.3 jupyterlab-widgets==1.0.2 @@ -155,6 +156,7 @@ soupsieve==2.3.1 sphinx==4.4.0 sphinx-autobuild==2021.3.14 sphinx-book-theme==0.2.0 +sphinx-codeautolink==0.10.0 sphinx-copybutton==0.4.0 sphinx-panels==0.6.0 sphinx-thebe==0.0.10 @@ -167,13 +169,13 @@ sphinxcontrib-htmlhelp==2.0.0 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 -sphobjinv==2.1 +sphobjinv==2.2 sqlalchemy==1.4.31 stack-data==0.1.4 terminado==0.13.1 testpath==0.5.0 toml==0.10.2 -tomli==1.2.3 +tomli==2.0.0 tornado==6.1 tox==3.24.5 tqdm==4.62.3 @@ -182,7 +184,7 @@ types-docutils==0.17.4 types-pkg-resources==0.1.3 types-pyyaml==6.0.3 types-requests==2.27.7 -types-setuptools==57.4.7 +types-setuptools==57.4.8 types-urllib3==1.26.7 typing-extensions==4.0.1 urllib3==1.26.8 diff --git a/.constraints/py3.6.txt b/.constraints/py3.6.txt index cf85939b..1699cf42 100644 --- a/.constraints/py3.6.txt +++ b/.constraints/py3.6.txt @@ -15,12 +15,12 @@ attrs==21.4.0 babel==2.9.1 backcall==0.2.0 beautifulsoup4==4.10.0 -black==21.12b0 +black==22.1.0 bleach==4.1.0 certifi==2021.10.8 cffi==1.15.0 cfgv==3.3.1 -charset-normalizer==2.0.10 +charset-normalizer==2.0.11 click==8.0.3 colorama==0.4.4 contextvars==2.4 @@ -44,7 +44,6 @@ flake8-polyfill==1.0.2 flake8-pytest-style==1.6.0 flake8-rst-docstrings==0.2.5 flake8-use-fstring==1.3 -fuzzywuzzy==0.18.0 gitdb==4.0.9 gitpython==3.1.18 gprof2dot==2021.2.21 @@ -154,6 +153,7 @@ soupsieve==2.3.1 sphinx==4.3.2 ; python_version < "3.8.0" sphinx-autobuild==2021.3.14 sphinx-book-theme==0.2.0 +sphinx-codeautolink==0.10.0 sphinx-copybutton==0.4.0 sphinx-panels==0.6.0 sphinx-thebe==0.0.10 @@ -166,7 +166,7 @@ sphinxcontrib-htmlhelp==2.0.0 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 -sphobjinv==2.1 +sphobjinv==2.2 sqlalchemy==1.4.31 terminado==0.12.1 testpath==0.5.0 @@ -181,7 +181,7 @@ types-docutils==0.17.4 types-pkg-resources==0.1.3 types-pyyaml==6.0.3 types-requests==2.27.7 -types-setuptools==57.4.7 +types-setuptools==57.4.8 types-urllib3==1.26.7 typing-extensions==4.0.1 ; python_version < "3.8.0" urllib3==1.26.8 diff --git a/.constraints/py3.7.txt b/.constraints/py3.7.txt index 68361c62..ca705e2b 100644 --- a/.constraints/py3.7.txt +++ b/.constraints/py3.7.txt @@ -14,12 +14,12 @@ attrs==21.4.0 babel==2.9.1 backcall==0.2.0 beautifulsoup4==4.10.0 -black==21.12b0 +black==22.1.0 bleach==4.1.0 certifi==2021.10.8 cffi==1.15.0 cfgv==3.3.1 -charset-normalizer==2.0.10 +charset-normalizer==2.0.11 click==8.0.3 colorama==0.4.4 coverage==6.3 @@ -42,7 +42,6 @@ flake8-polyfill==1.0.2 flake8-pytest-style==1.6.0 flake8-rst-docstrings==0.2.5 flake8-use-fstring==1.3 -fuzzywuzzy==0.18.0 gitdb==4.0.9 gitpython==3.1.26 gprof2dot==2021.2.21 @@ -74,6 +73,8 @@ jupyter-server-mathjax==0.2.3 jupyter-sphinx==0.3.2 jupyterlab==3.2.8 jupyterlab-code-formatter==1.4.10 +jupyterlab-markup==1.0.1 +jupyterlab-myst==0.1.6 ; python_version >= "3.7.0" jupyterlab-pygments==0.1.2 jupyterlab-server==2.10.3 jupyterlab-widgets==1.0.2 @@ -152,6 +153,7 @@ soupsieve==2.3.1 sphinx==4.3.2 ; python_version < "3.8.0" sphinx-autobuild==2021.3.14 sphinx-book-theme==0.2.0 +sphinx-codeautolink==0.10.0 sphinx-copybutton==0.4.0 sphinx-panels==0.6.0 sphinx-thebe==0.0.10 @@ -164,12 +166,12 @@ sphinxcontrib-htmlhelp==2.0.0 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 -sphobjinv==2.1 +sphobjinv==2.2 sqlalchemy==1.4.31 terminado==0.13.1 testpath==0.5.0 toml==0.10.2 -tomli==1.2.3 +tomli==2.0.0 tornado==6.1 tox==3.24.5 tqdm==4.62.3 @@ -179,7 +181,7 @@ types-docutils==0.17.4 types-pkg-resources==0.1.3 types-pyyaml==6.0.3 types-requests==2.27.7 -types-setuptools==57.4.7 +types-setuptools==57.4.8 types-urllib3==1.26.7 typing-extensions==4.0.1 ; python_version < "3.8.0" urllib3==1.26.8 diff --git a/.constraints/py3.8.txt b/.constraints/py3.8.txt index 1df5589c..f0ae50e6 100644 --- a/.constraints/py3.8.txt +++ b/.constraints/py3.8.txt @@ -15,12 +15,12 @@ attrs==21.4.0 babel==2.9.1 backcall==0.2.0 beautifulsoup4==4.10.0 -black==21.12b0 +black==22.1.0 bleach==4.1.0 certifi==2021.10.8 cffi==1.15.0 cfgv==3.3.1 -charset-normalizer==2.0.10 +charset-normalizer==2.0.11 click==8.0.3 colorama==0.4.4 coverage==6.3 @@ -45,7 +45,6 @@ flake8-pytest-style==1.6.0 flake8-rst-docstrings==0.2.5 flake8-type-ignore==0.1.0.post2 ; python_version >= "3.8.0" flake8-use-fstring==1.3 -fuzzywuzzy==0.18.0 gitdb==4.0.9 gitpython==3.1.26 gprof2dot==2021.2.21 @@ -77,6 +76,8 @@ jupyter-server-mathjax==0.2.3 jupyter-sphinx==0.3.2 jupyterlab==3.2.8 jupyterlab-code-formatter==1.4.10 +jupyterlab-markup==1.0.1 +jupyterlab-myst==0.1.6 ; python_version >= "3.7.0" jupyterlab-pygments==0.1.2 jupyterlab-server==2.10.3 jupyterlab-widgets==1.0.2 @@ -156,6 +157,7 @@ soupsieve==2.3.1 sphinx==4.4.0 sphinx-autobuild==2021.3.14 sphinx-book-theme==0.2.0 +sphinx-codeautolink==0.10.0 sphinx-copybutton==0.4.0 sphinx-panels==0.6.0 sphinx-thebe==0.0.10 @@ -168,13 +170,13 @@ sphinxcontrib-htmlhelp==2.0.0 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 -sphobjinv==2.1 +sphobjinv==2.2 sqlalchemy==1.4.31 stack-data==0.1.4 terminado==0.13.1 testpath==0.5.0 toml==0.10.2 -tomli==1.2.3 +tomli==2.0.0 tornado==6.1 tox==3.24.5 tqdm==4.62.3 @@ -183,7 +185,7 @@ types-docutils==0.17.4 types-pkg-resources==0.1.3 types-pyyaml==6.0.3 types-requests==2.27.7 -types-setuptools==57.4.7 +types-setuptools==57.4.8 types-urllib3==1.26.7 typing-extensions==4.0.1 urllib3==1.26.8 diff --git a/.constraints/py3.9.txt b/.constraints/py3.9.txt index 2497a887..99f72df4 100644 --- a/.constraints/py3.9.txt +++ b/.constraints/py3.9.txt @@ -15,12 +15,12 @@ attrs==21.4.0 babel==2.9.1 backcall==0.2.0 beautifulsoup4==4.10.0 -black==21.12b0 +black==22.1.0 bleach==4.1.0 certifi==2021.10.8 cffi==1.15.0 cfgv==3.3.1 -charset-normalizer==2.0.10 +charset-normalizer==2.0.11 click==8.0.3 colorama==0.4.4 coverage==6.3 @@ -45,7 +45,6 @@ flake8-pytest-style==1.6.0 flake8-rst-docstrings==0.2.5 flake8-type-ignore==0.1.0.post2 ; python_version >= "3.8.0" flake8-use-fstring==1.3 -fuzzywuzzy==0.18.0 gitdb==4.0.9 gitpython==3.1.26 gprof2dot==2021.2.21 @@ -76,6 +75,8 @@ jupyter-server-mathjax==0.2.3 jupyter-sphinx==0.3.2 jupyterlab==3.2.8 jupyterlab-code-formatter==1.4.10 +jupyterlab-markup==1.0.1 +jupyterlab-myst==0.1.6 ; python_version >= "3.7.0" jupyterlab-pygments==0.1.2 jupyterlab-server==2.10.3 jupyterlab-widgets==1.0.2 @@ -155,6 +156,7 @@ soupsieve==2.3.1 sphinx==4.4.0 sphinx-autobuild==2021.3.14 sphinx-book-theme==0.2.0 +sphinx-codeautolink==0.10.0 sphinx-copybutton==0.4.0 sphinx-panels==0.6.0 sphinx-thebe==0.0.10 @@ -167,13 +169,13 @@ sphinxcontrib-htmlhelp==2.0.0 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5 -sphobjinv==2.1 +sphobjinv==2.2 sqlalchemy==1.4.31 stack-data==0.1.4 terminado==0.13.1 testpath==0.5.0 toml==0.10.2 -tomli==1.2.3 +tomli==2.0.0 tornado==6.1 tox==3.24.5 tqdm==4.62.3 @@ -182,7 +184,7 @@ types-docutils==0.17.4 types-pkg-resources==0.1.3 types-pyyaml==6.0.3 types-requests==2.27.7 -types-setuptools==57.4.7 +types-setuptools==57.4.8 types-urllib3==1.26.7 typing-extensions==4.0.1 urllib3==1.26.8 diff --git a/.cspell.json b/.cspell.json index f330ca5f..13aa4202 100644 --- a/.cspell.json +++ b/.cspell.json @@ -128,6 +128,7 @@ "colab", "commitlint", "compwa", + "concat", "conds", "displaystyle", "doctest", diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b6881377..a47ce9e6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -41,7 +41,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/ComPWA/repo-maintenance - rev: 0.0.99 + rev: 0.0.101 hooks: - id: check-dev-files args: @@ -55,12 +55,12 @@ repos: - id: format-setup-cfg - repo: https://github.com/psf/black - rev: 21.12b0 + rev: 22.1.0 hooks: - id: black - repo: https://github.com/asottile/blacken-docs - rev: v1.12.0 + rev: v1.12.1 hooks: - id: blacken-docs @@ -101,6 +101,8 @@ repos: rev: 1.2.3 hooks: - id: nbqa-black + additional_dependencies: + - black>=22.1.0 - id: nbqa-flake8 - id: nbqa-isort diff --git a/docs/abbreviate_signature.py b/docs/_relink_references.py similarity index 64% rename from docs/abbreviate_signature.py rename to docs/_relink_references.py index 45a66434..f897ad2d 100644 --- a/docs/abbreviate_signature.py +++ b/docs/_relink_references.py @@ -1,5 +1,5 @@ # cspell:ignore docutils -# pylint: disable=import-error +# pylint: disable=import-error, import-outside-toplevel # pyright: reportMissingImports=false """Abbreviated the annotations generated by sphinx-autodoc. @@ -9,13 +9,14 @@ See also https://github.com/sphinx-doc/sphinx/issues/5868. """ -import sphinx.domains.python -from docutils import nodes -from sphinx import addnodes -from sphinx.environment import BuildEnvironment +from typing import TYPE_CHECKING +if TYPE_CHECKING: + from sphinx.addnodes import pending_xref + from sphinx.environment import BuildEnvironment -def replace_link(text: str) -> str: + +def _replace_link(text: str) -> str: replacements = { "a set-like object providing a view on D's items": "typing.ItemsView", "a set-like object providing a view on D's keys": "typing.KeysView", @@ -28,9 +29,9 @@ def replace_link(text: str) -> str: return text -def new_type_to_xref( - text: str, env: BuildEnvironment = None -) -> addnodes.pending_xref: +def _new_type_to_xref( + text: str, env: "BuildEnvironment" = None +) -> "pending_xref": """Convert a type string to a cross reference node.""" if text == "None": reftype = "obj" @@ -45,12 +46,15 @@ def new_type_to_xref( else: kwargs = {} - text = replace_link(text) + text = _replace_link(text) short_text = text.split(".")[-1] - return addnodes.pending_xref( + from docutils.nodes import Text + from sphinx.addnodes import pending_xref + + return pending_xref( "", - nodes.Text(short_text), + Text(short_text), refdomain="py", reftype=reftype, reftarget=text, @@ -58,5 +62,7 @@ def new_type_to_xref( ) -def abbreviate_signature() -> None: - sphinx.domains.python.type_to_xref = new_type_to_xref +def relink_references() -> None: + import sphinx.domains.python + + sphinx.domains.python.type_to_xref = _new_type_to_xref # type: ignore[assignment] diff --git a/docs/conf.py b/docs/conf.py index a4c20f8b..41b1a4be 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -73,9 +73,9 @@ def fetch_logo(url: str, output_path: str) -> None: # -- Generate API ------------------------------------------------------------ sys.path.insert(0, os.path.abspath(".")) -from abbreviate_signature import abbreviate_signature # noqa: E402 +from _relink_references import relink_references # noqa: E402 -abbreviate_signature() +relink_references() shutil.rmtree("api", ignore_errors=True) subprocess.call( " ".join( @@ -145,6 +145,7 @@ def fetch_logo(url: str, output_path: str) -> None: "sphinx.ext.mathjax", "sphinx.ext.napoleon", "sphinx.ext.viewcode", + "sphinx_codeautolink", "sphinx_copybutton", "sphinx_panels", "sphinx_thebe", @@ -172,6 +173,7 @@ def fetch_logo(url: str, output_path: str) -> None: ] ), } +codeautolink_concat_default = True AUTODOC_INSERT_SIGNATURE_LINEBREAKS = True graphviz_output_format = "svg" html_copy_source = True # needed for download notebook button diff --git a/docs/usage.ipynb b/docs/usage.ipynb index b0a8fc5d..76ba3732 100644 --- a/docs/usage.ipynb +++ b/docs/usage.ipynb @@ -49,6 +49,14 @@ "%pip install -q qrules[doc,viz] IPython" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```{autolink-concat}\n", + "```" + ] + }, { "cell_type": "markdown", "metadata": {}, diff --git a/docs/usage/conservation.ipynb b/docs/usage/conservation.ipynb index b002790d..97c1d083 100644 --- a/docs/usage/conservation.ipynb +++ b/docs/usage/conservation.ipynb @@ -49,6 +49,14 @@ "%pip install -q qrules[doc,viz] IPython" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```{autolink-concat}\n", + "```" + ] + }, { "cell_type": "markdown", "metadata": {}, diff --git a/docs/usage/custom-topology.ipynb b/docs/usage/custom-topology.ipynb index 51a4bd51..022116eb 100644 --- a/docs/usage/custom-topology.ipynb +++ b/docs/usage/custom-topology.ipynb @@ -49,6 +49,14 @@ "%pip install -q qrules[doc,viz] IPython" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```{autolink-concat}\n", + "```" + ] + }, { "cell_type": "markdown", "metadata": {}, diff --git a/docs/usage/ls-coupling.ipynb b/docs/usage/ls-coupling.ipynb index 99173db9..59f009c9 100644 --- a/docs/usage/ls-coupling.ipynb +++ b/docs/usage/ls-coupling.ipynb @@ -49,6 +49,14 @@ "%pip install -q qrules[doc,viz] IPython" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```{autolink-concat}\n", + "```" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -104,7 +112,7 @@ " spin = int(particle.spin)\n", " else:\n", " nominator = int(particle.spin * 2)\n", - " spin = fR\"\\tfrac{{{nominator}}}{2}\"\n", + " spin = Rf\"\\tfrac{{{nominator}}}{2}\"\n", " latex_expressions.append(f\"{particle.latex}={spin}^{parity}\")\n", "Math(R\"\\qquad \".join(latex_expressions))" ] diff --git a/docs/usage/particle.ipynb b/docs/usage/particle.ipynb index bddf7f6c..8e90b606 100644 --- a/docs/usage/particle.ipynb +++ b/docs/usage/particle.ipynb @@ -49,6 +49,14 @@ "%pip install -q qrules[doc,viz] IPython" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```{autolink-concat}\n", + "```" + ] + }, { "cell_type": "markdown", "metadata": {}, diff --git a/docs/usage/reaction.ipynb b/docs/usage/reaction.ipynb index fba7f2ea..376e7576 100644 --- a/docs/usage/reaction.ipynb +++ b/docs/usage/reaction.ipynb @@ -49,6 +49,14 @@ "%pip install -q qrules[doc,viz] IPython" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```{autolink-concat}\n", + "```" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -153,7 +161,7 @@ "source": [ ":::{tip}\n", "\n", - "{doc}`custom-topology` shows how to provide custom `.Topology` instances to the STM, so that you generate more than just isobar decays.\n", + "{doc}`custom-topology` shows how to provide custom {class}`.Topology` instances to the STM, so that you generate more than just isobar decays.\n", "\n", ":::" ] diff --git a/docs/usage/visualize.ipynb b/docs/usage/visualize.ipynb index afdac172..da19a400 100644 --- a/docs/usage/visualize.ipynb +++ b/docs/usage/visualize.ipynb @@ -49,6 +49,14 @@ "%pip install -q qrules[doc,viz] IPython" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```{autolink-concat}\n", + "```" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -373,7 +381,7 @@ "metadata": {}, "source": [ "```{note}\n", - "By default, `.asdot` renders edge IDs, because they represent the (final) state IDs as well. In the example above, we switched this off.\n", + "By default, {func}`.asdot` renders edge IDs, because they represent the (final) state IDs as well. In the example above, we switched this off.\n", "```" ] }, @@ -433,7 +441,7 @@ " \"style\": \"dashed\",\n", " },\n", ")\n", - "display(graphviz.Source(dot))\n" + "display(graphviz.Source(dot))" ] } ], diff --git a/pyproject.toml b/pyproject.toml index 1490b9ec..fd0f21fa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,9 +22,9 @@ exclude = ''' | dist )/ ''' -experimental-string-processing = true include = '\.pyi?$' line-length = 79 +preview = true target-version = [ "py36", "py37", diff --git a/setup.cfg b/setup.cfg index 8b48be62..bb0f25d2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -67,6 +67,7 @@ doc = Sphinx >=3 Sphinx <4.4; python_version <"3.8.0" # https://github.com/ComPWA/qrules/runs/4833302679 sphinx-book-theme + sphinx-codeautolink[ipython] sphinx-copybutton sphinx-panels sphinx-thebe @@ -121,6 +122,7 @@ dev = aquirdturtle-collapsible-headings jupyterlab jupyterlab-code-formatter + jupyterlab-myst; python_version >="3.7.0" pip-tools >=6.1.0 # for extras_require sphinx-autobuild tox >=1.9 # for skip_install, use_develop diff --git a/src/qrules/particle.py b/src/qrules/particle.py index d1d9551b..b7379b0a 100644 --- a/src/qrules/particle.py +++ b/src/qrules/particle.py @@ -512,7 +512,7 @@ def create_antiparticle( pid=-template_particle.pid, latex=new_latex if new_latex - else fR"\overline{{{template_particle.latex}}}", + else Rf"\overline{{{template_particle.latex}}}", mass=template_particle.mass, width=template_particle.width, charge=-template_particle.charge,