Merge pull request #783 from not-my-profile/pyrightconfig.json

[enh] add pyrightconfig.json and integrate pyright into CI
This commit is contained in:
Martin Fischer 2022-01-24 08:02:00 +01:00 committed by GitHub
commit 1f15d50aac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 62 additions and 14 deletions

View File

@ -32,6 +32,10 @@
;; Jedi, flycheck & other python stuff should use the 'python-shell-interpreter'
;; from the local py3 environment.
;;
;; For pyright support you need to install::
;;
;; M-x package-install lsp-pyright
;;
;; Other useful jedi stuff you might add to your ~/.emacs::
;;
;; (global-set-key [f6] 'flycheck-mode)
@ -104,7 +108,10 @@
(python-mode
. ((eval . (progn
;; use nodejs from the (local) NVM environment (see nvm-dir)
(nvm-use-for-buffer)
(if (featurep 'lsp-pyright)
(lsp))
(setq-local python-environment-virtualenv
(list (expand-file-name "bin/virtualenv" python-shell-virtualenv-root)
;;"--system-site-packages"

5
.gitignore vendored
View File

@ -1,4 +1,4 @@
# to sync with .dockerignore
# to sync with .dockerignore & pyrightconfig.json
*.pyc
*/*.pyc
@ -16,3 +16,6 @@ dist/
local/
gh-pages/
*.egg-info/
/package-lock.json
/node_modules/

View File

@ -1,8 +0,0 @@
# -*- coding: utf-8; mode: conf-unix -*-
#
# Developement tools pre-installed in NVM's node installation [1]
#
# [1] https://github.com/nvm-sh/nvm#default-global-packages-from-file-while-installing
eslint

View File

@ -50,8 +50,8 @@ search.checker.%: install
$(Q)./manage pyenv.cmd searx-checker -v "$(subst _, ,$(patsubst search.checker.%,%,$@))"
PHONY += test ci.test test.shell
ci.test: test.yamllint test.black test.pylint test.unit test.robot test.rst
test: test.yamllint test.black test.pylint test.unit test.robot test.rst test.shell
ci.test: test.yamllint test.black test.pyright test.pylint test.unit test.robot test.rst
test: test.yamllint test.black test.pyright test.pylint test.unit test.robot test.rst test.shell
test.shell:
$(Q)shellcheck -x -s dash \
dockerfiles/docker-entrypoint.sh
@ -86,7 +86,7 @@ MANAGE += py.build py.clean
MANAGE += pyenv pyenv.install pyenv.uninstall
MANAGE += pypi.upload pypi.upload.test
MANAGE += format.python
MANAGE += test.yamllint test.pylint test.black test.unit test.coverage test.robot test.rst test.clean
MANAGE += test.yamllint test.pylint test.pyright test.black test.unit test.coverage test.robot test.rst test.clean
MANAGE += themes.all themes.oscar themes.simple themes.simple.test pygments.less
MANAGE += static.build.commit static.build.drop static.build.restore
MANAGE += nvm.install nvm.clean nvm.status nvm.nodejs

19
manage
View File

@ -20,6 +20,8 @@ source "$(dirname "${BASH_SOURCE[0]}")/utils/lib_go.sh"
# shellcheck source=utils/lib_redis.sh
source "$(dirname "${BASH_SOURCE[0]}")/utils/lib_redis.sh"
PATH="${REPO_ROOT}/node_modules/.bin:${PATH}"
# config
PYOBJECTS="searx"
@ -103,6 +105,7 @@ format.:
test.:
yamllint : lint YAML files (YAMLLINT_FILES)
pylint : lint PYLINT_FILES, searx/engines, searx & tests
pyright : static type check of python sources
black : check black code format
unit : run unit tests
coverage : run unit tests with coverage
@ -558,6 +561,12 @@ node.env() {
dump_return $?
}
node.env.devtools() {
nodejs.ensure
build_msg INSTALL "package.json: developer and CI tools"
npm install
}
node.clean() {
if ! required_commands npm 2>/dev/null; then
build_msg CLEAN "npm is not installed / ignore npm dependencies"
@ -682,6 +691,16 @@ test.pylint() {
dump_return $?
}
test.pyright() {
build_msg TEST "[pyright] static type check of python sources"
node.env.devtools
# We run Pyright in the virtual environment because Pyright
# executes "python" to determine the Python version.
pyenv.cmd npx --no-install pyright -p pyrightconfig-ci.json
dump_return $?
}
test.black() {
build_msg TEST "[black] \$BLACK_TARGETS"
pyenv.cmd black --check --diff "${BLACK_OPTIONS[@]}" "${BLACK_TARGETS[@]}"

6
package.json Normal file
View File

@ -0,0 +1,6 @@
{
"dependencies": {
"eslint": "^8.7.0",
"pyright": "^1.1.212"
}
}

10
pyrightconfig-ci.json Normal file
View File

@ -0,0 +1,10 @@
{
"venvPath": "local",
"venv": "py3",
"include": [
"searx",
"searxng_extra",
"tests"
],
"typeCheckingMode": "off"
}

9
pyrightconfig.json Normal file
View File

@ -0,0 +1,9 @@
{
"venvPath": "local",
"venv": "py3",
"include": [
"searx",
"searxng_extra",
"tests"
]
}

View File

@ -117,7 +117,9 @@ nvm.install() {
info_msg "checkout ${NVM_VERSION_TAG}"
git checkout "${NVM_VERSION_TAG}" 2>&1 | prefix_stdout " ${_Yellow}||${_creset} "
popd &> /dev/null
cp "${REPO_ROOT}/.nvm_packages" "${NVM_DIR}/default-packages"
if [ -f "${REPO_ROOT}/.nvm_packages" ]; then
cp "${REPO_ROOT}/.nvm_packages" "${NVM_DIR}/default-packages"
fi
nvm.env
}