diff --git a/.ci/lint-python-bash.sh b/.ci/run-pre-commit-mypy.sh similarity index 100% rename from .ci/lint-python-bash.sh rename to .ci/run-pre-commit-mypy.sh diff --git a/.ci/test.sh b/.ci/test.sh index 63da0e7d04a3..6b8f31135da9 100755 --- a/.ci/test.sh +++ b/.ci/test.sh @@ -115,7 +115,7 @@ if [[ $TASK == "lint" ]]; then # shellcheck disable=SC1091 source activate "${CONDA_ENV}" echo "Linting Python and bash code" - bash ./.ci/lint-python-bash.sh || exit 1 + bash ./.ci/run-pre-commit-mypy.sh || exit 1 echo "Linting R code" Rscript ./.ci/lint-r-code.R "${BUILD_DIRECTORY}" || exit 1 echo "Linting C++ code" @@ -129,19 +129,8 @@ if [[ $TASK == "check-docs" ]] || [[ $TASK == "check-links" ]]; then conda env create \ -n "${CONDA_ENV}" \ --file ./docs/env.yml || exit 1 - conda install \ - -q \ - -y \ - -n "${CONDA_ENV}" \ - 'doxygen>=1.10.0' \ - 'rstcheck>=6.2.4' || exit 1 # shellcheck disable=SC1091 source activate "${CONDA_ENV}" - # check reStructuredText formatting - find "${BUILD_DIRECTORY}/python-package" -type f -name "*.rst" \ - -exec rstcheck --report-level warning {} \+ || exit 1 - find "${BUILD_DIRECTORY}/docs" -type f -name "*.rst" \ - -exec rstcheck --report-level warning --ignore-directives=autoclass,autofunction,autosummary,doxygenfile {} \+ || exit 1 # build docs make -C docs html || exit 1 if [[ $TASK == "check-links" ]]; then diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9897937ab88a..6c8fc0f8335a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,6 +27,15 @@ repos: hooks: - id: yamllint args: ["--strict"] + - repo: https://github.com/rstcheck/rstcheck + rev: v6.2.5 + hooks: + - id: rstcheck + args: ["--config", "./python-package/pyproject.toml"] + additional_dependencies: + - breathe>=4.36.0 + - sphinx>=8.1.3 + - sphinx_rtd_theme>=3.0.1 - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. rev: v0.12.5 diff --git a/docs/env.yml b/docs/env.yml index 30f84a26ce69..cf2bf82b247a 100644 --- a/docs/env.yml +++ b/docs/env.yml @@ -3,7 +3,8 @@ channels: - nodefaults - conda-forge dependencies: - - breathe>=4.35 + - breathe>=4.36 + - doxygen>=1.13.2 - python=3.12 - r-base>=4.3.3 - r-data.table=1.16.4 diff --git a/python-package/README.rst b/python-package/README.rst index 987269266488..ac20a4f56b79 100644 --- a/python-package/README.rst +++ b/python-package/README.rst @@ -346,7 +346,7 @@ To check that a contribution to the package matches its style expectations, run .. code:: sh - bash .ci/lint-python-bash.sh + bash .ci/run-pre-commit-mypy.sh To run the tests locally and compute test coverage, install the Python package using one of the options mentioned above. Then run the following from the root of the repo. diff --git a/python-package/pyproject.toml b/python-package/pyproject.toml index 088e031db9c8..b7ffd760ac94 100644 --- a/python-package/pyproject.toml +++ b/python-package/pyproject.toml @@ -91,6 +91,15 @@ disallow_untyped_defs = true exclude = 'build/*|compile/*|docs/*|examples/*|external_libs/*|lightgbm-python/*|tests/*' ignore_missing_imports = true +[tool.rstcheck] +report_level = "WARNING" +ignore_directives = [ + "autoclass", + "autofunction", + "autosummary", + "doxygenfile" +] + [tool.ruff] exclude = [ "build",