Skip to content

Commit 79febab

Browse files
committed
Lint on GitHub Actions via pre-commit
1 parent be0e655 commit 79febab

File tree

10 files changed

+121
-50
lines changed

10 files changed

+121
-50
lines changed

.flake8

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
max-line-length = 88

.github/workflows/lint.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Lint
2+
3+
on: [push, pull_request, workflow_dispatch]
4+
5+
env:
6+
FORCE_COLOR: 1
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
lint:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-python@v4
18+
with:
19+
python-version: "3.x"
20+
- uses: pre-commit/[email protected]

.github/workflows/pypi-package.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919

2020
steps:
21-
- uses: actions/checkout@v3
21+
- uses: actions/checkout@v4
2222

2323
- uses: hynek/build-and-inspect-python-package@v1
2424

.github/workflows/tests.yml

+18-15
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
name: Tests
22

3-
on:
4-
push:
5-
pull_request:
6-
workflow_dispatch:
3+
on: [push, pull_request, workflow_dispatch]
4+
5+
env:
6+
FORCE_COLOR: 1
77

88
jobs:
99
build_doc:
1010
name: Build CPython docs
1111
runs-on: ubuntu-latest
1212
strategy:
13+
fail-fast: false
1314
matrix:
14-
branch: [origin/main, 3.12, 3.11, '3.10', 3.9, 3.8]
15+
branch: ["origin/main", "3.12", "3.11", "3.10", "3.9", "3.8"]
1516
steps:
16-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v4
1718
- uses: actions/setup-python@v4
1819
with:
1920
python-version: 3
21+
allow-prereleases: true
22+
cache: pip
2023
- name: Clone docsbuild scripts
2124
run: |
2225
git clone https://github.com/python/docsbuild-scripts/
@@ -26,15 +29,15 @@ jobs:
2629
python -m pip install -r docsbuild-scripts/requirements.txt
2730
- name: Build documentation
2831
run: >
29-
python ./docsbuild-scripts/build_docs.py
30-
--quick
31-
--build-root ./build_root
32-
--www-root ./www
33-
--log-directory ./logs
34-
--group $(id -g)
35-
--skip-cache-invalidation
36-
--theme $(pwd)
37-
--language en
32+
python ./docsbuild-scripts/build_docs.py
33+
--quick
34+
--build-root ./build_root
35+
--www-root ./www
36+
--log-directory ./logs
37+
--group $(id -g)
38+
--skip-cache-invalidation
39+
--theme $(pwd)
40+
--language en
3841
--branch ${{ matrix.branch }}
3942
- name: Upload
4043
uses: actions/upload-artifact@v3

.pre-commit-config.yaml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
repos:
2+
- repo: https://github.com/asottile/pyupgrade
3+
rev: v3.15.0
4+
hooks:
5+
- id: pyupgrade
6+
args: [--py38-plus]
7+
8+
- repo: https://github.com/psf/black-pre-commit-mirror
9+
rev: 23.9.1
10+
hooks:
11+
- id: black
12+
13+
- repo: https://github.com/PyCQA/isort
14+
rev: 5.12.0
15+
hooks:
16+
- id: isort
17+
args: [--add-import=from __future__ import annotations]
18+
19+
- repo: https://github.com/PyCQA/flake8
20+
rev: 6.1.0
21+
hooks:
22+
- id: flake8
23+
additional_dependencies:
24+
[flake8-2020, flake8-implicit-str-concat, flake8-logging]
25+
26+
- repo: https://github.com/pre-commit/pygrep-hooks
27+
rev: v1.10.0
28+
hooks:
29+
- id: python-check-blanket-noqa
30+
31+
- repo: https://github.com/pre-commit/pre-commit-hooks
32+
rev: v4.5.0
33+
hooks:
34+
- id: check-case-conflict
35+
- id: check-executables-have-shebangs
36+
- id: check-merge-conflict
37+
- id: check-json
38+
- id: check-toml
39+
- id: check-yaml
40+
- id: debug-statements
41+
- id: end-of-file-fixer
42+
- id: trailing-whitespace
43+
44+
- repo: https://github.com/abravalheri/validate-pyproject
45+
rev: v0.14
46+
hooks:
47+
- id: validate-pyproject
48+
49+
ci:
50+
autoupdate_schedule: quarterly

README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ projects if you so choose, but please keep in mind that in doing so you're also
1010
choosing to accept some of the responsibility for maintaining that collective
1111
trust.
1212

13-
To use the theme, install it into your docs build environment via ``pip``
13+
To use the theme, install it into your docs build environment via ``pip``
1414
(preferably in a virtual environment).
1515

