html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue https://github.com/pydata/xarray/pull/4144#issuecomment-644231473,https://api.github.com/repos/pydata/xarray/issues/4144,644231473,MDEyOklzc3VlQ29tbWVudDY0NDIzMTQ3Mw==,1386642,2020-06-15T16:15:58Z,2020-06-15T16:32:24Z,CONTRIBUTOR,"@crusaderky Thanks for the re-work. For my own benefit, could you explain why that code worked? I remember writing something very similar, and running into mypy errors. My understanding of how mypy intreprets overload seems incomplete.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,636611699 https://github.com/pydata/xarray/pull/4144#issuecomment-643506298,https://api.github.com/repos/pydata/xarray/issues/4144,643506298,MDEyOklzc3VlQ29tbWVudDY0MzUwNjI5OA==,1386642,2020-06-12T22:23:56Z,2020-06-12T22:23:56Z,CONTRIBUTOR,No problem! I think I am done with this one unless you think its important that I document or test this somehow. Can someone review it?,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,636611699 https://github.com/pydata/xarray/pull/4144#issuecomment-643079280,https://api.github.com/repos/pydata/xarray/issues/4144,643079280,MDEyOklzc3VlQ29tbWVudDY0MzA3OTI4MA==,1386642,2020-06-12T05:49:56Z,2020-06-12T05:49:56Z,CONTRIBUTOR,"Okay. Assuming the tests pass, I think this is ready for review. I tried adding a test, but mypy didn't seem to find problems even with code that I *know* doesn't work (e.g. `'a'+ 1`). Is there some strategy for testing tricky type hints like this? In any case, this code does work: ``` $ cat test_mypy.py (fv3net) import xarray as xr ds = xr.Dataset({""a"": ()}) arr = ds['a'] union_obj = ds[['a']] reveal_locals() $ mypy test_mypy.py (fv3net) test_mypy.py:8: note: Revealed local types are: test_mypy.py:8: note: arr: xarray.core.dataarray.DataArray test_mypy.py:8: note: ds: xarray.core.dataset.Dataset test_mypy.py:8: note: union_obj: Union[xarray.core.dataarray.DataArray, xarray.core.dataset.Dataset] ```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,636611699 https://github.com/pydata/xarray/pull/4144#issuecomment-643014353,https://api.github.com/repos/pydata/xarray/issues/4144,643014353,MDEyOklzc3VlQ29tbWVudDY0MzAxNDM1Mw==,1386642,2020-06-12T01:27:55Z,2020-06-12T01:33:41Z,CONTRIBUTOR,"@mathause On further consideration, I think it might not be possible to get this to work. This method has three behaviors: - Mapping -> Dataset - Hashable -> DataArray - else (List): -> Dataset With my limited understanding of `mypy`, I think that any two of these is supported by `overload`, but I'm not sure it's possible to support all 3. I tried several different options, but maybe I am missing something. Would a good middle ground be something like this? - Hashable -> DataArray - Any -> Union[DataArray, Dataset] I *think* this would work since both the input/outputs of the first one are subtypes of the second one. It's not a complete solution, but it would solve the most common problem of `ds['a']` returning a union type rather than a DataArray.","{""total_count"": 2, ""+1"": 2, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,636611699