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-644639292,https://api.github.com/repos/pydata/xarray/issues/4144,644639292,MDEyOklzc3VlQ29tbWVudDY0NDYzOTI5Mg==,6213168,2020-06-16T09:10:07Z,2020-06-16T09:10:07Z,MEMBER,@nbren12 it seems to me that mypy is being overly aggressive when parsing the hinted code (hence why I had to put ``# type: ignore`` on it) but it is being more lax when the same code is invoked somewhere else like in my test script. Overall I suspect it may be fragile and break in future mypy versions...,"{""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-643655275,https://api.github.com/repos/pydata/xarray/issues/4144,643655275,MDEyOklzc3VlQ29tbWVudDY0MzY1NTI3NQ==,6213168,2020-06-13T17:44:43Z,2020-06-13T17:44:43Z,MEMBER,"I took the liberty to rework it, please have a look Test script: ```python from typing import Hashable, Mapping import xarray ds: xarray.Dataset class D(Hashable, Mapping): def __hash__(self): ... def __getitem__(self, item): ... def __iter__(self): ... def __len__(self): ... reveal_type(ds[""foo""]) reveal_type(ds[[""foo"", ""bar""]]) reveal_type(ds[{}]) reveal_type(ds[D()]) ``` mypy output: ``` t1.py:12: note: Revealed type is 'xarray.core.dataarray.DataArray' t1.py:13: note: Revealed type is 'xarray.core.dataset.Dataset' t1.py:14: note: Revealed type is 'xarray.core.dataset.Dataset' t1.py:15: note: Revealed type is '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-643303946,https://api.github.com/repos/pydata/xarray/issues/4144,643303946,MDEyOklzc3VlQ29tbWVudDY0MzMwMzk0Ng==,5635139,2020-06-12T14:34:01Z,2020-06-12T14:34:01Z,MEMBER,"Nice find @mathause ; I remember that discussion now. As @nbren12 said, this doesn't go all the way given mypy's restrictions, but seems like a dominant improvement. Test failures are unrelated. Thanks @nbren12 !","{""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-643242850,https://api.github.com/repos/pydata/xarray/issues/4144,643242850,MDEyOklzc3VlQ29tbWVudDY0MzI0Mjg1MA==,10194086,2020-06-12T12:24:20Z,2020-06-12T12:24:20Z,MEMBER,"Seems this was already discussed in [GH3210 (comment)](https://github.com/pydata/xarray/pull/3210/files/3cfd9a0c8c09de28e71abf8c861a8599c93bfd29#r317969251) and see also the TODO: https://github.com/pydata/xarray/blob/8f688ea92ae8416ecc3e18f6e060dad16960e9ac/xarray/core/dataset.py#L1244-L1250 (although it is not entirely clear to me whether this is actually fixed or not)","{""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-642554509,https://api.github.com/repos/pydata/xarray/issues/4144,642554509,MDEyOklzc3VlQ29tbWVudDY0MjU1NDUwOQ==,10194086,2020-06-11T10:20:33Z,2020-06-11T10:20:33Z,MEMBER,"The mypy check throws an error: `xarray/core/dataset.py:1250: error: Overloaded function signature 2 will never be matched: signature 1's parameter type(s) are the same` I think you can ignore the other failures. Should that be: ```python @overload def __getitem__(self, key: Hashable) -> DataArray: ... @overload def __getitem__(self, key: Iterable[Hashable]) -> ""Dataset"": ... ``` ? Only guessing, though - it was `Any` so there may be more options. @crusaderky ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,636611699