diff --git a/.github/workflows/ci-additional.yaml b/.github/workflows/ci-additional.yaml index 32ab03de850..c5f6a06e349 100644 --- a/.github/workflows/ci-additional.yaml +++ b/.github/workflows/ci-additional.yaml @@ -157,6 +157,50 @@ jobs: run: | python -m pytest --doctest-modules xarray --ignore xarray/tests + typing: + name: Type checking (mypy) + runs-on: "ubuntu-latest" + needs: detect-ci-trigger + if: false && needs.detect-ci-trigger.outputs.triggered == 'false' + defaults: + run: + shell: bash -l {0} + + steps: + - name: Cancel previous runs + uses: styfle/cancel-workflow-action@0.6.0 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Fetch all history for all branches and tags. + - uses: conda-incubator/setup-miniconda@v2 + with: + channels: conda-forge + channel-priority: strict + mamba-version: "*" + activate-environment: xarray-tests + auto-update-conda: false + python-version: "3.8" + + - name: Install conda dependencies + run: | + mamba env update -f ci/requirements/environment.yml + - name: Install mypy + run: | + mamba install --file ci/requirements/mypy_only + - name: Install xarray + run: | + python -m pip install --no-deps -e . + - name: Version info + run: | + conda info -a + conda list + python xarray/util/print_versions.py + - name: Run mypy + run: | + python -m mypy xarray + min-version-policy: name: Minimum Version Policy runs-on: "ubuntu-latest" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e90164575b4..7e967f57e55 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,6 +30,7 @@ repos: # - id: velin # args: ["--write", "--compact"] - repo: https://github.com/pre-commit/mirrors-mypy + # version must correspond to the one in .github/workflows/ci-additional.yaml rev: v0.812 hooks: - id: mypy diff --git a/ci/requirements/mypy_only b/ci/requirements/mypy_only new file mode 100644 index 00000000000..57fe071ee54 --- /dev/null +++ b/ci/requirements/mypy_only @@ -0,0 +1,3 @@ +# used for the "Type checking (mypy)" CI run +# version must correspond to the one in .pre-commit-config.yaml +mypy=0.812