home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 914207743

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/5692#issuecomment-914207743 https://api.github.com/repos/pydata/xarray/issues/5692 914207743 IC_kwDOAMm_X842fbP_ 4160723 2021-09-07T11:01:40Z 2021-09-07T15:53:17Z MEMBER

I'm currently adding more type annotations to the Index (sub)classes. I'm not 100% sure what to do for the query method, though. Without type annotations, I was thinking about those signatures:

```python class Index: def query(self, labels, **kwargs): raise NotImplementedError()

class PandasIndex(Index): def query(self, labels, method=None, tolerance=None): ...

class CustomIndex(Index): def query(self, labels, option1="value", option2=5): ... ```

However, this is unsafe and mypy complains (https://github.com/python/mypy/issues/7424).

Alternative options that work with type annotations:

  1. add # type: ignore[override] in Index subclasses
  2. add **kwargs in subclasses too (those are ignored)
  3. use a fixed number of arguments, i.e., Index.query(labels, query_options: Optional[Dict[str, Any]] = None)

Maybe other alternatives?

I don't like 1 and 2, it does not look very nice. 3 makes default query option values less clear, unless we define them elsewhere as a convention (e.g., as a class property)?

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