From 0af8721f9dda16d82d839f6d185c927968841d22 Mon Sep 17 00:00:00 2001 From: Tania Allard Date: Wed, 20 Nov 2024 11:09:06 +0000 Subject: [PATCH 1/6] :wrench: Update pre-commit config --- .pre-commit-config.yaml | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ad1c49c2c..3d88814a6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,11 +9,11 @@ ci: # Fix the node version to avoid a GLIBC error # ref: https://stackoverflow.com/questions/71939099/bitbucket-pipeline-error-installing-pre-commit-ts-lint/71940852#71940852 default_language_version: - node: 16.14.2 + node: 22.9.0 repos: - - repo: https://github.com/pre-commit/mirrors-prettier - rev: v4.0.0-alpha.8 + - repo: "https://github.com/pycontribs/mirrors-prettier" + rev: v3.3.3 hooks: - id: prettier # Exclude the HTML, since it doesn't understand Jinja2 @@ -21,29 +21,29 @@ repos: # exclude the pytest-regressions folder tests/test_ally exclude: .+\.html|webpack\.config\.js|tests/test_a11y/ - - repo: https://github.com/psf/black + - repo: "https://github.com/psf/black" rev: 24.10.0 hooks: - id: black - - repo: https://github.com/astral-sh/ruff-pre-commit + - repo: "https://github.com/astral-sh/ruff-pre-commit" rev: "v0.7.2" hooks: - id: ruff - - repo: https://github.com/asottile/pyupgrade + - repo: "https://github.com/asottile/pyupgrade" rev: v3.19.0 hooks: - id: pyupgrade args: [--py37-plus] - - repo: https://github.com/Riverside-Healthcare/djLint + - repo: "https://github.com/Riverside-Healthcare/djLint" rev: v1.35.4 hooks: - id: djlint-jinja types_or: ["html"] - - repo: https://github.com/PyCQA/doc8 + - repo: "https://github.com/PyCQA/doc8" rev: v1.1.2 hooks: - id: doc8 @@ -53,12 +53,12 @@ repos: hooks: - id: nbstripout - - repo: https://github.com/mondeja/pre-commit-po-hooks + - repo: "https://github.com/mondeja/pre-commit-po-hooks" rev: v1.7.3 hooks: - id: remove-metadata - - repo: https://github.com/thibaudcolas/pre-commit-stylelint + - repo: "https://github.com/thibaudcolas/pre-commit-stylelint" rev: v16.10.0 hooks: - id: stylelint @@ -68,3 +68,9 @@ repos: # stylelint itself needs to be here when using additional_dependencies. - stylelint@16.5.0 - stylelint-config-standard-scss@13.1.0 + + - repo: "https://github.com/pre-commit/pre-commit-hooks" + rev: v5.0.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer From 6d1623106bb0a3dc388bafe41f8497b2ebba9e27 Mon Sep 17 00:00:00 2001 From: Tania Allard Date: Wed, 20 Nov 2024 11:13:31 +0000 Subject: [PATCH 2/6] Add isort to ruff config --- pyproject.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 1d1272459..608aac1cd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -116,6 +116,10 @@ docstring-quotes = "double" [tool.ruff.lint.pydocstyle] convention = "google" +[tool.ruff.lint.isort] +lines-between-types = 1 +lines-after-imports = 2 + [tool.djlint] profile = "jinja" extension = "html" From fbde02f58b1a9638ee37eac440f3509d37866ebc Mon Sep 17 00:00:00 2001 From: Tania Allard Date: Wed, 20 Nov 2024 11:57:01 +0000 Subject: [PATCH 3/6] :heavy_minus_sign: Remove black pre-commit --- .pre-commit-config.yaml | 7 ++----- pyproject.toml | 7 ++++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3d88814a6..04b6bdc64 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,15 +21,12 @@ repos: # exclude the pytest-regressions folder tests/test_ally exclude: .+\.html|webpack\.config\.js|tests/test_a11y/ - - repo: "https://github.com/psf/black" - rev: 24.10.0 - hooks: - - id: black - - repo: "https://github.com/astral-sh/ruff-pre-commit" rev: "v0.7.2" hooks: - id: ruff + args: [--exit-non-zero-on-fix] + - id: ruff-format - repo: "https://github.com/asottile/pyupgrade" rev: v3.19.0 diff --git a/pyproject.toml b/pyproject.toml index 608aac1cd..29c03b62e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -100,11 +100,16 @@ ignore = ["D001"] # we follow a 1 line = 1 paragraph style [tool.ruff] fix = true +# keep consistent with black +line-length = 88 +indent-width = 4 [tool.ruff.lint] ignore = [ - "E501", # line too long | Black take care of it "D107", # Missing docstring in `__init__` | set the docstring in the class + "D205", # 1 blank line required between summary line and description, + "D212", + "W291", # let pre-commit handle trailing whitespace ] ignore-init-module-imports = true From 04ebf7bcc19116bd9f83e0cdeae8430a08984d70 Mon Sep 17 00:00:00 2001 From: Tania Allard Date: Wed, 20 Nov 2024 15:04:22 +0000 Subject: [PATCH 4/6] Add logging linters --- pyproject.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 29c03b62e..247729ff8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -112,8 +112,7 @@ ignore = [ "W291", # let pre-commit handle trailing whitespace ] -ignore-init-module-imports = true -select = ["E", "F", "W", "I", "D", "RUF"] +select = ["E", "F", "W", "I", "D", "RUF", "G"] [tool.ruff.lint.flake8-quotes] docstring-quotes = "double" From b6338988dfa46d118422c4dcfafdb1280e35ee3a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:06:00 +0000 Subject: [PATCH 5/6] [pre-commit.ci] Automatic linting and formatting fixes --- docs/_extension/component_directive.py | 2 ++ docs/_extension/gallery_directive.py | 1 + docs/conf.py | 2 ++ docs/examples/pydata.ipynb | 23 ++++++++++++------- .../scripts/generate_collaborators_gallery.py | 2 ++ docs/scripts/update_kitchen_sink.py | 1 + docs/user_guide/layout.rst | 1 - src/pydata_sphinx_theme/__init__.py | 3 +++ src/pydata_sphinx_theme/edit_this_page.py | 1 + .../locale/ca/LC_MESSAGES/sphinx.po | 4 ++-- .../locale/cs/LC_MESSAGES/sphinx.po | 1 - .../locale/en/LC_MESSAGES/sphinx.po | 1 - .../locale/es/LC_MESSAGES/sphinx.po | 4 ++-- .../locale/fr/LC_MESSAGES/sphinx.po | 4 ++-- .../locale/it/LC_MESSAGES/sphinx.po | 1 - .../locale/ja/LC_MESSAGES/sphinx.po | 1 - .../locale/ru/LC_MESSAGES/sphinx.po | 1 - src/pydata_sphinx_theme/locale/sphinx.pot | 1 - .../locale/zh/LC_MESSAGES/sphinx.po | 1 - .../components/search-button-field.html | 2 +- .../theme/pydata_sphinx_theme/layout.html | 4 ++-- src/pydata_sphinx_theme/toctree.py | 1 + src/pydata_sphinx_theme/translator.py | 1 + src/pydata_sphinx_theme/utils.py | 9 +++++--- tests/conftest.py | 3 +++ tests/test_a11y.py | 2 ++ tests/test_build.py | 2 ++ tests/test_playwright.py | 2 ++ tests/utils/check_warnings.py | 2 ++ tools/divergent_links.py | 2 ++ tools/profile.py | 2 +- tox.ini | 14 +++++------ webpack.config.js | 4 ++-- 33 files changed, 67 insertions(+), 38 deletions(-) diff --git a/docs/_extension/component_directive.py b/docs/_extension/component_directive.py index 07ffcf66f..334c79869 100644 --- a/docs/_extension/component_directive.py +++ b/docs/_extension/component_directive.py @@ -6,6 +6,7 @@ """ import re + from pathlib import Path from typing import Any, Dict, List @@ -14,6 +15,7 @@ from sphinx.util import logging from sphinx.util.docutils import SphinxDirective + logger = logging.getLogger(__name__) diff --git a/docs/_extension/gallery_directive.py b/docs/_extension/gallery_directive.py index 80642c545..d61b0f923 100644 --- a/docs/_extension/gallery_directive.py +++ b/docs/_extension/gallery_directive.py @@ -19,6 +19,7 @@ from sphinx.util.docutils import SphinxDirective from yaml import safe_load + logger = logging.getLogger(__name__) diff --git a/docs/conf.py b/docs/conf.py index de9295db7..3ab7500b3 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -8,6 +8,7 @@ # -- Path setup -------------------------------------------------------------- import os import sys + from pathlib import Path from typing import Any, Dict @@ -16,6 +17,7 @@ import pydata_sphinx_theme + sys.path.append(str(Path(".").resolve())) # -- Project information ----------------------------------------------------- diff --git a/docs/examples/pydata.ipynb b/docs/examples/pydata.ipynb index 64c273503..df86e223d 100644 --- a/docs/examples/pydata.ipynb +++ b/docs/examples/pydata.ipynb @@ -29,6 +29,7 @@ "import numpy as np\n", "import pandas as pd\n", "\n", + "\n", "rng = np.random.default_rng(seed=15485863)\n", "data = rng.standard_normal((100, 26))\n", "df = pd.DataFrame(data, columns=list(string.ascii_lowercase))\n", @@ -51,8 +52,10 @@ "import ipywidgets as widgets\n", "import numpy as np\n", "import pandas as pd\n", + "\n", "from IPython.display import display\n", "\n", + "\n", "tab = widgets.Tab()\n", "\n", "descr_str = \"Hello\"\n", @@ -65,9 +68,9 @@ "\n", "# render in output widgets\n", "with widget_images:\n", - " display(pd.DataFrame(np.random.randn(10,10)))\n", + " display(pd.DataFrame(np.random.randn(10, 10)))\n", "with widget_annotations:\n", - " display(pd.DataFrame(np.random.randn(10,10)))\n", + " display(pd.DataFrame(np.random.randn(10, 10)))\n", "\n", "tab.children = [widget_images, widget_annotations]\n", "tab.titles = [\"Images\", \"Annotations\"]\n", @@ -90,6 +93,7 @@ "source": [ "import matplotlib.pyplot as plt\n", "\n", + "\n", "fig, ax = plt.subplots()\n", "ax.scatter(df[\"a\"], df[\"b\"], c=df[\"b\"], s=3)" ] @@ -125,10 +129,13 @@ "import plotly.express as px\n", "import plotly.io as pio\n", "\n", + "\n", "pio.renderers.default = \"notebook\"\n", "\n", "df = px.data.iris()\n", - "fig = px.scatter(df, x=\"sepal_width\", y=\"sepal_length\", color=\"species\", size=\"sepal_length\")\n", + "fig = px.scatter(\n", + " df, x=\"sepal_width\", y=\"sepal_length\", color=\"species\", size=\"sepal_length\"\n", + ")\n", "fig" ] }, @@ -149,11 +156,10 @@ "source": [ "import xarray as xr\n", "\n", + "\n", "data = xr.DataArray(\n", - " np.random.randn(2, 3),\n", - " dims=(\"x\", \"y\"),\n", - " coords={\"x\": [10, 20]}, attrs={\"foo\": \"bar\"}\n", - " )\n", + " np.random.randn(2, 3), dims=(\"x\", \"y\"), coords={\"x\": [10, 20]}, attrs={\"foo\": \"bar\"}\n", + ")\n", "data" ] }, @@ -174,8 +180,9 @@ "source": [ "from ipyleaflet import Map, basemaps\n", "\n", + "\n", "# display a map centered on France\n", - "m = Map(basemap=basemaps.Esri.WorldImagery, zoom=5, center=[46.21, 2.21])\n", + "m = Map(basemap=basemaps.Esri.WorldImagery, zoom=5, center=[46.21, 2.21])\n", "m" ] } diff --git a/docs/scripts/generate_collaborators_gallery.py b/docs/scripts/generate_collaborators_gallery.py index 110abfb0f..c3809297c 100644 --- a/docs/scripts/generate_collaborators_gallery.py +++ b/docs/scripts/generate_collaborators_gallery.py @@ -2,11 +2,13 @@ import json import shlex + from pathlib import Path from subprocess import run from yaml import dump + COLLABORATORS_API = "https://api.github.com/repos/pydata/pydata-sphinx-theme/collaborators?affiliation=direct" print("Grabbing latest collaborators with GitHub API via GitHub's CLI...") diff --git a/docs/scripts/update_kitchen_sink.py b/docs/scripts/update_kitchen_sink.py index 4612e6687..a434fd32c 100644 --- a/docs/scripts/update_kitchen_sink.py +++ b/docs/scripts/update_kitchen_sink.py @@ -3,6 +3,7 @@ from pathlib import Path from urllib.request import urlopen + EXTRA_MESSAGE = """\ .. note:: diff --git a/docs/user_guide/layout.rst b/docs/user_guide/layout.rst index 697f32171..b3bc6d7b8 100644 --- a/docs/user_guide/layout.rst +++ b/docs/user_guide/layout.rst @@ -593,4 +593,3 @@ Please find here the full list of keys you can use in the ``html_theme_options`` .. include:: ../../src/pydata_sphinx_theme/theme/pydata_sphinx_theme/theme.conf :code: ini :class: highlight-ini - diff --git a/src/pydata_sphinx_theme/__init__.py b/src/pydata_sphinx_theme/__init__.py index 28b5a1c56..760ae0530 100644 --- a/src/pydata_sphinx_theme/__init__.py +++ b/src/pydata_sphinx_theme/__init__.py @@ -1,12 +1,14 @@ """Bootstrap-based sphinx theme from the PyData community.""" import json + from functools import partial from pathlib import Path from typing import Dict from urllib.parse import urlparse import requests + from requests.exceptions import ConnectionError, HTTPError, RetryError from sphinx.application import Sphinx from sphinx.builders.dirhtml import DirectoryHTMLBuilder @@ -14,6 +16,7 @@ from . import edit_this_page, logo, pygments, short_link, toctree, translator, utils + __version__ = "0.16.1dev0" diff --git a/src/pydata_sphinx_theme/edit_this_page.py b/src/pydata_sphinx_theme/edit_this_page.py index 7c97c86dc..c54fe20f6 100644 --- a/src/pydata_sphinx_theme/edit_this_page.py +++ b/src/pydata_sphinx_theme/edit_this_page.py @@ -1,6 +1,7 @@ """Create an "edit this page" url compatible with bitbucket, gitlab and github.""" import jinja2 + from sphinx.application import Sphinx from sphinx.errors import ExtensionError diff --git a/src/pydata_sphinx_theme/locale/ca/LC_MESSAGES/sphinx.po b/src/pydata_sphinx_theme/locale/ca/LC_MESSAGES/sphinx.po index 441324537..5f7e9bf54 100644 --- a/src/pydata_sphinx_theme/locale/ca/LC_MESSAGES/sphinx.po +++ b/src/pydata_sphinx_theme/locale/ca/LC_MESSAGES/sphinx.po @@ -2,11 +2,11 @@ # Copyright (C) 2024 ORGANIZATION # This file is distributed under the same license as the PROJECT project. # FIRST AUTHOR , 2024. -# +# # Translators: # Cristhian Rivera, 2024 # Oriol Abril-Pla , 2024 -# +# msgid "" msgstr "" diff --git a/src/pydata_sphinx_theme/locale/cs/LC_MESSAGES/sphinx.po b/src/pydata_sphinx_theme/locale/cs/LC_MESSAGES/sphinx.po index ddcf50f79..177378dc1 100644 --- a/src/pydata_sphinx_theme/locale/cs/LC_MESSAGES/sphinx.po +++ b/src/pydata_sphinx_theme/locale/cs/LC_MESSAGES/sphinx.po @@ -181,4 +181,3 @@ msgstr "Navigace na stránce" #~ msgid "© Copyright %(copyright)s." #~ msgstr "© Copyright %(copyright)s." - diff --git a/src/pydata_sphinx_theme/locale/en/LC_MESSAGES/sphinx.po b/src/pydata_sphinx_theme/locale/en/LC_MESSAGES/sphinx.po index 020709069..2f40a3c3a 100644 --- a/src/pydata_sphinx_theme/locale/en/LC_MESSAGES/sphinx.po +++ b/src/pydata_sphinx_theme/locale/en/LC_MESSAGES/sphinx.po @@ -182,4 +182,3 @@ msgstr "" #~ msgid "light/dark" #~ msgstr "" - diff --git a/src/pydata_sphinx_theme/locale/es/LC_MESSAGES/sphinx.po b/src/pydata_sphinx_theme/locale/es/LC_MESSAGES/sphinx.po index f13a226bc..256b7f4a5 100644 --- a/src/pydata_sphinx_theme/locale/es/LC_MESSAGES/sphinx.po +++ b/src/pydata_sphinx_theme/locale/es/LC_MESSAGES/sphinx.po @@ -2,13 +2,13 @@ # Copyright (C) 2024 ORGANIZATION # This file is distributed under the same license as the PROJECT project. # FIRST AUTHOR , 2024. -# +# # Translators: # Rambaud Pierrick , 2023 # Cristhian Rivera, 2024 # Felipe Moreno, 2024 # Tania Allard, 2024 -# +# msgid "" msgstr "" diff --git a/src/pydata_sphinx_theme/locale/fr/LC_MESSAGES/sphinx.po b/src/pydata_sphinx_theme/locale/fr/LC_MESSAGES/sphinx.po index 7101ec2e7..1a641370b 100644 --- a/src/pydata_sphinx_theme/locale/fr/LC_MESSAGES/sphinx.po +++ b/src/pydata_sphinx_theme/locale/fr/LC_MESSAGES/sphinx.po @@ -2,11 +2,11 @@ # Copyright (C) 2024 ORGANIZATION # This file is distributed under the same license as the PROJECT project. # FIRST AUTHOR , 2024. -# +# # Translators: # Rambaud Pierrick , 2024 # Denis Bitouzé , 2024 -# +# msgid "" msgstr "" diff --git a/src/pydata_sphinx_theme/locale/it/LC_MESSAGES/sphinx.po b/src/pydata_sphinx_theme/locale/it/LC_MESSAGES/sphinx.po index 6b17b9b2f..0375aa5b0 100644 --- a/src/pydata_sphinx_theme/locale/it/LC_MESSAGES/sphinx.po +++ b/src/pydata_sphinx_theme/locale/it/LC_MESSAGES/sphinx.po @@ -184,4 +184,3 @@ msgstr "Navigazione del sito" #~ msgid "© Copyright %(copyright)s." #~ msgstr "© Copyright %(copyright)s." - diff --git a/src/pydata_sphinx_theme/locale/ja/LC_MESSAGES/sphinx.po b/src/pydata_sphinx_theme/locale/ja/LC_MESSAGES/sphinx.po index fa2bccfd5..e247b0dde 100644 --- a/src/pydata_sphinx_theme/locale/ja/LC_MESSAGES/sphinx.po +++ b/src/pydata_sphinx_theme/locale/ja/LC_MESSAGES/sphinx.po @@ -186,4 +186,3 @@ msgstr "サイトナビゲーション" #~ msgid "© Copyright %(copyright)s." #~ msgstr "© Copyright %(copyright)s." - diff --git a/src/pydata_sphinx_theme/locale/ru/LC_MESSAGES/sphinx.po b/src/pydata_sphinx_theme/locale/ru/LC_MESSAGES/sphinx.po index 8fc4c2eca..aaed14546 100644 --- a/src/pydata_sphinx_theme/locale/ru/LC_MESSAGES/sphinx.po +++ b/src/pydata_sphinx_theme/locale/ru/LC_MESSAGES/sphinx.po @@ -181,4 +181,3 @@ msgstr "Навигация по сайту" #~ msgid "© Copyright %(copyright)s." #~ msgstr "© Копирайт %(copyright)s." - diff --git a/src/pydata_sphinx_theme/locale/sphinx.pot b/src/pydata_sphinx_theme/locale/sphinx.pot index 2a8c524e1..79c59f5eb 100644 --- a/src/pydata_sphinx_theme/locale/sphinx.pot +++ b/src/pydata_sphinx_theme/locale/sphinx.pot @@ -169,4 +169,3 @@ msgstr "" #: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/header.html:3 msgid "Site navigation" msgstr "" - diff --git a/src/pydata_sphinx_theme/locale/zh/LC_MESSAGES/sphinx.po b/src/pydata_sphinx_theme/locale/zh/LC_MESSAGES/sphinx.po index 0fe3fdae5..691b08ff5 100644 --- a/src/pydata_sphinx_theme/locale/zh/LC_MESSAGES/sphinx.po +++ b/src/pydata_sphinx_theme/locale/zh/LC_MESSAGES/sphinx.po @@ -184,4 +184,3 @@ msgstr "网页导航" #~ msgid "© Copyright %(copyright)s." #~ msgstr "© Copyright %(copyright)s." - diff --git a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/search-button-field.html b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/search-button-field.html index e6cb44f7d..f93a5f7c6 100644 --- a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/search-button-field.html +++ b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/search-button-field.html @@ -1,5 +1,5 @@ {# Displays a search field image that opens a search overlay when clicked. #} -{# +{# As this function will only work when JavaScript is enabled, we add a class that will hide it if js is disable. #} diff --git a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html index 39e1c7a6f..e062c1806 100644 --- a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html +++ b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html @@ -17,8 +17,8 @@ document.documentElement.dataset.mode = localStorage.getItem("mode") || "{{ default_mode }}"; document.documentElement.dataset.theme = localStorage.getItem("theme") || "{{ default_mode }}"; -