Skip to content

Commit ab3dd59

Browse files
authored
Add pyright type checker (#8279)
* Add pyright type checker * Update ci-additional.yaml * Update ci-additional.yaml
1 parent 7aa207b commit ab3dd59

File tree

2 files changed

+145
-0
lines changed

2 files changed

+145
-0
lines changed

.github/workflows/ci-additional.yaml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,126 @@ jobs:
188188

189189

190190

191+
pyright:
192+
name: Pyright
193+
runs-on: "ubuntu-latest"
194+
needs: detect-ci-trigger
195+
if: |
196+
always()
197+
&& (
198+
contains( github.event.pull_request.labels.*.name, 'run-pyright')
199+
)
200+
defaults:
201+
run:
202+
shell: bash -l {0}
203+
env:
204+
CONDA_ENV_FILE: ci/requirements/environment.yml
205+
PYTHON_VERSION: "3.10"
206+
207+
steps:
208+
- uses: actions/checkout@v4
209+
with:
210+
fetch-depth: 0 # Fetch all history for all branches and tags.
211+
212+
- name: set environment variables
213+
run: |
214+
echo "TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
215+
- name: Setup micromamba
216+
uses: mamba-org/setup-micromamba@v1
217+
with:
218+
environment-file: ${{env.CONDA_ENV_FILE}}
219+
environment-name: xarray-tests
220+
create-args: >-
221+
python=${{env.PYTHON_VERSION}}
222+
conda
223+
cache-environment: true
224+
cache-environment-key: "${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}"
225+
- name: Install xarray
226+
run: |
227+
python -m pip install --no-deps -e .
228+
- name: Version info
229+
run: |
230+
conda info -a
231+
conda list
232+
python xarray/util/print_versions.py
233+
- name: Install pyright
234+
run: |
235+
python -m pip install pyright --force-reinstall
236+
237+
- name: Run pyright
238+
run: |
239+
python -m pyright xarray/
240+
241+
- name: Upload pyright coverage to Codecov
242+
uses: codecov/codecov-action@v3.1.4
243+
with:
244+
file: pyright_report/cobertura.xml
245+
flags: pyright
246+
env_vars: PYTHON_VERSION
247+
name: codecov-umbrella
248+
fail_ci_if_error: false
249+
250+
pyright39:
251+
name: Pyright 3.9
252+
runs-on: "ubuntu-latest"
253+
needs: detect-ci-trigger
254+
if: |
255+
always()
256+
&& (
257+
contains( github.event.pull_request.labels.*.name, 'run-pyright')
258+
)
259+
defaults:
260+
run:
261+
shell: bash -l {0}
262+
env:
263+
CONDA_ENV_FILE: ci/requirements/environment.yml
264+
PYTHON_VERSION: "3.9"
265+
266+
steps:
267+
- uses: actions/checkout@v4
268+
with:
269+
fetch-depth: 0 # Fetch all history for all branches and tags.
270+
271+
- name: set environment variables
272+
run: |
273+
echo "TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
274+
- name: Setup micromamba
275+
uses: mamba-org/setup-micromamba@v1
276+
with:
277+
environment-file: ${{env.CONDA_ENV_FILE}}
278+
environment-name: xarray-tests
279+
create-args: >-
280+
python=${{env.PYTHON_VERSION}}
281+
conda
282+
cache-environment: true
283+
cache-environment-key: "${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}"
284+
- name: Install xarray
285+
run: |
286+
python -m pip install --no-deps -e .
287+
- name: Version info
288+
run: |
289+
conda info -a
290+
conda list
291+
python xarray/util/print_versions.py
292+
- name: Install pyright
293+
run: |
294+
python -m pip install pyright --force-reinstall
295+
296+
- name: Run pyright
297+
run: |
298+
python -m pyright xarray/
299+
300+
- name: Upload pyright coverage to Codecov
301+
uses: codecov/codecov-action@v3.1.4
302+
with:
303+
file: pyright_report/cobertura.xml
304+
flags: pyright39
305+
env_vars: PYTHON_VERSION
306+
name: codecov-umbrella
307+
fail_ci_if_error: false
308+
309+
310+
191311
min-version-policy:
192312
name: Minimum Version Policy
193313
runs-on: "ubuntu-latest"

pyproject.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,31 @@ warn_return_any = true
198198

199199
module = ["xarray.namedarray.*", "xarray.tests.test_namedarray"]
200200

201+
[tool.pyright]
202+
# include = ["src"]
203+
# exclude = ["**/node_modules",
204+
# "**/__pycache__",
205+
# "src/experimental",
206+
# "src/typestubs"
207+
# ]
208+
# ignore = ["src/oldstuff"]
209+
defineConstant = { DEBUG = true }
210+
# stubPath = "src/stubs"
211+
# venv = "env367"
212+
213+
reportMissingImports = true
214+
reportMissingTypeStubs = false
215+
216+
# pythonVersion = "3.6"
217+
# pythonPlatform = "Linux"
218+
219+
# executionEnvironments = [
220+
# { root = "src/web", pythonVersion = "3.5", pythonPlatform = "Windows", extraPaths = [ "src/service_libs" ] },
221+
# { root = "src/sdk", pythonVersion = "3.0", extraPaths = [ "src/backend" ] },
222+
# { root = "src/tests", extraPaths = ["src/tests/e2e", "src/sdk" ]},
223+
# { root = "src" }
224+
# ]
225+
201226
[tool.ruff]
202227
builtins = ["ellipsis"]
203228
exclude = [

0 commit comments

Comments
 (0)