diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c9282086422..fbe8f312676 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -104,6 +104,12 @@ jobs: MAKE: make -j2 --output-sync=recurse SAGE_NUM_THREADS: 2 + - name: Add venv to PATH for pyright + if: always() && steps.worktree.outcome == 'success' + # https://github.com/jakebailey/pyright-action#use-with-a-virtualenv + run: echo "$PWD/venv/bin" >> $GITHUB_PATH + working-directory: ./worktree-image + - name: Static code check with pyright if: (success() || failure()) && steps.worktree.outcome == 'success' uses: jakebailey/pyright-action@v1 diff --git a/pyrightconfig.json b/pyrightconfig.json index 643c56360c9..20b46f40fea 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -2,15 +2,9 @@ "include": [ "src/sage" ], - "executionEnvironments": [ - { - "root": "src" - } - ], + "stubPath": "src/typings", "pythonVersion": "3.9", "exclude": ["venv"], - "venvPath": "./venv/", - "venv": "./", "reportGeneralTypeIssues": "warning", "reportUnboundVariable": "warning", @@ -22,4 +16,6 @@ "reportUndefinedVariable": "warning", "reportOptionalOperand": "warning", "reportMissingImports": "warning", + // Suppress because it flags our standard pattern @staticmethod __classcall__(cls, ...) + "reportSelfClsParameterName": "none", } diff --git a/src/doc/en/developer/tools.rst b/src/doc/en/developer/tools.rst index 02be3f91b4b..828ec467547 100644 --- a/src/doc/en/developer/tools.rst +++ b/src/doc/en/developer/tools.rst @@ -46,10 +46,10 @@ available:: ... Testing files: ... - --tox [options] -- general entry point for testing - and linting of the Sage library - -e -- run specific test environments; default: - doctest,coverage,startuptime,pycodestyle-minimal,relint,codespell,rst + --tox [options] -- -- general entry point for testing + and linting of the Sage library + -e -- run specific test environments + (default: run all except full pycodestyle) doctest -- run the Sage doctester (same as "sage -t") coverage -- give information about doctest coverage of files @@ -383,7 +383,7 @@ Pyright *Usage:* -- Tox: Run ``./sage -tox -e pyright path/to/the/file.py`` +- Tox: Run ``./sage -tox -e pyright -- path/to/the/file.py`` - Manual: Run ``pyright path/to/the/file.py``. If you want to check the whole Sage library, you most likely run out of memory with the default settings. You can use the following command to check the whole library:: diff --git a/src/tox.ini b/src/tox.ini index 00f7a153f35..01c6e512ca7 100644 --- a/src/tox.ini +++ b/src/tox.ini @@ -113,21 +113,22 @@ commands = [testenv:pyright] description = run the static typing checker pyright -deps = pyright +skip_install = True +deps = + pyright + -e {toxinidir}/../pkgs/sage-conf + -r {toxinidir}/requirements.txt setenv = - {[sagedirect]setenv} - HOME={envdir} - # Fix version, see .github/workflows/build.yml - PYRIGHT_PYTHON_FORCE_VERSION=1.1.232 -allowlist_externals = {[sagedirect]allowlist_externals} -## We run pyright from within the sage-env so that SAGE_LOCAL is available. -## pyright is already configured via SAGE_ROOT/pyrightconfig.json to use our venv. -## -## Running pyright on the whole Sage source tree takes very long -## and may run out of memory. When no files/directories are given, just run it -## on the packages that already have typing annotations. + PYRIGHT_PYTHON_FORCE_VERSION=1.1.332 + PYRIGHT_PYTHON_GLOBAL_NODE=false + ## Otherwise running pyright on the whole Sage source tree (= default) + ## will take very long and may run out of memory. + NODE_OPTIONS=--max-old-space-size=8192 + ## We make the built wheels available + PIP_FIND_LINKS=file://{env:SAGE_SPKG_WHEELS:{env:SAGE_VENV:{toxinidir}/../venv}/var/lib/sage/wheels} + commands = - {env:SAGE} -sh -c 'pyright {posargs:{toxinidir}/sage/combinat {toxinidir}/sage/manifolds}' + pyright {posargs:} [testenv:pycodestyle] description =