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/4818#issuecomment-767565592,https://api.github.com/repos/pydata/xarray/issues/4818,767565592,MDEyOklzc3VlQ29tbWVudDc2NzU2NTU5Mg==,10194086,2021-01-26T14:10:01Z,2021-01-26T14:10:01Z,MEMBER,"Finally figured it out - I had to use
```python
T_DataWithCoords = TypeVar(""T_DataWithCoords"", bound=""DataWithCoords"")
```
`DataWithCoords` is a parent class of `Dastaset` and `DataArray`. Now the following works:
```python
import xarray as xr
da = xr.DataArray([1])
ds = xr.Dataset(data_vars={""x"": da})
reveal_type(da.weighted(da).mean()) # Revealed type is 'xarray.core.dataarray.DataArray*'
reveal_type(ds.weighted(da).mean()) # Revealed type is 'xarray.core.dataarray.Dataset*'
```","{""total_count"": 1, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 1, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,787502146
https://github.com/pydata/xarray/pull/4818#issuecomment-765031152,https://api.github.com/repos/pydata/xarray/issues/4818,765031152,MDEyOklzc3VlQ29tbWVudDc2NTAzMTE1Mg==,10194086,2021-01-22T00:33:39Z,2021-01-22T00:33:39Z,MEMBER,"The following now works well
```python
import xarray as xr
da = xr.DataArray([1])
reveal_type(xr.core.weighted.DataArrayWeighted(da, da).mean())
```
However, what I cannot get to work is:
```python
reveal_type(da.weighted(da))
```
(returns `Any`). What _almost_ works is:
```python
def weighted(self: T_DSorDA, weights: ""DataArray"") -> Weighted[T_DSorDA]:
return self._weighted_cls(self, weights)
```
However, mypy does not like that I overwrite the type of `self` with `T_DSorDA`...","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,787502146
https://github.com/pydata/xarray/pull/4818#issuecomment-761710076,https://api.github.com/repos/pydata/xarray/issues/4818,761710076,MDEyOklzc3VlQ29tbWVudDc2MTcxMDA3Ng==,5635139,2021-01-17T01:17:47Z,2021-01-17T01:17:47Z,MEMBER,Nice!,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,787502146