id,node_id,number,title,user,state,locked,assignee,milestone,comments,created_at,updated_at,closed_at,author_association,active_lock_reason,draft,pull_request,body,reactions,performed_via_github_app,state_reason,repo,type 617140674,MDU6SXNzdWU2MTcxNDA2NzQ=,4054,Type checking fails for multiplication,37403847,closed,0,,,6,2020-05-13T04:55:14Z,2021-04-14T15:59:59Z,2021-04-14T15:59:59Z,CONTRIBUTOR,,,," #### MCVE Code Sample I save the following in a file called ""foo.py"" ```python import xarray as xr def mul(x: float, y: xr.Dataset): return x*y ``` and run ``` mypy foo.py ``` #### Expected Output This should give ``` Success: no issues found in 1 source file ``` #### Problem Description Instead I get the output ``` foo.py:4: error: Unsupported operand types for * (""float"" and ""Dataset"") ``` It gives a similar error for addition. If I reverse the order of multiplication it works as expected, namely ```python import xarray as xr def mul(x: float, y: xr.Dataset): return y*x ``` gives ``` Success: no issues found in 1 source file ``` But it would be nice if it also worked when the float is first, so I don't have to change a lot existing code to get typechecking to work. #### Versions I tested on version 0.15.1 and on the current master
Output of xr.show_versions() INSTALLED VERSIONS ------------------ commit: None python: 3.8.2 (default, May 7 2020, 20:00:49) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 5.4.0-29-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 libhdf5: None libnetcdf: None xarray: 0.15.2.dev61+gbd84186a pandas: 1.0.3 numpy: 1.18.4 scipy: None netCDF4: None pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: None nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: None distributed: None matplotlib: None cartopy: None seaborn: None numbagg: None pint: None setuptools: 46.2.0.post20200511 pip: 20.0.2 conda: None pytest: None IPython: None sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4054/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue