Skip to content

Commit 97ff708

Browse files
[ci] use 'pre-commit' to run 'rstcheck' (#6989)
Co-authored-by: Nikita Titov <[email protected]>
1 parent ccc06d1 commit 97ff708

File tree

6 files changed

+22
-14
lines changed

6 files changed

+22
-14
lines changed

.ci/test.sh

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ if [[ $TASK == "lint" ]]; then
115115
# shellcheck disable=SC1091
116116
source activate "${CONDA_ENV}"
117117
echo "Linting Python and bash code"
118-
bash ./.ci/lint-python-bash.sh || exit 1
118+
bash ./.ci/run-pre-commit-mypy.sh || exit 1
119119
echo "Linting R code"
120120
Rscript ./.ci/lint-r-code.R "${BUILD_DIRECTORY}" || exit 1
121121
echo "Linting C++ code"
@@ -129,19 +129,8 @@ if [[ $TASK == "check-docs" ]] || [[ $TASK == "check-links" ]]; then
129129
conda env create \
130130
-n "${CONDA_ENV}" \
131131
--file ./docs/env.yml || exit 1
132-
conda install \
133-
-q \
134-
-y \
135-
-n "${CONDA_ENV}" \
136-
'doxygen>=1.10.0' \
137-
'rstcheck>=6.2.4' || exit 1
138132
# shellcheck disable=SC1091
139133
source activate "${CONDA_ENV}"
140-
# check reStructuredText formatting
141-
find "${BUILD_DIRECTORY}/python-package" -type f -name "*.rst" \
142-
-exec rstcheck --report-level warning {} \+ || exit 1
143-
find "${BUILD_DIRECTORY}/docs" -type f -name "*.rst" \
144-
-exec rstcheck --report-level warning --ignore-directives=autoclass,autofunction,autosummary,doxygenfile {} \+ || exit 1
145134
# build docs
146135
make -C docs html || exit 1
147136
if [[ $TASK == "check-links" ]]; then

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ repos:
2727
hooks:
2828
- id: yamllint
2929
args: ["--strict"]
30+
- repo: https://github.com/rstcheck/rstcheck
31+
rev: v6.2.5
32+
hooks:
33+
- id: rstcheck
34+
args: ["--config", "./python-package/pyproject.toml"]
35+
additional_dependencies:
36+
- breathe>=4.36.0
37+
- sphinx>=8.1.3
38+
- sphinx_rtd_theme>=3.0.1
3039
- repo: https://github.com/astral-sh/ruff-pre-commit
3140
# Ruff version.
3241
rev: v0.12.5

docs/env.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ channels:
33
- nodefaults
44
- conda-forge
55
dependencies:
6-
- breathe>=4.35
6+
- breathe>=4.36
7+
- doxygen>=1.13.2
78
- python=3.12
89
- r-base>=4.3.3
910
- r-data.table=1.16.4

python-package/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ To check that a contribution to the package matches its style expectations, run
346346

347347
.. code:: sh
348348
349-
bash .ci/lint-python-bash.sh
349+
bash .ci/run-pre-commit-mypy.sh
350350
351351
To run the tests locally and compute test coverage, install the Python package using one of the options mentioned above.
352352
Then run the following from the root of the repo.

python-package/pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ disallow_untyped_defs = true
9191
exclude = 'build/*|compile/*|docs/*|examples/*|external_libs/*|lightgbm-python/*|tests/*'
9292
ignore_missing_imports = true
9393

94+
[tool.rstcheck]
95+
report_level = "WARNING"
96+
ignore_directives = [
97+
"autoclass",
98+
"autofunction",
99+
"autosummary",
100+
"doxygenfile"
101+
]
102+
94103
[tool.ruff]
95104
exclude = [
96105
"build",

0 commit comments

Comments
 (0)