Skip to content

Commit 2a18083

Browse files
committed
ci(pre-commit): Add more hooks and fix various code smells
1 parent 19b4d66 commit 2a18083

File tree

16 files changed

+337
-12
lines changed

16 files changed

+337
-12
lines changed

.codespellignore

Whitespace-only changes.

.github/workflows/build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,3 @@ jobs:
120120

121121
- name: Publish Distributions to PyPI
122122
uses: pypa/gh-action-pypi-publish@release/v1
123-

.pre-commit-config.yaml

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,67 @@ repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
33
rev: v4.6.0
44
hooks:
5-
- id: trailing-whitespace
6-
- id: check-merge-conflict
7-
- id: check-yaml
8-
- id: check-executables-have-shebangs
9-
- id: mixed-line-ending
5+
- id: check-added-large-files
6+
args: ["--maxkb=500"]
7+
- id: check-ast
8+
- id: fix-byte-order-marker
9+
- id: check-builtin-literals
10+
- id: check-case-conflict
11+
- id: check-docstring-first
12+
- id: check-executables-have-shebangs
13+
- id: check-json
14+
- id: check-shebang-scripts-are-executable
15+
- id: pretty-format-json
16+
args: ["--autofix"]
17+
- id: check-merge-conflict
18+
- id: check-symlinks
19+
- id: check-toml
20+
- id: check-vcs-permalinks
21+
- id: check-xml
22+
- id: check-yaml
23+
- id: debug-statements
24+
- id: destroyed-symlinks
25+
- id: detect-private-key
26+
- id: end-of-file-fixer
27+
- id: file-contents-sorter
28+
- id: fix-byte-order-marker
29+
- id: forbid-new-submodules
30+
- id: mixed-line-ending
31+
args: ["--fix=lf"]
32+
- id: requirements-txt-fixer
33+
- id: sort-simple-yaml
34+
- id: trailing-whitespace
1035
- repo: https://github.com/astral-sh/ruff-pre-commit
11-
rev: v0.6.8
36+
rev: v0.6.9
1237
hooks:
1338
- id: ruff
1439
args: [ --fix ]
1540
- id: ruff-format
41+
- repo: https://github.com/codespell-project/codespell
42+
rev: v2.3.0
43+
hooks:
44+
- id: codespell
45+
args: [
46+
--ignore-words=.codespellignore
47+
]
48+
- repo: https://github.com/markdownlint/markdownlint
49+
rev: v0.12.0
50+
hooks:
51+
- id: markdownlint
52+
- repo: https://github.com/Holzhaus/sourceheaders
53+
rev: v0.0.4
54+
hooks:
55+
- id: sourceheaders
56+
- repo: https://github.com/PyCQA/bandit
57+
rev: "1.7.10"
58+
hooks:
59+
- id: bandit
60+
args: ["-c", "pyproject.toml", "--"]
61+
additional_dependencies: ["bandit[toml]"]
62+
- repo: https://github.com/gitleaks/gitleaks
63+
rev: v8.20.0
64+
hooks:
65+
- id: gitleaks
1666
- repo: local
1767
hooks:
1868
- id: version-check

.pre-commit/version_check.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,31 @@
11
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# Copyright (c) 2024 Jan Holthuis <[email protected]>
4+
#
5+
# Redistribution and use in source and binary forms, with or without
6+
# modification, are permitted provided that the following conditions are met:
7+
#
8+
# 1. Redistributions of source code must retain the above copyright notice,
9+
# this list of conditions and the following disclaimer.
10+
#
11+
# 2. Redistributions in binary form must reproduce the above copyright notice,
12+
# this list of conditions and the following disclaimer in the documentation
13+
# and/or other materials provided with the distribution.
14+
#
15+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25+
# POSSIBILITY OF SUCH DAMAGE.
26+
#
27+
# SPDX-License-Identifier: BSD-2-Clause
28+
229
import importlib.util
330
import os
431
import pkgutil

