Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate hooks (#1806)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate hooks

updates:
- [github.com/pre-commit/mirrors-prettier: v2.7.1 → v4.0.0-alpha.8](pre-commit/mirrors-prettier@v2.7.1...v4.0.0-alpha.8)
- [github.com/psf/black: 22.12.0 → 24.4.2](psf/black@22.12.0...24.4.2)
- https://github.com/charliermarsh/ruff-pre-commithttps://github.com/astral-sh/ruff-pre-commit
- [github.com/astral-sh/ruff-pre-commit: v0.0.215 → v0.4.3](astral-sh/ruff-pre-commit@v0.0.215...v0.4.3)
- [github.com/asottile/pyupgrade: v3.3.1 → v3.15.2](asottile/pyupgrade@v3.3.1...v3.15.2)
- [github.com/Riverside-Healthcare/djLint: v1.19.7 → v1.34.1](djlint/djLint@v1.19.7...v1.34.1)
- [github.com/kynan/nbstripout: 0.5.0 → 0.7.1](kynan/nbstripout@0.5.0...0.7.1)

* [pre-commit.ci] Automatic linting and formatting fixes

* ruff config key changes in pyproject.toml

* add classvar

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Daniel McCloy <[email protected]>
  • Loading branch information
pre-commit-ci[bot] and drammock authored May 6, 2024
1 parent 6620541 commit e67f64d
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 34 deletions.
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ default_language_version:

repos:
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
rev: v4.0.0-alpha.8
hooks:
- id: prettier
# Exclude the HTML, since it doesn't understand Jinja2
Expand All @@ -22,23 +22,23 @@ repos:
exclude: .+\.html|webpack\.config\.js|tests/test_a11y/

- repo: https://github.com/psf/black
rev: 22.12.0
rev: 24.4.2
hooks:
- id: black

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.215"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.4.3"
hooks:
- id: ruff

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
rev: v3.15.2
hooks:
- id: pyupgrade
args: [--py37-plus]

- repo: https://github.com/Riverside-Healthcare/djLint
rev: v1.19.7
rev: v1.34.1
hooks:
- id: djlint-jinja
types_or: ["html"]
Expand All @@ -49,6 +49,6 @@ repos:
- id: doc8

- repo: "https://github.com/kynan/nbstripout"
rev: "0.5.0"
rev: "0.7.1"
hooks:
- id: nbstripout
1 change: 1 addition & 0 deletions docs/_extension/component_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
This list will display some informations about the component and a link to the
GitHub file.
"""

import re
from pathlib import Path
from typing import Any, Dict, List
Expand Down
5 changes: 3 additions & 2 deletions docs/_extension/gallery_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
It currently exists for maintainers of the pydata-sphinx-theme,
but might be abstracted into a standalone package if it proves useful.
"""

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

from docutils import nodes
from docutils.parsers.rst import directives
Expand Down Expand Up @@ -58,7 +59,7 @@ class GalleryGridDirective(SphinxDirective):
required_arguments = 0
optional_arguments = 1
final_argument_whitespace = True
option_spec = {
option_spec: ClassVar[dict[str, Any]] = {
# A class to be added to the resulting container
"grid-columns": directives.unchanged,
"class-container": directives.unchanged,
Expand Down
2 changes: 1 addition & 1 deletion docs/_static/custom-icon.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/_static/pydata-icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ FontAwesome.library.add(
"e002", // unicode codepoint - private use area
"M12.1,17.8v5.8l-5-2.9v-5.8L12.1,17.8z M12.1,12v5.8l-5-2.9V9.1L12.1,12z M17,9.1L12.1,12v5.8l4.9-2.9V9.1z M12.1,6.2L7,9.1l5,2.9L17,9.1L12.1,6.2z M17,9.1V3.3l-4.9-2.8v5.8L17,9.1z",
],
})
}),
);
1 change: 1 addition & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
nox -s docs -- -r
"""

import os
import shutil as sh
import tempfile
Expand Down
11 changes: 6 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,20 @@ a11y = ["pytest-playwright"]
ignore = ["D001"] # we follow a 1 line = 1 paragraph style

[tool.ruff]
ignore-init-module-imports = true
fix = true
select = ["E", "F", "W", "I", "D", "RUF"]

[tool.ruff.lint]
ignore = [
"E501", # line too long | Black take care of it
"D107", # Missing docstring in `__init__` | set the docstring in the class

]
ignore-init-module-imports = true
select = ["E", "F", "W", "I", "D", "RUF"]

[tool.ruff.flake8-quotes]
[tool.ruff.lint.flake8-quotes]
docstring-quotes = "double"

[tool.ruff.pydocstyle]
[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.djlint]
Expand Down
2 changes: 1 addition & 1 deletion src/pydata_sphinx_theme/assets/scripts/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import "../styles/bootstrap.scss";
*/
function TriggerTooltip() {
var tooltipTriggerList = [].slice.call(
document.querySelectorAll('[data-bs-toggle="tooltip"]')
document.querySelectorAll('[data-bs-toggle="tooltip"]'),
);
tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl, {
Expand Down
24 changes: 12 additions & 12 deletions src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function scrollToActive() {
// Inspired on source of revealjs.com
let storedScrollTop = parseInt(
sessionStorage.getItem("sidebar-scroll-top"),
10
10,
);

if (!isNaN(storedScrollTop)) {
Expand Down Expand Up @@ -194,7 +194,7 @@ var findSearchInput = () => {
} else {
// must be at least one persistent form, use the first persistent one
form = document.querySelector(
"div:not(.search-button__search-container) > form.bd-search"
"div:not(.search-button__search-container) > form.bd-search",
);
}
return form.querySelector("input");
Expand Down Expand Up @@ -255,7 +255,7 @@ var addEventListenerForSearchKeyboard = () => {
toggleSearchField();
}
},
true
true,
);
};

Expand All @@ -278,7 +278,7 @@ var changeSearchShortcutKey = () => {
let shortcuts = document.querySelectorAll(".search-button__kbd-shortcut");
if (useCommandKey) {
shortcuts.forEach(
(f) => (f.querySelector("kbd.kbd-shortcut__modifier").innerText = "⌘")
(f) => (f.querySelector("kbd.kbd-shortcut__modifier").innerText = "⌘"),
);
}
};
Expand Down Expand Up @@ -404,7 +404,7 @@ function populateVersionSwitcher(data, versionSwitcherBtns) {
const anchor = document.createElement("a");
anchor.setAttribute(
"class",
"dropdown-item list-group-item list-group-item-action py-1"
"dropdown-item list-group-item list-group-item-action py-1",
);
anchor.setAttribute("href", `${entry.url}${currentFilePath}`);
anchor.setAttribute("role", "option");
Expand Down Expand Up @@ -464,7 +464,7 @@ function showVersionWarningBanner(data) {
if (preferredEntries.length !== 1) {
const howMany = preferredEntries.length == 0 ? "No" : "Multiple";
console.log(
`[PST] ${howMany} versions marked "preferred" found in versions JSON, ignoring.`
`[PST] ${howMany} versions marked "preferred" found in versions JSON, ignoring.`,
);
return;
}
Expand Down Expand Up @@ -520,7 +520,7 @@ function showVersionWarningBanner(data) {
// At least 3rem height
const autoHeight = Math.max(
outer.offsetHeight,
3 * parseFloat(getComputedStyle(document.documentElement).fontSize)
3 * parseFloat(getComputedStyle(document.documentElement).fontSize),
);
// Set height and vertical padding to 0 to prepare the height transition
outer.style.setProperty("height", 0);
Expand Down Expand Up @@ -575,17 +575,17 @@ function initRTDObserver() {
// fetch the JSON version data (only once), then use it to populate the version
// switcher and maybe show the version warning bar
var versionSwitcherBtns = document.querySelectorAll(
".version-switcher__button"
".version-switcher__button",
);
const hasSwitcherMenu = versionSwitcherBtns.length > 0;
const hasVersionsJSON = DOCUMENTATION_OPTIONS.hasOwnProperty(
"theme_switcher_json_url"
"theme_switcher_json_url",
);
const wantsWarningBanner = DOCUMENTATION_OPTIONS.show_version_warning_banner;

if (hasVersionsJSON && (hasSwitcherMenu || wantsWarningBanner)) {
const data = await fetchVersionSwitcherJSON(
DOCUMENTATION_OPTIONS.theme_switcher_json_url
DOCUMENTATION_OPTIONS.theme_switcher_json_url,
);
// TODO: remove the `if(data)` once the `return null` is fixed within fetchVersionSwitcherJSON.
// We don't really want the switcher and warning bar to silently not work.
Expand All @@ -602,7 +602,7 @@ if (hasVersionsJSON && (hasSwitcherMenu || wantsWarningBanner)) {
*/
function fixMoreLinksInMobileSidebar() {
const dropdown = document.querySelector(
".bd-sidebar-primary [id^=pst-nav-more-links]"
".bd-sidebar-primary [id^=pst-nav-more-links]",
);
if (dropdown !== null) {
dropdown.classList.add("show");
Expand All @@ -620,7 +620,7 @@ function setupMobileSidebarKeyboardHandlers() {
// allows the mobile sidebars to be hidden or revealed via CSS.
const primaryToggle = document.getElementById("pst-primary-sidebar-checkbox");
const secondaryToggle = document.getElementById(
"pst-secondary-sidebar-checkbox"
"pst-secondary-sidebar-checkbox",
);
const primarySidebar = document.querySelector(".bd-sidebar-primary");
const secondarySidebar = document.querySelector(".bd-sidebar-secondary");
Expand Down
3 changes: 2 additions & 1 deletion src/pydata_sphinx_theme/assets/styles/abstracts/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* A consistent box shadow style we apply across elements.
*/
@mixin box-shadow() {
box-shadow: 0 0.2rem 0.5rem var(--pst-color-shadow),
box-shadow:
0 0.2rem 0.5rem var(--pst-color-shadow),
0 0 0.0625rem var(--pst-color-shadow) !important;
}

Expand Down
4 changes: 3 additions & 1 deletion src/pydata_sphinx_theme/assets/styles/content/_api.scss
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ dl > dt > a:has(.viewcode-link) {

// the API selector
// from https://github.com/pradyunsg/furo/blob/main/src/furo/assets/styles/content/_api.sass#L6)
dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple) {
dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(
.simple
) {
//increase margin bottom after the dl elements
margin-bottom: 3rem;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ input {
width: 75%;
flex-grow: 0.75;
max-width: 350px;
transition: visibility $animation-time ease-out,
transition:
visibility $animation-time ease-out,
margin $animation-time ease-out;
visibility: hidden;

Expand Down
1 change: 1 addition & 0 deletions src/pydata_sphinx_theme/logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
we use one event to copy over custom logo images to _static
and another even to link them in the html context
"""

from functools import partial
from pathlib import Path

Expand Down
1 change: 1 addition & 0 deletions src/pydata_sphinx_theme/pygment.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
inspired by the Furo theme
https://github.com/pradyunsg/furo/blob/main/src/furo/__init__.py
"""

from functools import partial
from pathlib import Path

Expand Down
8 changes: 6 additions & 2 deletions src/pydata_sphinx_theme/short_link.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""A custom Transform object to shorten github and gitlab links."""

from typing import ClassVar
from urllib.parse import ParseResult, urlparse, urlunparse

from docutils import nodes
Expand Down Expand Up @@ -29,11 +30,14 @@ class ShortenLinkTransform(SphinxPostTransform):

default_priority = 400
formats = ("html",)
supported_platform = {"github.com": "github", "gitlab.com": "gitlab"}
supported_platform: ClassVar[dict[str, str]] = {
"github.com": "github",
"gitlab.com": "gitlab",
}
platform = None

def run(self, **kwargs):
"""run the Transform object."""
"""Run the Transform object."""
matcher = NodeMatcher(nodes.reference)
# TODO: just use "findall" once docutils min version >=0.18.1
for node in traverse_or_findall(self.document, matcher):
Expand Down

0 comments on commit e67f64d

Please sign in to comment.