home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 1902155047

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
1902155047 PR_kwDOAMm_X85aonTY 8208 Use a bound `TypeVar` for `DataArray` and `Dataset` methods 5635139 closed 0     4 2023-09-19T03:46:33Z 2023-09-28T16:46:54Z 2023-09-19T19:20:42Z MEMBER   1 pydata/xarray/pulls/8208
  • [ ] User visible changes (including notable bug fixes) are documented in whats-new.rst

Edit: I added a comment outlining a problem with this


I think we should be using a TypeVar(..., bound=...) for our typing, since otherwise subtypes aren't allowed. I don't see a compelling reason to have all of T_DataWithCoords and T_DataArrayOrSet and T_Xarray, though I might be missing something.

So this unifies all T_DataWithCoords, T_DataArrayOrSet and T_Xarray to T_Xarray, and changes that type to be bound on a union of DataArray & Dataset (similar to the existing T_DataArrayOrSet). This covers the bulk of our API — functions which transform either a DataArray or Dataset and return the input type.

This does require some manual casts; I think because when there's a concrete path for both DataArray & Dataset, mypy doesn't unify them back together. It's also possible I'm missing something.

One alternative — a minor change — would be to bound on DataWithCoords, like the existing T_DataWithCoords, rather than the union. A quick comparison showed each required some additional casts / ignores over the other.

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/8208/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    13221727 pull

Links from other tables

  • 5 rows from issues_id in issues_labels
  • 0 rows from issue in issue_comments
Powered by Datasette · Queries took 0.695ms · About: xarray-datasette