Skip to content

Commit

Permalink
[pre-commit.ci] Automatic linting and formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Nov 20, 2024
1 parent fbde02f commit 8e10365
Show file tree
Hide file tree
Showing 33 changed files with 67 additions and 38 deletions.
2 changes: 2 additions & 0 deletions docs/_extension/component_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""

import re

from pathlib import Path
from typing import Any, Dict, List

Expand All @@ -14,6 +15,7 @@
from sphinx.util import logging
from sphinx.util.docutils import SphinxDirective


logger = logging.getLogger(__name__)


Expand Down
1 change: 1 addition & 0 deletions docs/_extension/gallery_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from sphinx.util.docutils import SphinxDirective
from yaml import safe_load


logger = logging.getLogger(__name__)


Expand Down
2 changes: 2 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# -- Path setup --------------------------------------------------------------
import os
import sys

from pathlib import Path
from typing import Any, Dict

Expand All @@ -16,6 +17,7 @@

import pydata_sphinx_theme


sys.path.append(str(Path(".").resolve()))

# -- Project information -----------------------------------------------------
Expand Down
23 changes: 15 additions & 8 deletions docs/examples/pydata.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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)"
]
Expand Down Expand Up @@ -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"
]
},
Expand All @@ -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"
]
},
Expand All @@ -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"
]
}
Expand Down
2 changes: 2 additions & 0 deletions docs/scripts/generate_collaborators_gallery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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...")
Expand Down
1 change: 1 addition & 0 deletions docs/scripts/update_kitchen_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pathlib import Path
from urllib.request import urlopen


EXTRA_MESSAGE = """\
.. note::
Expand Down
1 change: 0 additions & 1 deletion docs/user_guide/layout.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

3 changes: 3 additions & 0 deletions src/pydata_sphinx_theme/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
"""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
from sphinx.errors import ExtensionError

from . import edit_this_page, logo, pygments, short_link, toctree, translator, utils


__version__ = "0.16.1dev0"


Expand Down
1 change: 1 addition & 0 deletions src/pydata_sphinx_theme/edit_this_page.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/pydata_sphinx_theme/locale/ca/LC_MESSAGES/sphinx.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# Copyright (C) 2024 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2024.
#
#
# Translators:
# Cristhian Rivera, 2024
# Oriol Abril-Pla <[email protected]>, 2024
#
#
msgid ""
msgstr ""

Expand Down
1 change: 0 additions & 1 deletion src/pydata_sphinx_theme/locale/cs/LC_MESSAGES/sphinx.po
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,3 @@ msgstr "Navigace na stránce"

#~ msgid "© <a href=\"%(path)s\">Copyright</a> %(copyright)s."
#~ msgstr "© <a href=\"%(path)s\">Copyright</a> %(copyright)s."

1 change: 0 additions & 1 deletion src/pydata_sphinx_theme/locale/en/LC_MESSAGES/sphinx.po
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,3 @@ msgstr ""

#~ msgid "light/dark"
#~ msgstr ""

4 changes: 2 additions & 2 deletions src/pydata_sphinx_theme/locale/es/LC_MESSAGES/sphinx.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# Copyright (C) 2024 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2024.
#
#
# Translators:
# Rambaud Pierrick <[email protected]>, 2023
# Cristhian Rivera, 2024
# Felipe Moreno, 2024
# Tania Allard, 2024
#
#
msgid ""
msgstr ""

Expand Down
4 changes: 2 additions & 2 deletions src/pydata_sphinx_theme/locale/fr/LC_MESSAGES/sphinx.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# Copyright (C) 2024 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2024.
#
#
# Translators:
# Rambaud Pierrick <[email protected]>, 2024
# Denis Bitouzé <[email protected]>, 2024
#
#
msgid ""
msgstr ""

Expand Down
1 change: 0 additions & 1 deletion src/pydata_sphinx_theme/locale/it/LC_MESSAGES/sphinx.po
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,3 @@ msgstr "Navigazione del sito"

#~ msgid "© <a href=\"%(path)s\">Copyright</a> %(copyright)s."
#~ msgstr "© <a href=\"%(path)s\">Copyright</a> %(copyright)s."

1 change: 0 additions & 1 deletion src/pydata_sphinx_theme/locale/ja/LC_MESSAGES/sphinx.po
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,3 @@ msgstr "サイトナビゲーション"

#~ msgid "© <a href=\"%(path)s\">Copyright</a> %(copyright)s."
#~ msgstr "© <a href=\"%(path)s\">Copyright</a> %(copyright)s."