.sourceheaders.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[general]
2+
license = "BSD-2-Clause"
3+
copyright_holder = "Jan Holthuis <[email protected]>"
4+
prefer_inline = true
5+
width = 79

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# sphinx-multiversion [![License][license-badge]][license] [![Build Status][build-badge]][build] [![pre-commit.ci status][pre-commit-badge]][pre-commit]
1+
# sphinx-multiversion [![License][license-badge]][license][![Build][build-badge]][build][![pre-commit.ci][pre-commit-badge]][pre-commit]
22

33
Sphinx extension for building self-hosted versioned docs.
44

55
This extension aims to provide a clean implementation that tries to avoid
66
messing with Sphinx internals as much as possible.
77

8-
Documentation can be found at: https://sphinx-contrib.github.io/multiversion/
8+
Documentation can be found at: <https://sphinx-contrib.github.io/multiversion/>
99

1010
[license]: https://github.com/sphinx-contrib/multiversion/blob/main/LICENSE
1111
[license-badge]: https://img.shields.io/github/license/sphinx-contrib/multiversion

docs/conf.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,30 @@
11
# -*- coding: utf-8 -*-
2+
# Copyright (c) 2024 Jan Holthuis <[email protected]>
3+
#
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions are met:
6+
#
7+
# 1. Redistributions of source code must retain the above copyright notice,
8+
# this list of conditions and the following disclaimer.
9+
#
10+
# 2. Redistributions in binary form must reproduce the above copyright notice,
11+
# this list of conditions and the following disclaimer in the documentation
12+
# and/or other materials provided with the distribution.
13+
#
14+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24+
# POSSIBILITY OF SUCH DAMAGE.
25+
#
26+
# SPDX-License-Identifier: BSD-2-Clause
27+
228
"""Sphinx configuration file."""
329

430
import time

docs/configuration.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Here are some examples:
8585
Output Directory Format
8686
=======================
8787

88-
Each version will be built into a seperate subdirectory of the Sphinx output directory.
88+
Each version will be built into a separate subdirectory of the Sphinx output directory.
8989
The ``smv_outputdir_format`` setting determines the directory structure for the subdirectories. It is a new-style Python formatting string with two parameters - ``ref`` and ``config``.
9090

9191
Here are some examples:
@@ -113,7 +113,7 @@ You can override configuration variables the same way as you're used to with ``s
113113

114114
Since ``sphinx-multiversion`` copies the branch data into a temporary directory and builds them there while leaving the current working directory unchanged, relative paths in your :file:`conf.py` will refer to the path of the version *you're building from*, not the path of the version you are trying to build documentation for.
115115

116-
Sometimes it might be necessary to override the configured path via a command line overide.
116+
Sometimes it might be necessary to override the configured path via a command line argument.
117117
``sphinx-multiversion`` allows you to insert placeholders into your override strings that will automatically be replaced with the correct value for the version you're building the documentation for.
118118

119119
Here's an example for the `exhale extension <exhale_>`_:

pyproject.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,17 @@ include = [
3838
"/sphinx_multiversion",
3939
]
4040

41+
[tool.bandit]
42+
skips = [
43+
# Asserts are actually fine for checking the developer's assumptions, we
44+
# "just" mustn't rely these assert in production code.
45+
"B101",
46+
# We need `subprocess` module.
47+
"B404",
48+
# As long as we don't use `shell=True` when spawning a subprocess, this
49+
# should be fine.
50+
"B603",
51+
]
52+
4153
[tool.ruff]
4254
line-length = 79

sphinx_multiversion/__init__.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,30 @@
11
# -*- coding: utf-8 -*-
2+
# Copyright (c) 2024 Jan Holthuis <[email protected]>
3+
#
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions are met:
6+
#
7+
# 1. Redistributions of source code must retain the above copyright notice,
8+
# this list of conditions and the following disclaimer.
9+
#
10+
# 2. Redistributions in binary form must reproduce the above copyright notice,
11+
# this list of conditions and the following disclaimer in the documentation
12+
# and/or other materials provided with the distribution.
13+
#
14+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24+
# POSSIBILITY OF SUCH DAMAGE.
25+
#
26+
# SPDX-License-Identifier: BSD-2-Clause
27+
228
from .sphinx import setup
329
from .main import main
430

0 commit comments

Comments
 (0)