mirror of https://github.com/searxng/searxng.git
[mod] replace pycodestyle by black
"make test.black" checks for the code style "make format.python" format the python code
This commit is contained in:
parent
54bce130f9
commit
3c77412d33
7
Makefile
7
Makefile
|
@ -54,8 +54,8 @@ search.checker.%: install
|
||||||
$(Q)./manage pyenv.cmd searx-checker -v "$(subst _, ,$(patsubst search.checker.%,%,$@))"
|
$(Q)./manage pyenv.cmd searx-checker -v "$(subst _, ,$(patsubst search.checker.%,%,$@))"
|
||||||
|
|
||||||
PHONY += test ci.test test.shell
|
PHONY += test ci.test test.shell
|
||||||
ci.test: test.yamllint test.pep8 test.pylint test.unit test.robot
|
ci.test: test.yamllint test.black test.pylint test.unit test.robot
|
||||||
test: test.yamllint test.pep8 test.pylint test.unit test.robot test.shell
|
test: test.yamllint test.black test.pylint test.unit test.robot test.shell
|
||||||
test.shell:
|
test.shell:
|
||||||
$(Q)shellcheck -x -s dash \
|
$(Q)shellcheck -x -s dash \
|
||||||
dockerfiles/docker-entrypoint.sh
|
dockerfiles/docker-entrypoint.sh
|
||||||
|
@ -88,7 +88,8 @@ MANAGE += node.env node.clean
|
||||||
MANAGE += py.build py.clean
|
MANAGE += py.build py.clean
|
||||||
MANAGE += pyenv pyenv.install pyenv.uninstall
|
MANAGE += pyenv pyenv.install pyenv.uninstall
|
||||||
MANAGE += pypi.upload pypi.upload.test
|
MANAGE += pypi.upload pypi.upload.test
|
||||||
MANAGE += test.yamllint test.pylint test.pep8 test.unit test.coverage test.robot test.clean
|
MANAGE += format.python
|
||||||
|
MANAGE += test.yamllint test.pylint test.black test.unit test.coverage test.robot test.clean
|
||||||
MANAGE += themes.all themes.oscar themes.simple themes.simple.test pygments.less
|
MANAGE += themes.all themes.oscar themes.simple themes.simple.test pygments.less
|
||||||
MANAGE += static.build.commit static.build.drop static.build.restore
|
MANAGE += static.build.commit static.build.drop static.build.restore
|
||||||
MANAGE += nvm.install nvm.clean nvm.status nvm.nodejs
|
MANAGE += nvm.install nvm.clean nvm.status nvm.nodejs
|
||||||
|
|
27
manage
27
manage
|
@ -24,6 +24,8 @@ PY_SETUP_EXTRAS='[test]'
|
||||||
GECKODRIVER_VERSION="v0.30.0"
|
GECKODRIVER_VERSION="v0.30.0"
|
||||||
export NODE_MINIMUM_VERSION="16.13.0"
|
export NODE_MINIMUM_VERSION="16.13.0"
|
||||||
# SPHINXOPTS=
|
# SPHINXOPTS=
|
||||||
|
BLACK_OPTIONS=("--target-version" "py37" "--line-length" "120" "--skip-string-normalization")
|
||||||
|
BLACK_TARGETS=("--exclude" "searx/static,searx/languages.py" "searx" "searxng_extra" "tests")
|
||||||
|
|
||||||
pylint.FILES() {
|
pylint.FILES() {
|
||||||
|
|
||||||
|
@ -31,8 +33,7 @@ pylint.FILES() {
|
||||||
#
|
#
|
||||||
# # lint: pylint
|
# # lint: pylint
|
||||||
#
|
#
|
||||||
# These py files are linted by test.pylint(), all other files are linted by
|
# These py files are linted by test.pylint()
|
||||||
# test.pep8()
|
|
||||||
|
|
||||||
grep -l -r --include \*.py '^#[[:blank:]]*lint:[[:blank:]]*pylint' searx searxng_extra tests
|
grep -l -r --include \*.py '^#[[:blank:]]*lint:[[:blank:]]*pylint' searx searxng_extra tests
|
||||||
}
|
}
|
||||||
|
@ -89,10 +90,12 @@ pyenv.:
|
||||||
OK : test if virtualenv is OK
|
OK : test if virtualenv is OK
|
||||||
pypi.upload:
|
pypi.upload:
|
||||||
Upload python packages to PyPi (to test use pypi.upload.test)
|
Upload python packages to PyPi (to test use pypi.upload.test)
|
||||||
|
format.:
|
||||||
|
python : format Python code source using black
|
||||||
test.:
|
test.:
|
||||||
yamllint : lint YAML files (YAMLLINT_FILES)
|
yamllint : lint YAML files (YAMLLINT_FILES)
|
||||||
pylint : lint PYLINT_FILES, searx/engines, searx & tests
|
pylint : lint PYLINT_FILES, searx/engines, searx & tests
|
||||||
pep8 : pycodestyle (pep8) for all files except PYLINT_FILES
|
black : check black code format
|
||||||
unit : run unit tests
|
unit : run unit tests
|
||||||
coverage : run unit tests with coverage
|
coverage : run unit tests with coverage
|
||||||
robot : run robot test
|
robot : run robot test
|
||||||
|
@ -617,6 +620,12 @@ pypi.upload.test() {
|
||||||
pyenv.cmd twine upload -r testpypi "${PYDIST}"/*
|
pyenv.cmd twine upload -r testpypi "${PYDIST}"/*
|
||||||
}
|
}
|
||||||
|
|
||||||
|
format.python() {
|
||||||
|
build_msg TEST "[format.python] black \$BLACK_TARGETS"
|
||||||
|
pyenv.cmd black "${BLACK_OPTIONS[@]}" "${BLACK_TARGETS[@]}"
|
||||||
|
dump_return $?
|
||||||
|
}
|
||||||
|
|
||||||
test.yamllint() {
|
test.yamllint() {
|
||||||
build_msg TEST "[yamllint] \$YAMLLINT_FILES"
|
build_msg TEST "[yamllint] \$YAMLLINT_FILES"
|
||||||
pyenv.cmd yamllint --format parsable "${YAMLLINT_FILES[@]}"
|
pyenv.cmd yamllint --format parsable "${YAMLLINT_FILES[@]}"
|
||||||
|
@ -646,15 +655,9 @@ test.pylint() {
|
||||||
dump_return $?
|
dump_return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
test.pep8() {
|
test.black() {
|
||||||
build_msg TEST 'pycodestyle (formerly pep8)'
|
build_msg TEST "[black] \$BLACK_TARGETS"
|
||||||
local _exclude=""
|
pyenv.cmd black --check "${BLACK_OPTIONS[@]}" "${BLACK_TARGETS[@]}"
|
||||||
printf -v _exclude '%s, ' "${PYLINT_FILES[@]}"
|
|
||||||
pyenv.cmd pycodestyle \
|
|
||||||
--exclude="searx/static, searx/languages.py, $_exclude " \
|
|
||||||
--max-line-length=120 \
|
|
||||||
--ignore "E117,E252,E402,E722,E741,W503,W504,W605" \
|
|
||||||
searx tests
|
|
||||||
dump_return $?
|
dump_return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
mock==4.0.3
|
mock==4.0.3
|
||||||
nose2[coverage_plugin]==0.10.0
|
nose2[coverage_plugin]==0.10.0
|
||||||
cov-core==1.15.0
|
cov-core==1.15.0
|
||||||
|
black==21.12b0
|
||||||
pycodestyle==2.8.0
|
pycodestyle==2.8.0
|
||||||
pylint==2.12.2
|
pylint==2.12.2
|
||||||
splinter==0.17.0
|
splinter==0.17.0
|
||||||
|
|
Loading…
Reference in New Issue