From a8959e898ac2966b8bd4976ecb8b1c211b6596c7 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Mon, 23 Oct 2023 03:47:33 +0000 Subject: [PATCH 1/6] Add pyright ci annotations --- .github/workflows/build.yml | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5242dfc06f9..82f8ee825d3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -103,21 +103,26 @@ jobs: MAKE: make -j2 --output-sync=recurse SAGE_NUM_THREADS: 2 - - name: Set up node to install pyright + - name: Static code check with pyright if: always() && steps.worktree.outcome == 'success' - uses: actions/setup-node@v3 + uses: jakebailey/pyright-action@v1 with: - node-version: '12' - - - name: Install pyright + # Fix to v232 due to bug https://github.com/microsoft/pyright/issues/3239 + version: 1.1.232 + # Many warnings issued by pyright are not yet helpful because there is not yet enough type information. + no-comments: true + working-directory: ./worktree-image + + - name: Static code check with pyright (annotated) if: always() && steps.worktree.outcome == 'success' - # Fix to v232 due to bug https://github.com/microsoft/pyright/issues/3239 - run: npm install -g pyright@1.1.232 - - - name: Static code check with pyright - if: always() && steps.worktree.outcome == 'success' - run: pyright - working-directory: ./worktree-image + uses: jakebailey/pyright-action@v1 + with: + # Fix to v232 due to bug https://github.com/microsoft/pyright/issues/3239 + version: 1.1.232 + # Issue warnings for all annoted functions + no-comments: false + skip-unannotated: true + working-directory: ./worktree-image - name: Clean (fallback to non-incremental) id: clean From 5005cc62529163c422b3ac3f02107e7148c7f021 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Mon, 23 Oct 2023 04:18:48 +0000 Subject: [PATCH 2/6] Only annotate errors --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 82f8ee825d3..b5e630fd789 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -119,9 +119,9 @@ jobs: with: # Fix to v232 due to bug https://github.com/microsoft/pyright/issues/3239 version: 1.1.232 - # Issue warnings for all annoted functions + # Issue errors no-comments: false - skip-unannotated: true + level: error working-directory: ./worktree-image - name: Clean (fallback to non-incremental) From 7856e140138e86bd2210592b2220f53f565947fd Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Mon, 23 Oct 2023 05:41:11 +0000 Subject: [PATCH 3/6] update pyright --- .github/workflows/build.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b5e630fd789..9f258de05be 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -107,8 +107,7 @@ jobs: if: always() && steps.worktree.outcome == 'success' uses: jakebailey/pyright-action@v1 with: - # Fix to v232 due to bug https://github.com/microsoft/pyright/issues/3239 - version: 1.1.232 + version: 1.1.332 # Many warnings issued by pyright are not yet helpful because there is not yet enough type information. no-comments: true working-directory: ./worktree-image @@ -117,8 +116,7 @@ jobs: if: always() && steps.worktree.outcome == 'success' uses: jakebailey/pyright-action@v1 with: - # Fix to v232 due to bug https://github.com/microsoft/pyright/issues/3239 - version: 1.1.232 + version: 1.1.332 # Issue errors no-comments: false level: error From 226a35b2e919ccc39362f27fb65a874a716ec0af Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Mon, 23 Oct 2023 06:42:07 +0000 Subject: [PATCH 4/6] fix out of memory --- .github/workflows/build.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9f258de05be..7ac9c6154d0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -111,6 +111,9 @@ jobs: # Many warnings issued by pyright are not yet helpful because there is not yet enough type information. no-comments: true working-directory: ./worktree-image + env: + # To avoid out of memory errors + NODE_OPTIONS: --max-old-space-size=8192 - name: Static code check with pyright (annotated) if: always() && steps.worktree.outcome == 'success' @@ -121,6 +124,9 @@ jobs: no-comments: false level: error working-directory: ./worktree-image + env: + # To avoid out of memory errors + NODE_OPTIONS: --max-old-space-size=8192 - name: Clean (fallback to non-incremental) id: clean From 6f010eaed64a174426e6566f6912493b08e2ac59 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Mon, 23 Oct 2023 07:27:40 +0000 Subject: [PATCH 5/6] Remove private import --- src/sage/functions/other.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/functions/other.py b/src/sage/functions/other.py index 249eb2ea56f..eed84964be3 100644 --- a/src/sage/functions/other.py +++ b/src/sage/functions/other.py @@ -2209,7 +2209,7 @@ def _evalf_(self, poly, index, parent=None, algorithm=None): sage: complex_root_of(x^8 - 1, 7).n(20) # needs sage.symbolic 0.70711 + 0.70711*I """ - from sympy.core.evalf import prec_to_dps + from mpmath.libmp import prec_to_dps from sympy.polys import CRootOf, Poly try: prec = parent.precision() From 01eed9839b507a56f5f1b171b288c5e134c8b0b4 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Mon, 23 Oct 2023 07:34:57 +0000 Subject: [PATCH 6/6] Add manual workaround for out of memory --- src/doc/en/developer/tools.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/doc/en/developer/tools.rst b/src/doc/en/developer/tools.rst index 20878a6175d..fca5d5ef4c1 100644 --- a/src/doc/en/developer/tools.rst +++ b/src/doc/en/developer/tools.rst @@ -327,7 +327,10 @@ Pyright - Tox: Run ``./sage -tox -e pyright path/to/the/file.py`` -- Manual: Run ``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:: + + NODE_OPTIONS="--max-old-space-size=8192" pyright - VS Code: Install the `Pylance `__ extension.