Skip to content

Commit f6102b4

Browse files
trallardpre-commit-ci[bot]drammockCarreau
authored
LINT - Run updated pre-commit hooks (#2049)
Follows-up #2044 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Daniel McCloy <[email protected]> Co-authored-by: M Bussonnier <[email protected]>
1 parent c0f2db5 commit f6102b4

39 files changed

+244
-126
lines changed

.git-blame-ignore-revs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
# https://git-scm.com/docs/git-config#Documentation/git-config.txt-blameignoreRevsFile
66
# https://github.com/pydata/pydata-sphinx-theme/pull/713
77
#
8-
90550b66ace16a370caa446e54698b126fda740b # initial black-format
9-
236d4c6d1f10f5da064d929e9eb594daecf23551 # apply black 20.8b1 format
10-
69f1a42a3b184f4ba4c98f1745779a277d56c5e2 # [pre-commit.ci] Automatic linting and formatting fixes
11-
a35529c9ee8d5863613df40787cda0021b3e0128 # Manual fixes for stylelint
12-
ce583b8f3136d52e8056c9a651bf6f92e7922f79 # Manual adjustments to autofixes
13-
d1ee9eb7a132cde51433e9594513319fdab41f2f # Autofix (stylelint)
8+
90550b66ace16a370caa446e54698b126fda740b # initial black-format
9+
236d4c6d1f10f5da064d929e9eb594daecf23551 # apply black 20.8b1 format
10+
69f1a42a3b184f4ba4c98f1745779a277d56c5e2 # [pre-commit.ci] Automatic linting and formatting fixes
11+
a35529c9ee8d5863613df40787cda0021b3e0128 # Manual fixes for stylelint
12+
ce583b8f3136d52e8056c9a651bf6f92e7922f79 # Manual adjustments to autofixes
13+
d1ee9eb7a132cde51433e9594513319fdab41f2f # Autofix (stylelint)
14+
0f3aa5ca174fe1534ef4817d42f0e2ffa7d9d921 # [pre-commit.ci] Automatic linting and formatting fixes
15+
9c5a3d592d03849bd050fe946b246145ad171605 # Automated and manual fixes for pre-commits

.pre-commit-config.yaml

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,38 @@ ci:
99
# Fix the node version to avoid a GLIBC error
1010
# ref: https://stackoverflow.com/questions/71939099/bitbucket-pipeline-error-installing-pre-commit-ts-lint/71940852#71940852
1111
default_language_version:
12-
node: 16.14.2
12+
node: 22.9.0
1313

1414
repos:
15-
- repo: https://github.com/pre-commit/mirrors-prettier
16-
rev: v4.0.0-alpha.8
15+
- repo: "https://github.com/pycontribs/mirrors-prettier"
16+
rev: v3.3.3
1717
hooks:
1818
- id: prettier
1919
# Exclude the HTML, since it doesn't understand Jinja2
2020
# exclude also the webpack.config.js file has it embed complete url dificult to prettify
2121
# exclude the pytest-regressions folder tests/test_ally
2222
exclude: .+\.html|webpack\.config\.js|tests/test_a11y/
2323

24-
- repo: https://github.com/psf/black
25-
rev: 24.10.0
26-
hooks:
27-
- id: black
28-
29-
- repo: https://github.com/astral-sh/ruff-pre-commit
24+
- repo: "https://github.com/astral-sh/ruff-pre-commit"
3025
rev: "v0.7.2"
3126
hooks:
3227
- id: ruff
28+
args: [--exit-non-zero-on-fix]
29+
- id: ruff-format
3330

34-
- repo: https://github.com/asottile/pyupgrade
31+
- repo: "https://github.com/asottile/pyupgrade"
3532
rev: v3.19.0
3633
hooks:
3734
- id: pyupgrade
3835
args: [--py37-plus]
3936

40-
- repo: https://github.com/Riverside-Healthcare/djLint
37+
- repo: "https://github.com/Riverside-Healthcare/djLint"
4138
rev: v1.35.4
4239
hooks:
4340
- id: djlint-jinja
4441
types_or: ["html"]
4542

46-
- repo: https://github.com/PyCQA/doc8
43+
- repo: "https://github.com/PyCQA/doc8"
4744
rev: v1.1.2
4845
hooks:
4946
- id: doc8
@@ -53,12 +50,12 @@ repos:
5350
hooks:
5451
- id: nbstripout
5552

56-
- repo: https://github.com/mondeja/pre-commit-po-hooks
53+
- repo: "https://github.com/mondeja/pre-commit-po-hooks"
5754
rev: v1.7.3
5855
hooks:
5956
- id: remove-metadata
6057

61-
- repo: https://github.com/thibaudcolas/pre-commit-stylelint
58+
- repo: "https://github.com/thibaudcolas/pre-commit-stylelint"
6259
rev: v16.10.0
6360
hooks:
6461
- id: stylelint
@@ -68,3 +65,9 @@ repos:
6865
# stylelint itself needs to be here when using additional_dependencies.
6966
7067
68+
69+
- repo: "https://github.com/pre-commit/pre-commit-hooks"
70+
rev: v5.0.0
71+
hooks:
72+
- id: trailing-whitespace
73+
- id: end-of-file-fixer

docs/_extension/component_directive.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"""
77

88
import re
9+
910
from pathlib import Path
1011
from typing import Any, Dict, List
1112

@@ -14,6 +15,7 @@
1415
from sphinx.util import logging
1516
from sphinx.util.docutils import SphinxDirective
1617

18+
1719
logger = logging.getLogger(__name__)
1820

1921

docs/_extension/gallery_directive.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from sphinx.util.docutils import SphinxDirective
2020
from yaml import safe_load
2121

22+
2223
logger = logging.getLogger(__name__)
2324

2425

@@ -76,7 +77,7 @@ def run(self) -> List[nodes.Node]:
7677
path_doc = Path(path_doc).parent
7778
path_data = (path_doc / path_data_rel).resolve()
7879
if not path_data.exists():
79-
logger.info(f"Could not find grid data at {path_data}.")
80+
logger.info("Could not find grid data at %s.", path_data)
8081
nodes.text("No grid data found at {path_data}.")
8182
return
8283
yaml_string = path_data.read_text()

docs/conf.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# -- Path setup --------------------------------------------------------------
99
import os
1010
import sys
11+
1112
from pathlib import Path
1213
from typing import Any, Dict
1314

@@ -16,6 +17,7 @@
1617

1718
import pydata_sphinx_theme
1819

20+
1921
sys.path.append(str(Path(".").resolve()))
2022

2123
# -- Project information -----------------------------------------------------
@@ -192,7 +194,8 @@
192194
},
193195
"use_edit_page_button": True,
194196
"show_toc_level": 1,
195-
"navbar_align": "left", # [left, content, right] For testing that the navbar items align properly
197+
# [left, content, right] For testing that the navbar items align properly
198+
"navbar_align": "left",
196199
# "show_nav_level": 2,
197200
"announcement": "https://raw.githubusercontent.com/pydata/pydata-sphinx-theme/main/docs/_templates/custom-template.html",
198201
"show_version_warning_banner": True,
@@ -294,10 +297,15 @@
294297
def setup_to_main(
295298
app: Sphinx, pagename: str, templatename: str, context, doctree
296299
) -> None:
297-
"""Add a function that jinja can access for returning an "edit this page" link pointing to `main`."""
300+
"""
301+
Add a function that jinja can access for returning an "edit this page" link
302+
pointing to `main`.
303+
"""
298304

299305
def to_main(link: str) -> str:
300-
"""Transform "edit on github" links and make sure they always point to the main branch.
306+
"""
307+
Transform "edit on github" links and make sure they always point to the
308+
main branch.
301309
302310
Args:
303311
link: the link to the github edit interface

docs/examples/pydata.ipynb

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"import numpy as np\n",
3030
"import pandas as pd\n",
3131
"\n",
32+
"\n",
3233
"rng = np.random.default_rng(seed=15485863)\n",
3334
"data = rng.standard_normal((100, 26))\n",
3435
"df = pd.DataFrame(data, columns=list(string.ascii_lowercase))\n",
@@ -51,8 +52,10 @@
5152
"import ipywidgets as widgets\n",
5253
"import numpy as np\n",
5354
"import pandas as pd\n",
55+
"\n",
5456
"from IPython.display import display\n",
5557
"\n",
58+
"\n",
5659
"tab = widgets.Tab()\n",
5760
"\n",
5861
"descr_str = \"Hello\"\n",
@@ -65,9 +68,9 @@
6568
"\n",
6669
"# render in output widgets\n",
6770
"with widget_images:\n",
68-
" display(pd.DataFrame(np.random.randn(10,10)))\n",
71+
" display(pd.DataFrame(np.random.randn(10, 10)))\n",
6972
"with widget_annotations:\n",
70-
" display(pd.DataFrame(np.random.randn(10,10)))\n",
73+
" display(pd.DataFrame(np.random.randn(10, 10)))\n",
7174
"\n",
7275
"tab.children = [widget_images, widget_annotations]\n",
7376
"tab.titles = [\"Images\", \"Annotations\"]\n",
@@ -90,6 +93,7 @@
9093
"source": [
9194
"import matplotlib.pyplot as plt\n",
9295
"\n",
96+
"\n",
9397
"fig, ax = plt.subplots()\n",
9498
"ax.scatter(df[\"a\"], df[\"b\"], c=df[\"b\"], s=3)"
9599
]
@@ -125,10 +129,13 @@
125129
"import plotly.express as px\n",
126130
"import plotly.io as pio\n",
127131
"\n",
132+
"\n",
128133
"pio.renderers.default = \"notebook\"\n",
129134
"\n",
130135
"df = px.data.iris()\n",
131-
"fig = px.scatter(df, x=\"sepal_width\", y=\"sepal_length\", color=\"species\", size=\"sepal_length\")\n",
136+
"fig = px.scatter(\n",
137+
" df, x=\"sepal_width\", y=\"sepal_length\", color=\"species\", size=\"sepal_length\"\n",
138+
")\n",
132139
"fig"
133140
]
134141
},
@@ -149,11 +156,10 @@
149156
"source": [
150157
"import xarray as xr\n",
151158
"\n",
159+
"\n",
152160
"data = xr.DataArray(\n",
153-
" np.random.randn(2, 3),\n",
154-
" dims=(\"x\", \"y\"),\n",
155-
" coords={\"x\": [10, 20]}, attrs={\"foo\": \"bar\"}\n",
156-
" )\n",
161+
" np.random.randn(2, 3), dims=(\"x\", \"y\"), coords={\"x\": [10, 20]}, attrs={\"foo\": \"bar\"}\n",
162+
")\n",
157163
"data"
158164
]
159165
},
@@ -174,8 +180,9 @@
174180
"source": [
175181
"from ipyleaflet import Map, basemaps\n",
176182
"\n",
183+
"\n",
177184
"# display a map centered on France\n",
178-
"m = Map(basemap=basemaps.Esri.WorldImagery, zoom=5, center=[46.21, 2.21])\n",
185+
"m = Map(basemap=basemaps.Esri.WorldImagery, zoom=5, center=[46.21, 2.21])\n",
179186
"m"
180187
]
181188
}

docs/scripts/generate_collaborators_gallery.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
"""Uses the GitHub API to list a gallery of all people with direct access to the repository."""
1+
"""
2+
Uses the GitHub API to list a gallery of all people with direct access to the
3+
repository.
4+
"""
25

36
import json
47
import shlex
8+
59
from pathlib import Path
610
from subprocess import run
711

812
from yaml import dump
913

14+
1015
COLLABORATORS_API = "https://api.github.com/repos/pydata/pydata-sphinx-theme/collaborators?affiliation=direct"
1116

1217
print("Grabbing latest collaborators with GitHub API via GitHub's CLI...")

docs/scripts/update_kitchen_sink.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
from pathlib import Path
44
from urllib.request import urlopen
55

6+
67
EXTRA_MESSAGE = """\
78
.. note::
89
9-
The Kitchen Sink was generated from the `Sphinx Themes website <https://sphinx-themes.org/>`_, a community-supported showcase of themes for `Sphinx <https://www.sphinx-doc.org/>`_.
10+
The Kitchen Sink was generated from the
11+
`Sphinx Themes website <https://sphinx-themes.org/>`_, a community-supported showcase
12+
of themes for `Sphinx <https://www.sphinx-doc.org/>`_.
1013
Check it out to see other great themes.
1114
1215
.. button-link:: https://sphinx-themes.org

docs/user_guide/layout.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,4 +593,3 @@ Please find here the full list of keys you can use in the ``html_theme_options``
593593
.. include:: ../../src/pydata_sphinx_theme/theme/pydata_sphinx_theme/theme.conf
594594
:code: ini
595595
:class: highlight-ini
596-

pyproject.toml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,22 +100,30 @@ ignore = ["D001"] # we follow a 1 line = 1 paragraph style
100100

101101
[tool.ruff]
102102
fix = true
103+
# keep consistent with black
104+
line-length = 88
105+
indent-width = 4
103106

104107
[tool.ruff.lint]
105108
ignore = [
106-
"E501", # line too long | Black take care of it
107109
"D107", # Missing docstring in `__init__` | set the docstring in the class
110+
"D205", # 1 blank line required between summary line and description,
111+
"D212", # docstring summary must be on first physical line
112+
"W291", # let pre-commit handle trailing whitespace
108113

109114
]
110-
ignore-init-module-imports = true
111-
select = ["E", "F", "W", "I", "D", "RUF"]
115+
select = ["E", "F", "W", "I", "D", "RUF", "G"]
112116

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

116120
[tool.ruff.lint.pydocstyle]
117121
convention = "google"
118122

123+
[tool.ruff.lint.isort]
124+
lines-between-types = 1
125+
lines-after-imports = 2
126+
119127
[tool.djlint]
120128
profile = "jinja"
121129
extension = "html"

0 commit comments

Comments
 (0)