1 change: 0 additions & 1 deletion src/pydata_sphinx_theme/locale/ru/LC_MESSAGES/sphinx.po
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,3 @@ msgstr "Навигация по сайту"

#~ msgid "© <a href=\"%(path)s\">Copyright</a> %(copyright)s."
#~ msgstr "© <a href=\\\"%(path)s\\\">Копирайт</a> %(copyright)s."

1 change: 0 additions & 1 deletion src/pydata_sphinx_theme/locale/sphinx.pot
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,3 @@ msgstr ""
#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/header.html:3
msgid "Site navigation"
msgstr ""

1 change: 0 additions & 1 deletion src/pydata_sphinx_theme/locale/zh/LC_MESSAGES/sphinx.po
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,3 @@ msgstr "网页导航"

#~ msgid "© <a href=\"%(path)s\">Copyright</a> %(copyright)s."
#~ msgstr "© <a href=\"%(path)s\">Copyright</a> %(copyright)s."

Original file line number Diff line number Diff line change
@@ -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.
#}
Expand Down
4 changes: 2 additions & 2 deletions src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
document.documentElement.dataset.mode = localStorage.getItem("mode") || "{{ default_mode }}";
document.documentElement.dataset.theme = localStorage.getItem("theme") || "{{ default_mode }}";
</script>
<!--
this give us a css class that will be invisible only if js is disabled
<!--
this give us a css class that will be invisible only if js is disabled
-->
<noscript>
<style>
Expand Down
1 change: 1 addition & 0 deletions src/pydata_sphinx_theme/toctree.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from urllib.parse import urlparse

import sphinx

from bs4 import BeautifulSoup
from docutils import nodes
from docutils.nodes import Node
Expand Down
1 change: 1 addition & 0 deletions src/pydata_sphinx_theme/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from sphinx.ext.autosummary import autosummary_table
from sphinx.util import logging


logger = logging.getLogger(__name__)


Expand Down
9 changes: 6 additions & 3 deletions src/pydata_sphinx_theme/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import copy
import os
import re

from typing import Any, Callable, Dict, Iterable, List, Optional, Union

from docutils.nodes import Node
Expand Down Expand Up @@ -158,9 +159,11 @@ def _get_matching_sidebar_items(
for pattern, sidebar_items in sidebars.items():
if matching.patmatch(pagename, pattern):
if matched and _has_wildcard(pattern) and _has_wildcard(matched):
SPHINX_LOGGER.warning(
f"Page {pagename} matches two wildcard patterns in secondary_sidebar_items: {matched} and {pattern}"
),
(
SPHINX_LOGGER.warning(
f"Page {pagename} matches two wildcard patterns in secondary_sidebar_items: {matched} and {pattern}"
),
)

matched = pattern
secondary_sidebar_items = sidebar_items
Expand Down
3 changes: 3 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import re
import time

from http.client import HTTPConnection
from os import environ
from pathlib import Path
Expand All @@ -11,10 +12,12 @@

import pytest
import sphinx

from bs4 import BeautifulSoup
from sphinx.testing.util import SphinxTestApp
from typing_extensions import Self


pytest_plugins = "sphinx.testing.fixtures"

tests_path = Path(__file__).parent
Expand Down
2 changes: 2 additions & 0 deletions tests/test_a11y.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

import pytest


# Using importorskip to ensure these tests are only loaded if Playwright is installed.
playwright = pytest.importorskip("playwright")
from playwright.sync_api import Page, expect # noqa: E402


# Important note: automated accessibility scans can only find a fraction of
# potential accessibility issues.
#
Expand Down
2 changes: 2 additions & 0 deletions tests/test_build.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
"""All the tests performed in the pydata-sphinx-theme test suite."""

import re

from pathlib import Path

import pytest
import sphinx.errors

from pydata_sphinx_theme.utils import escape_ansi


COMMON_CONF_OVERRIDES = dict(
surface_warnings=True,
)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_playwright.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import pytest


try:
from pathlib import UnsupportedOperation # added in Py 3.13
except ImportError:
Expand All @@ -15,6 +16,7 @@
playwright = pytest.importorskip("playwright")
from playwright.sync_api import Page, expect # noqa: E402


repo_path = Path(__file__).parents[1]
test_sites_dir = repo_path / "docs" / "_build" / "html" / "playwright_tests"

Expand Down
2 changes: 2 additions & 0 deletions tests/utils/check_warnings.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
"""Check the list of warnings produced by a doc build."""

import sys

from pathlib import Path

from colorama import Fore, init

from pydata_sphinx_theme.utils import escape_ansi


# init colors for all plateforms
init()

Expand Down
Loading

0 comments on commit 8e10365

Please sign in to comment.