From 44c57b4a3e33fbd5e7c3696e937c43691a484e21 Mon Sep 17 00:00:00 2001 From: Kyle Sunden Date: Fri, 27 Oct 2023 15:17:01 -0500 Subject: [PATCH] Fix type hints for undeprecated contour APIs They whad been in the limbo land of deprecated APIs that I didn't bother to ensure were the _best_ type hints because they were deprecated. So I just added them to the allowlist for stubtest, but now that they are undeprecated, make sure that they are correct. While I'm here, may as well get rid of the allow list entries for all of them, even the ones that are still deprecated, as that is documented standard practice going forward that pyi match implementation for deprecations as well --- ci/mypy-stubtest-allowlist.txt | 6 ------ lib/matplotlib/contour.pyi | 11 ++++++++--- lib/matplotlib/path.pyi | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ci/mypy-stubtest-allowlist.txt b/ci/mypy-stubtest-allowlist.txt index e9256de10b36..9f3efd283906 100644 --- a/ci/mypy-stubtest-allowlist.txt +++ b/ci/mypy-stubtest-allowlist.txt @@ -41,12 +41,6 @@ matplotlib.figure.Figure.set_tight_layout matplotlib.cm.register_cmap matplotlib.cm.unregister_cmap -# 3.8 deprecations -matplotlib.contour.ContourSet.allkinds -matplotlib.contour.ContourSet.allsegs -matplotlib.contour.ContourSet.tcolors -matplotlib.contour.ContourSet.tlinewidths - # positional-only argument name lacking leading underscores matplotlib.axes._base._AxesBase.axis diff --git a/lib/matplotlib/contour.pyi b/lib/matplotlib/contour.pyi index 8a987b762445..d7bddfe8f1f5 100644 --- a/lib/matplotlib/contour.pyi +++ b/lib/matplotlib/contour.pyi @@ -103,12 +103,17 @@ class ContourSet(ContourLabeler, Collection): clip_path: Patch | Path | TransformedPath | TransformedPatchPath | None labelTexts: list[Text] labelCValues: list[ColorType] - allkinds: list[np.ndarray] - tcolors: list[tuple[float, float, float, float]] + @property + def tcolors(self) -> list[tuple[tuple[float, float, float, float]]]: ... # only for not filled - tlinewidths: list[tuple[float]] + @property + def tlinewidths(self) -> list[tuple[float]]: ... + @property + def allkinds(self) -> list[list[np.ndarray | None]]: ... + @property + def allsegs(self) -> list[list[np.ndarray]]: ... @property def alpha(self) -> float | None: ... @property diff --git a/lib/matplotlib/path.pyi b/lib/matplotlib/path.pyi index c96c5a0ba9e4..464fc6d9a912 100644 --- a/lib/matplotlib/path.pyi +++ b/lib/matplotlib/path.pyi @@ -30,7 +30,7 @@ class Path: @vertices.setter def vertices(self, vertices: ArrayLike) -> None: ... @property - def codes(self) -> ArrayLike: ... + def codes(self) -> ArrayLike | None: ... @codes.setter def codes(self, codes: ArrayLike) -> None: ... @property