home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 998973316

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/6086#issuecomment-998973316 https://api.github.com/repos/pydata/xarray/issues/6086 998973316 IC_kwDOAMm_X847ix-E 35968931 2021-12-21T17:43:11Z 2021-12-23T04:12:48Z MEMBER

This is just an internal check in xarray, verifying that _variables is always a Python dict. I would be fine turning this off, certainly at least for tests with the new custom mapping.

It seems I can make that check pass very easily, because this already works somehow, even though they aren't considered subtypes :confused:

```python In [1]: from xarray.core.utils import CopyableMutableMapping

In [2]: d = {}

In [3]: isinstance(d, CopyableMutableMapping) Out[3]: True ```

I realize that my assertion above isn't quite right — the issue was about Mapping[Hashable, V], not Dict[Hashable, V].

Changing CopyableMutableMapping[Hashable, Variable] to Mapping[Hashable, Variable] in the type hints for ._construct_direct and ._replace gets rid of loads of type errors! Must be because those methods don't actually need to mutate the mapping, so won't complain about .update if it's never called on those types.

Still have a bunch of errors like this though

xarray/core/dataset.py:785: error: Argument 1 to "Frozen" has incompatible type "CopyableMutableMapping[Hashable, Variable]"; expected "Mapping[Hashable, Variable]" [arg-type]

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  1084220684
Powered by Datasette · Queries took 159.906ms · About: xarray-datasette