[ci] [python-package] move tool configuration to pyproject.toml (#5872)

This commit is contained in:
James Lamb 2023-05-08 18:05:54 -05:00 коммит произвёл GitHub
Родитель 3d63ddac02
Коммит 1c873af9c0
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
6 изменённых файлов: 45 добавлений и 21 удалений

Просмотреть файл

@ -1,41 +1,30 @@
#!/bin/sh
DIR_TO_CHECK=${1}
echo "running flake8"
flake8 \
--ignore=E501,W503 \
--exclude=./.nuget,./external_libs,./python-package/build,./python-package/compile \
"${DIR_TO_CHECK}" \
--config=./python-package/setup.cfg \
. \
|| exit -1
echo "done running flake8"
echo "running pydocstyle"
pydocstyle \
--convention=numpy \
--add-ignore=D105 \
--match-dir="^(?!^external_libs|test|example).*" \
--match="(?!^test_|setup).*\.py" \
"${DIR_TO_CHECK}" \
--config=./python-package/pyproject.toml \
. \
|| exit -1
echo "done running pydocstyle"
echo "running isort"
isort \
--check-only \
"${DIR_TO_CHECK}" \
--settings-path=./python-package/pyproject.toml \
. \
|| exit -1
echo "done running isort"
echo "running mypy"
mypy \
--ignore-missing-imports \
--exclude 'build/' \
--exclude 'compile/' \
--exclude 'docs/' \
--exclude 'examples/' \
--exclude 'external_libs/' \
--exclude 'tests/' \
"${DIR_TO_CHECK}/python-package" \
--config-file=./python-package/pyproject.toml \
./python-package \
|| true
echo "done running mypy"

Просмотреть файл

@ -78,7 +78,7 @@ if [[ $TASK == "lint" ]]; then
"r-lintr>=3.0"
source activate $CONDA_ENV
echo "Linting Python code"
sh ${BUILD_DIRECTORY}/.ci/lint-python.sh ${BUILD_DIRECTORY} || exit -1
sh ${BUILD_DIRECTORY}/.ci/lint-python.sh || exit -1
echo "Linting R code"
Rscript ${BUILD_DIRECTORY}/.ci/lint_r_code.R ${BUILD_DIRECTORY} || exit -1
echo "Linting C++ code"

Просмотреть файл

@ -189,6 +189,11 @@ create_isolated_source_dir() {
cp -R ./python-package ./lightgbm-python
# temporarily remove these files until
# https://github.com/microsoft/LightGBM/issues/5061 is done
rm ./lightgbm-python/pyproject.toml
rm ./lightgbm-python/setup.cfg
cp LICENSE ./lightgbm-python/
cp VERSION.txt ./lightgbm-python/lightgbm/VERSION.txt

Просмотреть файл

@ -259,7 +259,7 @@ To check that a contribution to the package matches its style expectations, run
.. code:: sh
sh .ci/lint-python.sh .
sh .ci/lint-python.sh
.. |License| image:: https://img.shields.io/github/license/microsoft/lightgbm.svg
:target: https://github.com/microsoft/LightGBM/blob/master/LICENSE

Просмотреть файл

@ -0,0 +1,18 @@
[tool.isort]
line_length = 120
skip_glob = [
"external_libs/*",
"lightgbm-python/*"
]
[tool.mypy]
exclude = 'build/*|compile/*|docs/*|examples/*|external_libs/*|lightgbm-python/*|tests/*'
ignore_missing_imports = true
[tool.pydocstyle]
add_ignore = [
'D105'
]
convention = 'numpy'
match = '(?!^test_|setup).*\.py'
match_dir = '^(?!^external_libs|lightgbm-python|test|example).*'

12
python-package/setup.cfg Normal file
Просмотреть файл

@ -0,0 +1,12 @@
[flake8]
ignore =
# line too long
E501,
# line break occurred before a binary operator
W503
exclude =
./.nuget,
./external_libs,
./lightgbm-python,
./python-package/build,
./python-package/compile