Unverified Commit 1c873af9 authored by James Lamb's avatar James Lamb Committed by GitHub
Browse files

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

parent 3d63ddac
#!/bin/sh #!/bin/sh
DIR_TO_CHECK=${1}
echo "running flake8" echo "running flake8"
flake8 \ flake8 \
--ignore=E501,W503 \ --config=./python-package/setup.cfg \
--exclude=./.nuget,./external_libs,./python-package/build,./python-package/compile \ . \
"${DIR_TO_CHECK}" \
|| exit -1 || exit -1
echo "done running flake8" echo "done running flake8"
echo "running pydocstyle" echo "running pydocstyle"
pydocstyle \ pydocstyle \
--convention=numpy \ --config=./python-package/pyproject.toml \
--add-ignore=D105 \ . \
--match-dir="^(?!^external_libs|test|example).*" \
--match="(?!^test_|setup).*\.py" \
"${DIR_TO_CHECK}" \
|| exit -1 || exit -1
echo "done running pydocstyle" echo "done running pydocstyle"
echo "running isort" echo "running isort"
isort \ isort \
--check-only \ --check-only \
"${DIR_TO_CHECK}" \ --settings-path=./python-package/pyproject.toml \
. \
|| exit -1 || exit -1
echo "done running isort" echo "done running isort"
echo "running mypy" echo "running mypy"
mypy \ mypy \
--ignore-missing-imports \ --config-file=./python-package/pyproject.toml \
--exclude 'build/' \ ./python-package \
--exclude 'compile/' \
--exclude 'docs/' \
--exclude 'examples/' \
--exclude 'external_libs/' \
--exclude 'tests/' \
"${DIR_TO_CHECK}/python-package" \
|| true || true
echo "done running mypy" echo "done running mypy"
...@@ -78,7 +78,7 @@ if [[ $TASK == "lint" ]]; then ...@@ -78,7 +78,7 @@ if [[ $TASK == "lint" ]]; then
"r-lintr>=3.0" "r-lintr>=3.0"
source activate $CONDA_ENV source activate $CONDA_ENV
echo "Linting Python code" 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" echo "Linting R code"
Rscript ${BUILD_DIRECTORY}/.ci/lint_r_code.R ${BUILD_DIRECTORY} || exit -1 Rscript ${BUILD_DIRECTORY}/.ci/lint_r_code.R ${BUILD_DIRECTORY} || exit -1
echo "Linting C++ code" echo "Linting C++ code"
......
...@@ -189,6 +189,11 @@ create_isolated_source_dir() { ...@@ -189,6 +189,11 @@ create_isolated_source_dir() {
cp -R ./python-package ./lightgbm-python 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 LICENSE ./lightgbm-python/
cp VERSION.txt ./lightgbm-python/lightgbm/VERSION.txt 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 ...@@ -259,7 +259,7 @@ To check that a contribution to the package matches its style expectations, run
.. code:: sh .. code:: sh
sh .ci/lint-python.sh . sh .ci/lint-python.sh
.. |License| image:: https://img.shields.io/github/license/microsoft/lightgbm.svg .. |License| image:: https://img.shields.io/github/license/microsoft/lightgbm.svg
:target: https://github.com/microsoft/LightGBM/blob/master/LICENSE :target: https://github.com/microsoft/LightGBM/blob/master/LICENSE
......
[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).*'
[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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment