Skip to content

Mypy errors with matplotlib 3.8 #7802

Closed
@Illviljan

Description

@Illviljan

Matplotlib has started to support typing in main (matplotlib/matplotlib#20504) and mypy is throwing a few errors:

xarray/core/options.py:12: error: Cannot assign to a type  [misc]
xarray/core/options.py:12: error: Incompatible types in assignment (expression has type "Type[str]", variable has type "Type[Colormap]")  [assignment]
xarray/plot/utils.py:808: error: Argument 1 to "set_xticks" of "_AxesBase" has incompatible type "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]"; expected "Iterable[float]"  [arg-type]
xarray/plot/utils.py:810: error: Argument 1 to "set_yticks" of "_AxesBase" has incompatible type "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]"; expected "Iterable[float]"  [arg-type]
xarray/plot/utils.py:813: error: Argument 1 to "set_xlim" of "_AxesBase" has incompatible type "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]"; expected "Union[float, Tuple[float, float], None]"  [arg-type]
xarray/plot/utils.py:815: error: Argument 1 to "set_ylim" of "_AxesBase" has incompatible type "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]"; expected "Union[float, Tuple[float, float], None]"  [arg-type]
Generated Cobertura report: /home/runner/work/xarray/xarray/mypy_report/cobertura.xml
Installing missing stub packages:
/home/runner/micromamba-root/envs/xarray-tests/bin/python -m pip install types-Pillow types-PyYAML types-Pygments types-babel types-colorama types-paramiko types-psutil types-pytz types-pywin32 types-setuptools types-urllib3


Generated Cobertura report: /home/runner/work/xarray/xarray/mypy_report/cobertura.xml
Found 154 errors in 10 files (checked 138 source files)
xarray/plot/utils.py:1349: error: Unsupported operand types for * ("_SupportsArray[dtype[Any]]" and "float")  [operator]
xarray/plot/utils.py:1349: error: Unsupported operand types for * ("_NestedSequence[_SupportsArray[dtype[Any]]]" and "float")  [operator]
xarray/plot/utils.py:1349: error: Unsupported operand types for * ("_NestedSequence[Union[bool, int, float, complex, str, bytes]]" and "float")  [operator]
xarray/plot/utils.py:1349: note: Left operand is of type "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]"
xarray/plot/utils.py:1349: error: Unsupported operand types for * ("str" and "float")  [operator]
xarray/plot/utils.py:1349: error: Unsupported operand types for * ("bytes" and "float")  [operator]
xarray/plot/utils.py:1350: error: Item "_SupportsArray[dtype[Any]]" of "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]" has no attribute "mask"  [union-attr]
xarray/plot/utils.py:1350: error: Item "_NestedSequence[_SupportsArray[dtype[Any]]]" of "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]" has no attribute "mask"  [union-attr]
xarray/plot/utils.py:1350: error: Item "int" of "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]" has no attribute "mask"  [union-attr]
xarray/plot/utils.py:1350: error: Item "float" of "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]" has no attribute "mask"  [union-attr]
xarray/plot/utils.py:1350: error: Item "complex" of "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]" has no attribute "mask"  [union-attr]
xarray/plot/utils.py:1350: error: Item "str" of "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]" has no attribute "mask"  [union-attr]
xarray/plot/utils.py:1350: error: Item "bytes" of "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]" has no attribute "mask"  [union-attr]
xarray/plot/utils.py:1350: error: Item "_NestedSequence[Union[bool, int, float, complex, str, bytes]]" of "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]" has no attribute "mask"  [union-attr]
xarray/plot/utils.py:1351: error: Item "_SupportsArray[dtype[Any]]" of "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]" has no attribute "mask"  [union-attr]
xarray/plot/utils.py:1351: error: Item "_NestedSequence[_SupportsArray[dtype[Any]]]" of "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]" has no attribute "mask"  [union-attr]
xarray/plot/utils.py:1351: error: Item "int" of "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]" has no attribute "mask"  [union-attr]
xarray/plot/utils.py:1351: error: Item "float" of "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]" has no attribute "mask"  [union-attr]
xarray/plot/utils.py:1351: error: Item "complex" of "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]" has no attribute "mask"  [union-attr]
xarray/plot/utils.py:1351: error: Item "str" of "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]" has no attribute "mask"  [union-attr]
xarray/plot/utils.py:1351: error: Item "bytes" of "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]" has no attribute "mask"  [union-attr]
xarray/plot/utils.py:1351: error: Item "_NestedSequence[Union[bool, int, float, complex, str, bytes]]" of "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]" has no attribute "mask"  [union-attr]
xarray/plot/facetgrid.py:684: error: "FigureCanvasBase" has no attribute "get_renderer"  [attr-defined]
xarray/plot/accessor.py:182: error: Overloaded function signatures 1 and 2 overlap with incompatible return types  [misc]
xarray/plot/accessor.py:182: error: Overloaded function signatures 1 and 3 overlap with incompatible return types  [misc]
xarray/plot/accessor.py:309: error: Overloaded function signatures 1 and 2 overlap with incompatible return types  [misc]
xarray/plot/accessor.py:309: error: Overloaded function signatures 1 and 3 overlap with incompatible return types  [misc]
xarray/plot/accessor.py:428: error: Overloaded function implementation cannot produce return type of signature 2  [misc]
xarray/plot/accessor.py:428: error: Overloaded function implementation cannot produce return type of signature 3  [misc]
xarray/plot/accessor.py:433: error: Overloaded function signatures 1 and 2 overlap with incompatible return types  [misc]
xarray/plot/accessor.py:433: error: Overloaded function signatures 1 and 3 overlap with incompatible return types  [misc]
xarray/plot/accessor.py:552: error: Overloaded function implementation cannot produce return type of signature 2  [misc]
xarray/plot/accessor.py:552: error: Overloaded function implementation cannot produce return type of signature 3  [misc]
xarray/plot/accessor.py:557: error: Overloaded function signatures 1 and 2 overlap with incompatible return types  [misc]
xarray/plot/accessor.py:557: error: Overloaded function signatures 1 and 3 overlap with incompatible return types  [misc]
xarray/plot/accessor.py:676: error: Overloaded function implementation cannot produce return type of signature 2  [misc]
xarray/plot/accessor.py:676: error: Overloaded function implementation cannot produce return type of signature 3  [misc]
xarray/plot/accessor.py:681: error: Overloaded function signatures 1 and 2 overlap with incompatible return types  [misc]
xarray/plot/accessor.py:681: error: Overloaded function signatures 1 and 3 overlap with incompatible return types  [misc]
xarray/plot/accessor.py:800: error: Overloaded function implementation cannot produce return type of signature 2  [misc]
xarray/plot/accessor.py:800: error: Overloaded function implementation cannot produce return type of signature 3  [misc]
xarray/plot/accessor.py:948: error: Overloaded function signatures 1 and 2 overlap with incompatible return types  [misc]
xarray/plot/accessor.py:948: error: Overloaded function signatures 1 and 3 overlap with incompatible return types  [misc]
xarray/plot/accessor.py:1075: error: Overloaded function signatures 1 and 2 overlap with incompatible return types  [misc]
xarray/plot/accessor.py:1075: error: Overloaded function signatures 1 and 3 overlap with incompatible return types  [misc]
xarray/plot/accessor.py:1190: error: Overloaded function signatures 1 and 2 overlap with incompatible return types  [misc]
xarray/plot/accessor.py:1190: error: Overloaded function signatures 1 and 3 overlap with incompatible return types  [misc]
xarray/plot/dataset_plot.py:324: error: Overloaded function signatures 1 and 2 overlap with incompatible return types  [misc]
xarray/plot/dataset_plot.py:324: error: Overloaded function signatures 1 and 3 overlap with incompatible return types  [misc]
xarray/plot/dataset_plot.py:478: error: Overloaded function signatures 1 and 2 overlap with incompatible return types  [misc]
xarray/plot/dataset_plot.py:478: error: Overloaded function signatures 1 and 3 overlap with incompatible return types  [misc]
xarray/plot/dataset_plot.py:649: error: Function gets multiple values for keyword argument "x"  [misc]
xarray/plot/dataset_plot.py:649: error: Function gets multiple values for keyword argument "y"  [misc]
xarray/plot/dataset_plot.py:649: error: Function gets multiple values for keyword argument "u"  [misc]
xarray/plot/dataset_plot.py:649: error: Function gets multiple values for keyword argument "v"  [misc]
xarray/plot/dataset_plot.py:649: error: Function gets multiple values for keyword argument "density"  [misc]
xarray/plot/dataset_plot.py:649: error: Function gets multiple values for keyword argument "linewidth"  [misc]
xarray/plot/dataset_plot.py:649: error: Function gets multiple values for keyword argument "color"  [misc]
xarray/plot/dataset_plot.py:649: error: Function gets multiple values for keyword argument "cmap"  [misc]
xarray/plot/dataset_plot.py:649: error: Function gets multiple values for keyword argument "norm"  [misc]
xarray/plot/dataset_plot.py:649: error: Function gets multiple values for keyword argument "arrowsize"  [misc]
xarray/plot/dataset_plot.py:649: error: Function gets multiple values for keyword argument "arrowstyle"  [misc]
xarray/plot/dataset_plot.py:649: error: Function gets multiple values for keyword argument "minlength"  [misc]
xarray/plot/dataset_plot.py:649: error: Function gets multiple values for keyword argument "transform"  [misc]
xarray/plot/dataset_plot.py:649: error: Function gets multiple values for keyword argument "zorder"  [misc]
xarray/plot/dataset_plot.py:649: error: Function gets multiple values for keyword argument "start_points"  [misc]
xarray/plot/dataset_plot.py:649: error: Function gets multiple values for keyword argument "maxlength"  [misc]
xarray/plot/dataset_plot.py:649: error: Function gets multiple values for keyword argument "integration_direction"  [misc]
xarray/plot/dataset_plot.py:649: error: Function gets multiple values for keyword argument "broken_streamlines"  [misc]
xarray/plot/dataset_plot.py:649: error: Argument 1 has incompatible type "*List[ndarray[Any, Any]]"; expected "Union[float, Tuple[float, float]]"  [arg-type]
xarray/plot/dataset_plot.py:649: error: Argument 1 has incompatible type "*List[ndarray[Any, Any]]"; expected "Union[str, Colormap, None]"  [arg-type]
xarray/plot/dataset_plot.py:649: error: Argument 1 has incompatible type "*List[ndarray[Any, Any]]"; expected "Union[str, Normalize, None]"  [arg-type]
xarray/plot/dataset_plot.py:649: error: Argument 1 has incompatible type "*List[ndarray[Any, Any]]"; expected "float"  [arg-type]
xarray/plot/dataset_plot.py:649: error: Argument 1 has incompatible type "*List[ndarray[Any, Any]]"; expected "Union[str, ArrowStyle]"  [arg-type]
xarray/plot/dataset_plot.py:649: error: Argument 1 has incompatible type "*List[ndarray[Any, Any]]"; expected "Optional[Transform]"  [arg-type]
xarray/plot/dataset_plot.py:649: error: Argument 1 has incompatible type "*List[ndarray[Any, Any]]"; expected "Optional[float]"  [arg-type]
xarray/plot/dataset_plot.py:649: error: Argument 1 has incompatible type "*List[ndarray[Any, Any]]"; expected "Literal['forward', 'backward', 'both']"  [arg-type]
xarray/plot/dataset_plot.py:649: error: Argument 1 has incompatible type "*List[ndarray[Any, Any]]"; expected "bool"  [arg-type]
xarray/plot/dataset_plot.py:751: error: Overloaded function signatures 1 and 2 overlap with incompatible return types  [misc]
xarray/plot/dataset_plot.py:751: error: Overloaded function signatures 1 and 3 overlap with incompatible return types  [misc]
xarray/plot/dataarray_plot.py:718: error: Incompatible return value type (got "Tuple[Union[ndarray[Any, Any], List[ndarray[Any, Any]]], ndarray[Any, Any], Union[BarContainer, Polygon, List[Union[BarContainer, Polygon]]]]", expected "Tuple[ndarray[Any, Any], ndarray[Any, Any], BarContainer]")  [return-value]
xarray/plot/dataarray_plot.py:996: error: "Axes" has no attribute "view_init"  [attr-defined]
xarray/plot/dataarray_plot.py:1106: error: Overloaded function signatures 1 and 2 overlap with incompatible return types  [misc]
xarray/plot/dataarray_plot.py:1106: error: Overloaded function signatures 1 and 3 overlap with incompatible return types  [misc]
xarray/plot/dataarray_plot.py:1261: error: Argument 1 to "scatter" of "Axes" has incompatible type "*List[ndarray[Any, Any]]"; expected "Union[Sequence[Union[Union[Tuple[float, float, float], str], Union[str, Tuple[float, float, float, float], Tuple[Union[Tuple[float, float, float], str], float], Tuple[Tuple[float, float, float, float], float]]]], Union[Union[Tuple[float, float, float], str], Union[str, Tuple[float, float, float, float], Tuple[Union[Tuple[float, float, float], str], float], Tuple[Tuple[float, float, float, float], float]]], None]"  [arg-type]
xarray/plot/dataarray_plot.py:1261: error: Argument 1 to "scatter" of "Axes" has incompatible type "*List[ndarray[Any, Any]]"; expected "Optional[Union[str, Path, MarkerStyle]]"  [arg-type]
xarray/plot/dataarray_plot.py:1261: error: Argument 1 to "scatter" of "Axes" has incompatible type "*List[ndarray[Any, Any]]"; expected "Union[str, Colormap, None]"  [arg-type]
xarray/plot/dataarray_plot.py:1261: error: Argument 1 to "scatter" of "Axes" has incompatible type "*List[ndarray[Any, Any]]"; expected "Union[str, Normalize, None]"  [arg-type]
xarray/plot/dataarray_plot.py:1261: error: Argument 1 to "scatter" of "Axes" has incompatible type "*List[ndarray[Any, Any]]"; expected "Optional[float]"  [arg-type]
xarray/plot/dataarray_plot.py:1261: error: Argument 1 to "scatter" of "Axes" has incompatible type "*List[ndarray[Any, Any]]"; expected "Union[float, Sequence[float], None]"  [arg-type]
xarray/plot/dataarray_plot.py:1615: error: "Axes" has no attribute "set_zlabel"  [attr-defined]
xarray/plot/dataarray_plot.py:1655: error: Overloaded function signatures 1 and 2 overlap with incompatible return types  [misc]
xarray/plot/dataarray_plot.py:1655: error: Overloaded function signatures 1 and 3 overlap with incompatible return types  [misc]
xarray/plot/dataarray_plot.py:1874: error: Overloaded function signatures 1 and 2 overlap with incompatible return types  [misc]
xarray/plot/dataarray_plot.py:1874: error: Overloaded function signatures 1 and 3 overlap with incompatible return types  [misc]
xarray/plot/dataarray_plot.py:2010: error: Overloaded function signatures 1 and 2 overlap with incompatible return types  [misc]
xarray/plot/dataarray_plot.py:2010: error: Overloaded function signatures 1 and 3 overlap with incompatible return types  [misc]
xarray/plot/dataarray_plot.py:2146: error: Overloaded function signatures 1 and 2 overlap with incompatible return types  [misc]
xarray/plot/dataarray_plot.py:2146: error: Overloaded function signatures 1 and 3 overlap with incompatible return types  [misc]
xarray/plot/dataarray_plot.py:2464: error: "Axes" has no attribute "plot_surface"  [attr-defined]
xarray/tests/test_plot.py:427: error: Value of type "Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]" is not indexable  [index]
xarray/tests/test_plot.py:443: error: Module has no attribute "viridis"  [attr-defined]
xarray/tests/test_plot.py:457: error: "None" not callable  [misc]
xarray/tests/test_plot.py:462: error: "None" not callable  [misc]
xarray/tests/test_plot.py:465: error: "None" not callable  [misc]
xarray/tests/test_plot.py:471: error: Module has no attribute "viridis"  [attr-defined]
xarray/tests/test_plot.py:477: error: Module has no attribute "viridis"  [attr-defined]
xarray/tests/test_plot.py:482: error: Module has no attribute "viridis"  [attr-defined]
xarray/tests/test_plot.py:486: error: Module has no attribute "viridis"  [attr-defined]
xarray/tests/test_plot.py:493: error: "None" not callable  [misc]
xarray/tests/test_plot.py:498: error: "None" not callable  [misc]
xarray/tests/test_plot.py:501: error: "None" not callable  [misc]
xarray/tests/test_plot.py:931: error: Module has no attribute "magma"  [attr-defined]
xarray/tests/test_plot.py:933: error: Module has no attribute "magma"  [attr-defined]
xarray/tests/test_plot.py:1173: error: Module has no attribute "RdBu"  [attr-defined]
xarray/tests/test_plot.py:1746: error: Item "Colormap" of "Optional[Colormap]" has no attribute "colors"  [union-attr]
xarray/tests/test_plot.py:1746: error: Item "None" of "Optional[Colormap]" has no attribute "colors"  [union-attr]
xarray/tests/test_plot.py:1747: error: Item "Colormap" of "Optional[Colormap]" has no attribute "colors"  [union-attr]
xarray/tests/test_plot.py:1747: error: Item "None" of "Optional[Colormap]" has no attribute "colors"  [union-attr]
xarray/tests/test_plot.py:1749: error: Item "Colormap" of "Optional[Colormap]" has no attribute "_rgba_over"  [union-attr]
xarray/tests/test_plot.py:1749: error: Item "None" of "Optional[Colormap]" has no attribute "_rgba_over"  [union-attr]
xarray/tests/test_plot.py:1801: error: Item "None" of "Optional[ndarray[Any, Any]]" has no attribute "size"  [union-attr]
xarray/tests/test_plot.py:1952: error: Item "None" of "Optional[ndarray[Any, Any]]" has no attribute "min"  [union-attr]
xarray/tests/test_plot.py:1952: error: Item "None" of "Optional[ndarray[Any, Any]]" has no attribute "max"  [union-attr]
xarray/tests/test_plot.py:1968: error: Item "None" of "Optional[ndarray[Any, Any]]" has no attribute "dtype"  [union-attr]
xarray/tests/test_plot.py:1969: error: Value of type "Optional[ndarray[Any, Any]]" is not indexable  [index]
xarray/tests/test_plot.py:2125: error: "Artist" has no attribute "get_clim"  [attr-defined]
xarray/tests/test_plot.py:2135: error: "Colorbar" has no attribute "vmin"  [attr-defined]
xarray/tests/test_plot.py:2136: error: "Colorbar" has no attribute "vmax"  [attr-defined]
xarray/tests/test_plot.py:2202: error: "Artist" has no attribute "get_clim"  [attr-defined]
xarray/tests/test_plot.py:2218: error: "Artist" has no attribute "norm"  [attr-defined]
xarray/tests/test_plot.py:2747: error: Item "_AxesBase" of "Optional[_AxesBase]" has no attribute "legend_"  [union-attr]
xarray/tests/test_plot.py:2747: error: Item "None" of "Optional[_AxesBase]" has no attribute "legend_"  [union-attr]
xarray/tests/test_plot.py:2754: error: Item "None" of "Optional[_AxesBase]" has no attribute "get_legend"  [union-attr]
xarray/tests/test_plot.py:2775: error: Item "None" of "Optional[FigureBase]" has no attribute "axes"  [union-attr]
xarray/tests/test_plot.py:2775: error: Argument 1 to "len" has incompatible type "Union[_AxesBase, None, Any]"; expected "Sized"  [arg-type]
xarray/tests/test_plot.py:2803: error: Module has no attribute "dates"  [attr-defined]
xarray/tests/test_plot.py:2812: error: Module has no attribute "dates"  [attr-defined]
xarray/tests/test_plot.py:2831: error: Item "None" of "Optional[_AxesBase]" has no attribute "xaxis"  [union-attr]
xarray/tests/test_plot.py:2831: error: Module has no attribute "dates"  [attr-defined]
xarray/tests/test_groupby.py:715: error: Argument 1 to "groupby" of "Dataset" has incompatible type "ndarray[Any, dtype[signedinteger[Any]]]"; expected "Union[Hashable, DataArray, IndexVariable]"  [arg-type]
xarray/tests/test_groupby.py:715: note: Following member(s) of "ndarray[Any, dtype[signedinteger[Any]]]" have conflicts:
xarray/tests/test_groupby.py:715: note:     __hash__: expected "Callable[[], int]", got "None"
xarray/tests/test_dataset.py:6964: error: "PlainQuantity[Any]" not callable  [operator]
xarray/tests/test_dataset.py:6965: error: "PlainQuantity[Any]" not callable  [operator]
xarray/tests/test_dataset.py:7007: error: "PlainQuantity[Any]" not callable  [operator]
xarray/tests/test_dataset.py:7008: error: "PlainQuantity[Any]" not callable  [operator]
xarray/tests/test_dataarray.py:6687: error: "PlainQuantity[Any]" not callable  [operator]
xarray/tests/test_dataarray.py:6689: error: "PlainQuantity[Any]" not callable  [operator]
xarray/tests/test_dataarray.py:6735: error: "PlainQuantity[Any]" not callable  [operator]
xarray/tests/test_dataarray.py:6737: error: "PlainQuantity[Any]" not callable  [operator]

Some guidance how to solve these:

  • [xy]ticks in mpl is currently overly narrowly type hinted because I was following the docstring, but I agree that ArrayLike is a better type hint for that, plan on updating (including the docstring) upstream
  • [xy]lim originally neglected the case of passing set_xlim((min, max)) as a tuple, but that has been updated. xarray has that type hinted as array like, but mpl has it hinted as a 2-tuple (I think it is currently still of floats, but may be expanded as we more directly address units/categoricals/etc). Willing to debate here, but my starting position is that the "exactly 2 values" is valuable info here, and I think tuple is the only way to do that.
  • get_renderer is not actually available on all of our backends, we should maybe see if there is a more preferred way of doing what you are doing here that will work for all backends, but haven't looked into it too closely.
  • Module has no attribute <colormap> is another instance of dynamically generated behavior which can't be statically type checked (elegantly, at least), can probably be replaced by mpl.colormaps["<colormap>"] in many cases, which is statically typecheckable
  • Anything to do with 3D Axes is not type hinted, perhaps ignore for now (or help us get that type hinted adequately, but it is relatively low priority currently)
  • Module has no attribute "dates" we don't currently type hint dates/units things, but it is on my mind, not sure yet if it will be in first release or not though (may at least put a placeholder that gets rid of this error, but treats everything as "Any").

Originally posted by @ksunden in #7787 (comment)

The suggestion from mpl (specifically @tacaswell) was to use constrained layout for the purpose that xarray currently uses get_renderer, this will ensure that the facetgrid works with all mpl backends.

Originally posted by @ksunden in #7787 (comment)

I'm also relatively sure that if you are willing to put a floor on the version of Matplotlib you support get_window_extent will use it's internally cached renderer (and when we make it uniformly optional we also fixed the cache invalidation logic).

Originally posted by @tacaswell in #7787 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions