From ea695ee18d197c89a5598981314be29cfc56b639 Mon Sep 17 00:00:00 2001 From: Ruth Comer <10599679+rcomer@users.noreply.github.com> Date: Sat, 28 Oct 2023 13:35:48 +0100 Subject: [PATCH] Backport PR #27217: Fix type hints for undeprecated contour APIs (cherry picked from commit 518b268a5e94f8dcec079cb07eb735981e5ac0ef) --- ci/mypy-stubtest-allowlist.txt | 4 ---- lib/matplotlib/contour.pyi | 11 ++++++++--- lib/matplotlib/path.pyi | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ci/mypy-stubtest-allowlist.txt b/ci/mypy-stubtest-allowlist.txt index 8a7ffb18df7f..778494446d38 100644 --- a/ci/mypy-stubtest-allowlist.txt +++ b/ci/mypy-stubtest-allowlist.txt @@ -46,10 +46,6 @@ matplotlib.widgets.MultiCursor.needclear # 3.8 deprecations matplotlib.cbook.get_sample_data -matplotlib.contour.ContourSet.allkinds -matplotlib.contour.ContourSet.allsegs -matplotlib.contour.ContourSet.tcolors -matplotlib.contour.ContourSet.tlinewidths matplotlib.ticker.LogLocator.__init__ matplotlib.ticker.LogLocator.set_params 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