issue_comments: 974588586
This data as json
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/5950#issuecomment-974588586 | https://api.github.com/repos/pydata/xarray/issues/5950 | 974588586 | IC_kwDOAMm_X846Fwqq | 14371165 | 2021-11-20T04:00:45Z | 2021-11-20T04:00:45Z | MEMBER | These mypy errors are quite tricky. Any ideas how to solve them? Here's a stripped down example: ```python class DatasetReduce2(Protocol): def reduce(self, func: Callable): ... class DatasetReductions2: def sum(self: DatasetReduce2, dim: Hashable) -> int: return self.reduce(lambda x: x) class Test(DatasetReductions2): def init(self, a, b): self.a = a self.b = b a = Test(1, 2) a.sum("z") Invalid self argument "Test" to attribute function "sum" with type "Callable[[DatasetReduce2, Hashable], int] ``` It's posssible to avoid the failures using the previous import way instead of mixing in directly in the dataset/dataarray class, But I think the typing is simply stripped then instead, so that's no good either. Interesting reading: https://stackoverflow.com/questions/51930339/how-do-i-correctly-add-type-hints-to-mixin-classes |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1046990273 |