You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
importxarrayasxrda=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.
The text was updated successfully, but these errors were encountered:
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
MVCE confirmation
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.
The text was updated successfully, but these errors were encountered: