home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 1347715262

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
1347715262 I_kwDOAMm_X85QVIC- 6949 Plot accessors miss static typing 43316012 closed 0     0 2022-08-23T10:38:56Z 2022-10-16T09:26:55Z 2022-10-16T09:26:55Z COLLABORATOR      

What happened?

The plot accessors i.e. dataarray.plot of type _PlotMethods are missing static typing especially of function attributes. See #6947 for an example.

The problem is that many plotting methods are added using hooks via decorators, something that mypy does not understand.

What did you expect to happen?

As a quick fix: type the plot accessors as _PlotMethods | Any to avoid false positives in mypy.

Better to either restructure the accessor with static methods instead of hooks or figure out another way of telling static type checkers about these methods.

Anyway: mypy should not complain.

Minimal Complete Verifiable Example

```Python import xarray as xr

da = xr.DataArray([[1,2,3], [4,5,6]], dims=["x", "y"]) da.plot.contourf(x="x", y="y")

mypy complains:

error: "_PlotMethods" has no attribute "contourf"

```

MVCE confirmation

  • [X] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
  • [X] Complete example — the example is self-contained, including all data and the text of any traceback.
  • [X] Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
  • [X] New issue — a search of GitHub Issues suggests this is not a duplicate.

Relevant log output

No response

Anything else we need to know?

No response

Environment

On mobile, can edit it later if required. Newest xarray should have this problem, before the accessor was Any.

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

Links from other tables

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