1616

code_of_conduct.rst

-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ which includes all infrastructure used in the development of Python itself
1111

1212
In general this means everyone is expected to be open, considerate, and
1313
respectful of others no matter what their position is within the project.
14-

pyproject.toml

+23-28
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,38 @@
11
[build-system]
2-
requires = ["flit_core>=3.7"]
32
build-backend = "flit_core.buildapi"
3+
requires = [
4+
"flit_core>=3.7",
5+
]
46

5-
# project metadata
67
[project]
78
name = "python-docs-theme"
89
version = "2023.9"
910
description = "The Sphinx theme for the CPython docs and related projects"
1011
readme = "README.rst"
11-
urls.Code = "https://github.com/python/python-docs-theme"
12-
urls.Download = "https://pypi.org/project/python-docs-theme/"
13-
urls.Homepage = "https://github.com/python/python-docs-theme/"
14-
urls."Issue tracker" = "https://github.com/python/python-docs-theme/issues"
1512
license.file = "LICENSE"
13+
authors = [{name = "PyPA", email = "[email protected]"}]
1614
requires-python = ">=3.8"
17-
18-
# Classifiers list: https://pypi.org/classifiers/
1915
classifiers = [
20-
"Development Status :: 5 - Production/Stable",
21-
"Framework :: Sphinx :: Theme",
22-
"Intended Audience :: Developers",
23-
"License :: OSI Approved :: Python Software Foundation License",
24-
"Operating System :: OS Independent",
25-
"Topic :: Documentation",
26-
"Topic :: Software Development :: Documentation",
27-
"Programming Language :: Python",
28-
"Programming Language :: Python :: 3",
29-
"Programming Language :: Python :: 3.8",
30-
"Programming Language :: Python :: 3.9",
31-
"Programming Language :: Python :: 3.10",
32-
"Programming Language :: Python :: 3.11",
33-
"Programming Language :: Python :: 3.12",
34-
"Programming Language :: Python :: 3.13",
16+
"Development Status :: 5 - Production/Stable",
17+
"Framework :: Sphinx :: Theme",
18+
"Intended Audience :: Developers",
19+
"License :: OSI Approved :: Python Software Foundation License",
20+
"Operating System :: OS Independent",
21+
"Programming Language :: Python",
22+
"Programming Language :: Python :: 3 :: Only",
23+
"Programming Language :: Python :: 3.8",
24+
"Programming Language :: Python :: 3.9",
25+
"Programming Language :: Python :: 3.10",
26+
"Programming Language :: Python :: 3.11",
27+
"Programming Language :: Python :: 3.12",
28+
"Programming Language :: Python :: 3.13",
29+
"Topic :: Documentation",
30+
"Topic :: Software Development :: Documentation",
3531
]
36-
37-
[[project.authors]]
38-
name = "PyPA"
39-
40-
32+
urls.Code = "https://github.com/python/python-docs-theme"
33+
urls.Download = "https://pypi.org/project/python-docs-theme/"
34+
urls.Homepage = "https://github.com/python/python-docs-theme/"
35+
urls."Issue tracker" = "https://github.com/python/python-docs-theme/issues"
4136
[project.entry-points."sphinx.html_themes"]
4237
python_docs_theme = 'python_docs_theme'
4338

python_docs_theme/__init__.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
from __future__ import annotations
2+
13
import hashlib
24
import os
35
from functools import lru_cache
46
from pathlib import Path
5-
from typing import Any, Dict, List
7+
from typing import Any
68

79
import sphinx.application
810
from sphinx.builders.html import StandaloneHTMLBuilder
@@ -19,7 +21,7 @@ def _asset_hash(path: str) -> str:
1921
return f"{path}?digest={digest}"
2022

2123

22-
def _add_asset_hashes(static: List[str], add_digest_to: List[str]) -> None:
24+
def _add_asset_hashes(static: list[str], add_digest_to: list[str]) -> None:
2325
for asset in add_digest_to:
2426
index = static.index(asset)
2527
static[index].filename = _asset_hash(asset) # type: ignore
@@ -29,7 +31,7 @@ def _html_page_context(
2931
app: sphinx.application.Sphinx,
3032
pagename: str,
3133
templatename: str,
32-
context: Dict[str, Any],
34+
context: dict[str, Any],
3335
doctree: Any,
3436
) -> None:
3537
if app.config.html_theme != "python_docs_theme":

python_docs_theme/static/menu.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ document.addEventListener("DOMContentLoaded", function () {
5454
closeMenu()
5555
}
5656
})
57-
})
57+
})

0 commit comments

Comments
 (0)