Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add runtime type checking in CI tests #9745

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/ci-additional.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,47 @@ jobs:
# `xarray/tests/__init__.py`.
python -m pytest --doctest-modules xarray --ignore xarray/tests -Werror

beartype:
name: beartype
runs-on: "ubuntu-latest"
needs: detect-ci-trigger
defaults:
run:
shell: bash -l {0}
env:
CONDA_ENV_FILE: ci/requirements/environment.yml
PYTHON_VERSION: "3.12"

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags.

- name: set environment variables
run: |
echo "TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Setup micromamba
uses: mamba-org/setup-micromamba@v2
with:
micromamba-version: ${{env.MICROMAMBA_VERSION}}
environment-file: ${{env.CONDA_ENV_FILE}}
environment-name: xarray-tests
create-args: >-
python=${{env.PYTHON_VERSION}}
cache-environment: true
cache-environment-key: "${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}"
- name: Install xarray
run: |
python -m pip install --no-deps -e .
- name: Version info
run: |
python xarray/util/print_versions.py

- name: Run beartype
continue-on-error: true
run: |
python -m pytest --beartype-packages=xarray

mypy:
name: Mypy
runs-on: "ubuntu-latest"
Expand Down
1 change: 1 addition & 0 deletions ci/requirements/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ dependencies:
- pydap
- pydap-server
- pytest
- pytest-beartype
- pytest-cov
- pytest-env
- pytest-xdist
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ dev = [
"mypy",
"pre-commit",
"pytest",
"pytest-beartype",
"pytest-cov",
"pytest-env",
"pytest-xdist",
Expand Down
4 changes: 2 additions & 2 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ def merge_data_and_coords(data_vars: DataVars, coords) -> _MergeResult:
)


class DataVariables(Mapping[Any, "DataArray"]):
class DataVariables(Mapping[Any, "xarray.DataArray"]):
__slots__ = ("_dataset",)

def __init__(self, dataset: Dataset):
Expand Down Expand Up @@ -523,7 +523,7 @@ class Dataset(
DataWithCoords,
DatasetAggregations,
DatasetArithmetic,
Mapping[Hashable, "DataArray"],
Mapping[Hashable, "xarray.DataArray"],
):
"""A multi-dimensional, in memory, array database.

Expand Down
Loading