Skip to content

Commit

Permalink
really drop python<=3.8 support (#844)
Browse files Browse the repository at this point in the history
* really drop python<=3.8 support

Filter all code over `pyupgrade --py39-plus`.

Signed-off-by: Tomasz Kłoczko <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Signed-off-by: Tomasz Kłoczko <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Angus Hollands <[email protected]>
Co-authored-by: Chris Holdgraf <[email protected]>
  • Loading branch information
4 people authored Dec 23, 2024
1 parent 40f7c41 commit 8822eef
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 17 deletions.
6 changes: 2 additions & 4 deletions src/sphinx_book_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,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
Expand Down
2 changes: 1 addition & 1 deletion src/sphinx_book_theme/_compat.py
Original file line number Diff line number Diff line change
@@ -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]:
Expand Down
6 changes: 2 additions & 4 deletions src/sphinx_book_theme/header_buttons/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,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.
Expand Down
12 changes: 5 additions & 7 deletions src/sphinx_book_theme/header_buttons/launch.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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]

Expand Down
2 changes: 1 addition & 1 deletion tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand Down

0 comments on commit 8822eef

Please sign in to comment.