home / github

Menu
  • GraphQL API
  • Search all tables

issue_comments

Table actions
  • GraphQL API for issue_comments

3 rows where author_association = "CONTRIBUTOR" and issue = 617140674 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: reactions, created_at (date), updated_at (date)

user 2

  • Zeitsperre 2
  • rhkleijn 1

issue 1

  • Type checking fails for multiplication · 3 ✖

author_association 1

  • CONTRIBUTOR · 3 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
778628502 https://github.com/pydata/xarray/issues/4054#issuecomment-778628502 https://api.github.com/repos/pydata/xarray/issues/4054 MDEyOklzc3VlQ29tbWVudDc3ODYyODUwMg== rhkleijn 32801740 2021-02-13T14:40:51Z 2021-02-13T14:40:51Z CONTRIBUTOR

I have implemented a possible solution to have typing for all unary and binary operators which works for mypy and also displays correctly inferred type hints on hovering over the code in Pylance (with VS Code) and PyCharm. The approach involves generating a stub file using a simple helper script. I'll open a draft PR so you can see this approach and for soliciting feedback.

I have been experimenting with all kinds of other approaches to solve this issue but this was the only one with a satisfactory result. For reference, and jotting down from memory, I think I tried the following approaches without much success:

  • add the typing information to the not_implemented function in https://github.com/pydata/xarray/blob/971bad7c21551f297d3e1e24e3779488ea1b9565/xarray/core/arithmetic.py#L83-L105
  • adding type declarations in a Generic mixin class parameterized on the return type of the methods. This doesn't handle dependencies of the return type on the type of the second argument of binary operators.
  • adding type declarations in a Generic mixin class parameterized on a Callback Protocol (PEP 544). This is too much magic for typing tools to grasp.
  • adding type declarations directly using a Callback Protocol. This seems to works fine for regular function but for methods the type of self of the class implementing the Protocol gets confused with the type of self in the Protocol itself.
  • using an overloaded abstract method for one operator (and then assigning the method to the dunders of all other operators to avoid a lot of repetition) results in mypy errors because it does not recognize that the concrete implementations are added dynamically. Making them concrete and returning NotImplemented doesn't work as type checkers are not sufficiently aware of the fallback logic of calling the corresponding reflexive method on the other argument of the binary operation. And raising causes some type checkers to think NoReturn is the intended return type.
{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Type checking fails for multiplication 617140674
678423562 https://github.com/pydata/xarray/issues/4054#issuecomment-678423562 https://api.github.com/repos/pydata/xarray/issues/4054 MDEyOklzc3VlQ29tbWVudDY3ODQyMzU2Mg== Zeitsperre 10819524 2020-08-21T18:16:16Z 2020-08-21T18:16:16Z CONTRIBUTOR

Just dicsovered that the same things is true for ~. Another thing to add to the list: ... : error: Unsupported operand type for ~ ("DataArray") [operator]

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Type checking fails for multiplication 617140674
677920840 https://github.com/pydata/xarray/issues/4054#issuecomment-677920840 https://api.github.com/repos/pydata/xarray/issues/4054 MDEyOklzc3VlQ29tbWVudDY3NzkyMDg0MA== Zeitsperre 10819524 2020-08-20T21:41:51Z 2020-08-20T22:48:49Z CONTRIBUTOR

We're currently working on a library largely based on xarray and have seen the same types of errors from mypy (PR in our project that is currently trying to integrate mypy: https://github.com/Ouranosinc/xclim/pull/532). Currently working off of xarray v0.16.

I also want to note this error is raised for other operations as well (+, -, /, and *) between xarray.DataArray and xarray.Datasets.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Type checking fails for multiplication 617140674

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [issue_comments] (
   [html_url] TEXT,
   [issue_url] TEXT,
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [created_at] TEXT,
   [updated_at] TEXT,
   [author_association] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [performed_via_github_app] TEXT,
   [issue] INTEGER REFERENCES [issues]([id])
);
CREATE INDEX [idx_issue_comments_issue]
    ON [issue_comments] ([issue]);
CREATE INDEX [idx_issue_comments_user]
    ON [issue_comments] ([user]);
Powered by Datasette · Queries took 14.835ms · About: xarray-datasette