diff options
| author | Markus Heiser <markus.heiser@darmarit.de> | 2025-07-31 13:45:16 +0200 |
|---|---|---|
| committer | Markus Heiser <markus.heiser@darmarIT.de> | 2025-08-19 12:04:35 +0200 |
| commit | 25647c20d1904840d089892bb118390f46c66984 (patch) | |
| tree | a2db511a7444ea0504dbe83d484a556003d57e9b /utils/lib_sxng_test.sh | |
| parent | 9bb04e288ddda7d91fd6e2d87adc3bdaf01bd7c8 (diff) | |
[mod] switching from pyright to basedpyright (plus first rules)
pyrightconfig.json :
for the paths searx, searxng_extra and tests, individual rules were
defined (for example, in test fewer / different rules are needed than in the
searx package
searx/engines/__builtins__.pyi :
The builtin types that are added to the global namespace of a module by the
intended monkey patching of the engine modules / replaces the previous
filtering of the stdout using grep.
test.pyright_modified (utils/lib_sxng_test.sh) :
static type check of local modified files not yet commited
make test :
prerequisite 'test.pyright' has been replaced by 'test.pyright_modified'
searx/engines/__init__.py, searx/enginelib/__init__.py :
First, minimal typifications that were considered necessary.
Diffstat (limited to 'utils/lib_sxng_test.sh')
| -rwxr-xr-x | utils/lib_sxng_test.sh | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/utils/lib_sxng_test.sh b/utils/lib_sxng_test.sh index 0248c3125..22a655722 100755 --- a/utils/lib_sxng_test.sh +++ b/utils/lib_sxng_test.sh @@ -51,25 +51,32 @@ test.pylint() { } test.pyright() { - # use this pyright test for local tests in development / it suppress - # warnings related to intentional monkey patching but gives good hints where - # we need to work on SearXNG's typification. - - build_msg TEST "[pyright/types] static type check of python sources" - node.env.dev - - build_msg TEST "[pyright/types] suppress warnings related to intentional monkey patching" - # We run Pyright in the virtual environment because pyright executes - # "python" to determine the Python version. - pyenv.cmd npx --no-install pyright -p pyrightconfig.json | - grep -E '\.py:[0-9]+:[0-9]+' | - grep -v '/engines/.*.py.* - warning: "logger" is not defined' | - grep -v '/plugins/.*.py.* - error: "logger" is not defined' | - grep -v '/engines/.*.py.* - warning: "supported_languages" is not defined' | - grep -v '/engines/.*.py.* - warning: "language_aliases" is not defined' | - grep -v '/engines/.*.py.* - warning: "categories" is not defined' - # ignore exit value from pyright - # dump_return ${PIPESTATUS[0]} + # For integration into your IDE (editor) use the basedpyright-langserver + # (LSP) installed by 'pipx basedpyright' and read: + # + # - https://docs.basedpyright.com/latest/installation/ides/ + # + # The $REPO_ROOT/pyrightconfig.json uses the virtualenv found in + # $REPO_ROOT/local/py3 and create by a 'make pyenv' + + build_msg TEST "[basedpyright] static type check of python sources" + LANG=C pyenv.cmd basedpyright + # ignore exit value from basedpyright + # dump_return $? + return 0 +} + +test.pyright_modified() { + build_msg TEST "[basedpyright] static type check of local modified files" + local pyrigth_files=() + readarray -t pyrigth_files < <(git status --porcelain | awk 'match($2,".py[i]*$") {print $2}') + if [ ${#pyrigth_files[@]} -eq 0 ]; then + echo "there are no locally modified python files that could be checked" + else + pyenv.cmd basedpyright "${pyrigth_files[@]}" + fi + # ignore exit value from basedpyright + # dump_return $? return 0 } |