Skip to content

Commit 863a26e

Browse files
author
Release Manager
committed
sagemathgh-36510: Add pyright ci annotations <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes sagemath#1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes sagemath#12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> We use the [pyright-action](https://github.com/jakebailey/pyright- action) to install and run pyright in the ci. This action is also used by https://github.com/python/typeshed (among others) and has the advantage that we can easily add annotations to surface typing errors. Due to the limited typing info currently in the sage repo, we only add these annotations for errors and not warnings. ![image](https://github.com/sagemath/sage/assets/5037600/12ed6be1-68d5- 496d-b77b-0eff750ef530) Also fix one import that was complained about by the new pyright version. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - sagemath#12345: short description why this is a dependency - sagemath#34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: sagemath#36510 Reported by: Tobias Diez Reviewer(s): Matthias Köppe
2 parents 48279f9 + 01eed98 commit 863a26e

File tree

3 files changed

+26
-14
lines changed

3 files changed

+26
-14
lines changed

.github/workflows/build.yml

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,30 @@ jobs:
103103
MAKE: make -j2 --output-sync=recurse
104104
SAGE_NUM_THREADS: 2
105105

106-
- name: Set up node to install pyright
106+
- name: Static code check with pyright
107107
if: always() && steps.worktree.outcome == 'success'
108-
uses: actions/setup-node@v3
108+
uses: jakebailey/pyright-action@v1
109109
with:
110-
node-version: '12'
111-
112-
- name: Install pyright
113-
if: always() && steps.worktree.outcome == 'success'
114-
# Fix to v232 due to bug https://github.com/microsoft/pyright/issues/3239
115-
run: npm install -g pyright@1.1.232
116-
117-
- name: Static code check with pyright
110+
version: 1.1.332
111+
# Many warnings issued by pyright are not yet helpful because there is not yet enough type information.
112+
no-comments: true
113+
working-directory: ./worktree-image
114+
env:
115+
# To avoid out of memory errors
116+
NODE_OPTIONS: --max-old-space-size=8192
117+
118+
- name: Static code check with pyright (annotated)
118119
if: always() && steps.worktree.outcome == 'success'
119-
run: pyright
120-
working-directory: ./worktree-image
120+
uses: jakebailey/pyright-action@v1
121+
with:
122+
version: 1.1.332
123+
# Issue errors
124+
no-comments: false
125+
level: error
126+
working-directory: ./worktree-image
127+
env:
128+
# To avoid out of memory errors
129+
NODE_OPTIONS: --max-old-space-size=8192
121130

122131
- name: Clean (fallback to non-incremental)
123132
id: clean

src/doc/en/developer/tools.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,10 @@ Pyright
327327

328328
- Tox: Run ``./sage -tox -e pyright path/to/the/file.py``
329329

330-
- Manual: Run ``pyright path/to/the/file.py``
330+
- 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.
331+
You can use the following command to check the whole library::
332+
333+
NODE_OPTIONS="--max-old-space-size=8192" pyright
331334

332335
- VS Code: Install the `Pylance <https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance>`__ extension.
333336

src/sage/functions/other.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2209,7 +2209,7 @@ def _evalf_(self, poly, index, parent=None, algorithm=None):
22092209
sage: complex_root_of(x^8 - 1, 7).n(20) # needs sage.symbolic
22102210
0.70711 + 0.70711*I
22112211
"""
2212-
from sympy.core.evalf import prec_to_dps
2212+
from mpmath.libmp import prec_to_dps
22132213
from sympy.polys import CRootOf, Poly
22142214
try:
22152215
prec = parent.precision()

0 commit comments

Comments
 (0)