Skip to content

mypy failure for Variable + Dataset arithmetic in test_typed_ops.py with Python 3.12 only #9656

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

Closed
shoyer opened this issue Oct 21, 2024 · 0 comments · Fixed by #9688
Closed

Comments

@shoyer
Copy link
Member

shoyer commented Oct 21, 2024

What is your issue?

I get the following error when I run mypy in a Python 3.12 environment:

$ python -m mypy --install-types --non-interactive
xarray/tests/test_typed_ops.py: note: In function "test_dataset_typed_ops":
xarray/tests/test_typed_ops.py:139: error: Argument 1 to "_test" has incompatible type "Variable"; expected "Dataset"  [arg-type]
xarray/tests/test_typed_ops.py:140: error: Argument 1 to "_test" has incompatible type "DataArray"; expected "Dataset"  [arg-type]
xarray/tests/test_typed_ops.py:151: error: Argument 1 to "_test" has incompatible type "Variable"; expected "Dataset"  [arg-type]
xarray/tests/test_typed_ops.py:152: error: Argument 1 to "_test" has incompatible type "DataArray"; expected "Dataset"  [arg-type]
xarray/tests/test_typed_ops.py:163: error: Argument 1 to "_test" has incompatible type "Variable"; expected "Dataset"  [arg-type]
xarray/tests/test_typed_ops.py:164: error: Argument 1 to "_test" has incompatible type "DataArray"; expected "Dataset"  [arg-type]
Found 6 errors in 1 file (checked 167 source files)

When I run this using an identical Python 3.11 setup, mypy passes without any errors.

The offending lines are doing arithmetic operations like Variable + Dataset or DataArray + Dataset.

Enviroment details:

Python 3.12

commit: df87f69
python: 3.12.7 | packaged by conda-forge | (main, Oct 4 2024, 15:57:01) [Clang 17.0.6 ]
python-bits: 64
OS: Darwin
OS-release: 23.6.0
machine: arm64
processor: arm
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: 1.14.3
libnetcdf: 4.9.2

xarray: 2024.9.1.dev81+g994550f0
pandas: 2.2.3
numpy: 2.0.2
scipy: 1.14.1
netCDF4: 1.7.1
pydap: 3.5
h5netcdf: 1.4.0
h5py: 3.12.1
zarr: 2.18.3
cftime: 1.6.4
nc_time_axis: 1.4.1
iris: 3.9.0
bottleneck: 1.4.2
dask: 2024.10.0
distributed: 2024.10.0
matplotlib: 3.9.2
cartopy: 0.24.0
seaborn: 0.13.2
numbagg: 0.8.2
fsspec: 2024.9.0
cupy: None
pint: None
sparse: 0.15.4
flox: 0.9.12
numpy_groupies: 0.11.2
setuptools: 75.1.0
pip: 24.2
conda: None
pytest: 8.3.3
mypy: 1.11.2
IPython: None
sphinx: None

Python 3.11

commit: df87f69
python: 3.11.10 | packaged by conda-forge | (main, Oct 16 2024, 01:26:25) [Clang 17.0.6 ]
python-bits: 64
OS: Darwin
OS-release: 23.6.0
machine: arm64
processor: arm
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: 1.14.3
libnetcdf: 4.9.2

xarray: 2024.9.1.dev77+gdf87f692
pandas: 2.2.3
numpy: 2.0.2
scipy: 1.14.1
netCDF4: 1.7.1
pydap: 3.5
h5netcdf: 1.4.0
h5py: 3.12.1
zarr: 2.18.3
cftime: 1.6.4
nc_time_axis: 1.4.1
iris: 3.9.0
bottleneck: 1.4.2
dask: 2024.10.0
distributed: 2024.10.0
matplotlib: 3.9.2
cartopy: 0.24.0
seaborn: 0.13.2
numbagg: 0.8.2
fsspec: 2024.9.0
cupy: None
pint: None
sparse: 0.15.4
flox: 0.9.12
numpy_groupies: 0.11.2
setuptools: 75.1.0
pip: 24.2
conda: None
pytest: 8.3.3
mypy: 1.11.2
IPython: None
sphinx: None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant