Skip to content

Commit 200c2b2

Browse files
mathausekeewis
andauthored
CI: run mypy in full env (#4929)
* CI: run mypy in full env * mypy: show_error_codes * [skip-ci] add skip ci option & version comment * Apply suggestions from code review Co-authored-by: keewis <[email protected]> * Update .github/workflows/ci-additional.yaml * Update .github/workflows/ci-additional.yaml Co-authored-by: keewis <[email protected]> * update mypy version * Update .pre-commit-config.yaml * [skip-ci] install mypy from file Co-authored-by: keewis <[email protected]>
1 parent 88c5fd2 commit 200c2b2

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

.github/workflows/ci-additional.yaml

+44
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,50 @@ jobs:
157157
run: |
158158
python -m pytest --doctest-modules xarray --ignore xarray/tests
159159
160+
typing:
161+
name: Type checking (mypy)
162+
runs-on: "ubuntu-latest"
163+
needs: detect-ci-trigger
164+
if: false && needs.detect-ci-trigger.outputs.triggered == 'false'
165+
defaults:
166+
run:
167+
shell: bash -l {0}
168+
169+
steps:
170+
- name: Cancel previous runs
171+
uses: styfle/[email protected]
172+
with:
173+
access_token: ${{ github.token }}
174+
- uses: actions/checkout@v2
175+
with:
176+
fetch-depth: 0 # Fetch all history for all branches and tags.
177+
- uses: conda-incubator/setup-miniconda@v2
178+
with:
179+
channels: conda-forge
180+
channel-priority: strict
181+
mamba-version: "*"
182+
activate-environment: xarray-tests
183+
auto-update-conda: false
184+
python-version: "3.8"
185+
186+
- name: Install conda dependencies
187+
run: |
188+
mamba env update -f ci/requirements/environment.yml
189+
- name: Install mypy
190+
run: |
191+
mamba install --file ci/requirements/mypy_only
192+
- name: Install xarray
193+
run: |
194+
python -m pip install --no-deps -e .
195+
- name: Version info
196+
run: |
197+
conda info -a
198+
conda list
199+
python xarray/util/print_versions.py
200+
- name: Run mypy
201+
run: |
202+
python -m mypy xarray
203+
160204
min-version-policy:
161205
name: Minimum Version Policy
162206
runs-on: "ubuntu-latest"

.pre-commit-config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ repos:
3030
# - id: velin
3131
# args: ["--write", "--compact"]
3232
- repo: https://github.com/pre-commit/mirrors-mypy
33+
# version must correspond to the one in .github/workflows/ci-additional.yaml
3334
rev: v0.812
3435
hooks:
3536
- id: mypy

ci/requirements/mypy_only

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# used for the "Type checking (mypy)" CI run
2+
# version must correspond to the one in .pre-commit-config.yaml
3+
mypy=0.812

0 commit comments

Comments
 (0)