diff --git a/src/sphinx_book_theme/__init__.py b/src/sphinx_book_theme/__init__.py index b15c1033..1646f2d1 100644 --- a/src/sphinx_book_theme/__init__.py +++ b/src/sphinx_book_theme/__init__.py @@ -139,10 +139,8 @@ def update_mode_thebe_config(app): # but has not activated the sphinx_thebe extension. if not hasattr(app.env.config, "thebe_config"): SPHINX_LOGGER.warning( - ( - "Thebe is activated but not added to extensions list. " - "Add `sphinx_thebe` to your site's extensions list." - ) + "Thebe is activated but not added to extensions list. " + "Add `sphinx_thebe` to your site's extensions list." ) return # Will be empty if it doesn't exist diff --git a/src/sphinx_book_theme/_compat.py b/src/sphinx_book_theme/_compat.py index 99e70b8d..4e2940cc 100644 --- a/src/sphinx_book_theme/_compat.py +++ b/src/sphinx_book_theme/_compat.py @@ -1,5 +1,5 @@ from docutils.nodes import Element -from typing import Iterator +from collections.abc import Iterator def findall(node: Element, *args, **kwargs) -> Iterator[Element]: diff --git a/src/sphinx_book_theme/header_buttons/__init__.py b/src/sphinx_book_theme/header_buttons/__init__.py index e18d51c0..49608e22 100644 --- a/src/sphinx_book_theme/header_buttons/__init__.py +++ b/src/sphinx_book_theme/header_buttons/__init__.py @@ -173,10 +173,8 @@ def update_context_with_repository_info(app): # If provider is still empty, raise an error because we don't recognize it if provider == "": raise SphinxError( - ( - f"Provider not recognized in repository url {repo_url}. " - "If you're using a custom provider URL, specify `repository_provider`" - ) + f"Provider not recognized in repository url {repo_url}. " + "If you're using a custom provider URL, specify `repository_provider`" ) # Update the context because this is what the get_edit_url function uses. diff --git a/src/sphinx_book_theme/header_buttons/launch.py b/src/sphinx_book_theme/header_buttons/launch.py index c00f9293..20f93b4c 100644 --- a/src/sphinx_book_theme/header_buttons/launch.py +++ b/src/sphinx_book_theme/header_buttons/launch.py @@ -1,7 +1,7 @@ """Launch buttons for Binder / Thebe / Colab / etc.""" from pathlib import Path -from typing import Any, Dict, Optional +from typing import Any, Optional from urllib.parse import urlencode, quote from docutils.nodes import document @@ -23,7 +23,7 @@ def add_launch_buttons( app: Sphinx, pagename: str, templatename: str, - context: Dict[str, Any], + context: dict[str, Any], doctree: Optional[document], ): """Builds a binder link and inserts it in HTML context for use in templating. @@ -89,11 +89,9 @@ def add_launch_buttons( notebook_interface = launch_buttons.get("notebook_interface", "classic") if notebook_interface not in notebook_interface_prefixes: raise ValueError( - ( - "Notebook UI for Binder/JupyterHub links must be one" - f"of {tuple(notebook_interface_prefixes.keys())}," - f"not {notebook_interface}" - ) + "Notebook UI for Binder/JupyterHub links must be one" + f"of {tuple(notebook_interface_prefixes.keys())}," + f"not {notebook_interface}" ) ui_pre = notebook_interface_prefixes[notebook_interface] diff --git a/tests/test_build.py b/tests/test_build.py index 77621e5f..9d7b8847 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -86,7 +86,7 @@ def test_build_book(sphinx_build_factory, file_regression): for filename, kernel in kernels_expected.items(): ntbk_html = sphinx_build.html_tree("section1", filename) thebe_config = ntbk_html.find("script", attrs={"type": "text/x-thebe-config"}) - kernel_name = 'name: "{}",'.format(kernel) + kernel_name = f'name: "{kernel}",' if kernel_name not in thebe_config.prettify(): raise AssertionError(f"{kernel_name} not in {kernels_expected}")