-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Description
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
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
- Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
- Complete example — the example is self-contained, including all data and the text of any traceback.
- Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
- 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.
zmoon