diff --git a/.github/workflows/ci-additional.yaml b/.github/workflows/ci-additional.yaml index 9ef315f505c..fa29ec844af 100644 --- a/.github/workflows/ci-additional.yaml +++ b/.github/workflows/ci-additional.yaml @@ -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" diff --git a/ci/requirements/environment.yml b/ci/requirements/environment.yml index c630bce2ac8..161529d0569 100644 --- a/ci/requirements/environment.yml +++ b/ci/requirements/environment.yml @@ -38,6 +38,7 @@ dependencies: - pydap - pydap-server - pytest + - pytest-beartype - pytest-cov - pytest-env - pytest-xdist diff --git a/pyproject.toml b/pyproject.toml index 55c8d92bfdb..1166b3b0998 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,6 +41,7 @@ dev = [ "mypy", "pre-commit", "pytest", + "pytest-beartype", "pytest-cov", "pytest-env", "pytest-xdist", diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index a09a857e331..3f809087f82 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -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): @@ -523,7 +523,7 @@ class Dataset( DataWithCoords, DatasetAggregations, DatasetArithmetic, - Mapping[Hashable, "DataArray"], + Mapping[Hashable, "xarray.DataArray"], ): """A multi-dimensional, in memory, array database.