8000 Merge pull request #25844 from ksunden/allowlist_reduction · matplotlib/matplotlib@7d7f6da · GitHub
[go: up one dir, main page]

Skip to content

Commit 7d7f6da

Browse files
authored
Merge pull request #25844 from ksunden/allowlist_reduction
[TYP] Reduce stubtest ignores
2 parents 4384062 + c768050 commit 7d7f6da

File tree

6 files changed

+20
-24
lines changed

6 files changed

+20
-24
lines changed

ci/mypy-stubtest-allowlist.txt

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ matplotlib.*\.set$
1717
matplotlib.pyplot.*
1818
matplotlib.typing.*
1919

20-
# Other decorator modifying signature (maybe investigate)
20+
# Other decorator modifying signature
21+
# Runtime picks up *args **kwargs, but only decorated by a decorator that uses @wraps so?
2122
matplotlib.axis.Axis.draw
23+
# Backcompat decorator which does not modify runtime reported signature
2224
matplotlib.offsetbox.*Offset[Bb]ox.get_offset
2325

24-
# Inconsistent super/sub class signatures (other than just arg name)
25-
matplotlib.ticker.MultipleLocator.set_params
26-
matplotlib.text.Annotation.get_window_extent
27-
2826
# Inconsistent super/sub class parameter name (maybe rename for consistency)
2927
matplotlib.projections.polar.RadialLocator.nonsingular
3028
matplotlib.ticker.LogLocator.nonsingular
@@ -163,12 +161,6 @@ matplotlib.axes._base._AxesBase.get_fc
163161
matplotlib.axes._base._AxesBase.set_fc
164162

165163
# Other dynamic python behaviors not type hinted
166-
matplotlib.projections.polar.PolarAxes.InvertedPolarTransform
167-
matplotlib.projections.polar.PolarAxes.PolarAffine
168-
matplotlib.projections.polar.PolarAxes.PolarTransform
169-
matplotlib.projections.polar.PolarAxes.RadialLocator
170-
matplotlib.projections.polar.PolarAxes.ThetaFormatter
171-
matplotlib.projections.polar.PolarAxes.ThetaLocator
172164
matplotlib.rcsetup.defaultParams
173165

174166
# Maybe should be abstractmethods, required for subclasses, stubs define once
@@ -178,10 +170,6 @@ matplotlib.tri.*TriInterpolator.gradient
178170
# Functionally a method call, but actually a class instance, type hinted as former
179171
matplotlib.rcsetup.validate_fillstyle
180172

181-
# C-defined method without docstring indicating signature
182-
matplotlib.transforms.count_bboxes_overlapping_bbox
183-
matplotlib.transforms.update_path_extents
184-
185173
# TypeVar used only in type hints
186174
matplotlib.backend_bases.FigureCanvasBase._T
187175
matplotlib.backend_managers.ToolManager._T

lib/matplotlib/_path.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ import numpy as np
33
from .transforms import BboxBase
44

55
def affine_transform(points: np.ndarray, trans: np.ndarray) -> np.ndarray: ...
6-
def count_bboxes_overlapping_bbox(a: BboxBase, bboxes: Sequence[BboxBase]) -> int: ...
7-
def update_path_extents(*args, **kwargs): ...
6+
def count_bboxes_overlapping_bbox(bbox: BboxBase, bboxes: Sequence[BboxBase]) -> int: ...
7+
def update_path_extents(path, trans, rect, minpos, ignore): ...

lib/matplotlib/projections/polar.pyi

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ from matplotlib.text import Text
88
import numpy as np
99
from numpy.typing import ArrayLike
1010
from collections.abc import Sequence
11-
from typing import Any, Literal, overload
11+
from typing import Any, ClassVar, Literal, overload
1212

1313
class PolarTransform(mtransforms.Transform):
1414
input_dims: int
@@ -80,6 +80,14 @@ class _WedgeBbox(mtransforms.Bbox):
8080
) -> None: ...
8181

8282
class PolarAxes(Axes):
83+
84+
PolarTransform: ClassVar[type] = PolarTransform
85+
PolarAffine: ClassVar[type] = PolarAffine
86+
InvertedPolarTransform: ClassVar[type] = InvertedPolarTransform
87+
ThetaFormatter: ClassVar[type] = ThetaFormatter
88+
RadialLocator: ClassVar[type] = RadialLocator
89+
ThetaLocator: ClassVar[type] = ThetaLocator
90+
8391
name: str
8492
use_sticky_edges: bool
8593
def __init__(

lib/matplotlib/text.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,5 @@ class Annotation(Text, _AnnotationBase):
203203
| Callable[[RendererBase], Bbox | Transform],
204204
) -> None: ...
205205
def update_positions(self, renderer: RendererBase) -> None: ...
206+
# Drops `dpi` parameter from superclass
207+
def get_window_extent(self, renderer: RendererBase | None = ...) -> Bbox: ... # type: ignore[override]

lib/matplotlib/ticker.pyi

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ class PercentFormatter(Formatter):
172172
class Locator(TickHelper):
173173
MAXTICKS: int
174174
def tick_values(self, vmin: float, vmax: float) -> Sequence[float]: ...
175+
# Implementation accepts **kwargs, but is a no-op other than a warning
176+
# Typing as **kwargs would require each subclass to accept **kwargs for mypy
175177
def set_params(self) -> None: ...
176178
def __call__(self) -> Sequence[float]: ...
177179
def raise_if_exceeds(self, locs: Sequence[float]) -> Sequence[float]: ...
@@ -211,7 +213,8 @@ class LinearLocator(Locator):
211213

212214
class MultipleLocator(Locator):
213215
def __init__(self, base: float = ...) -> None: ...
214-
def set_params(self, base: float | None = ...) -> None: ...
216+
# Makes set_params `base` argument mandatory
217+
def set_params(self, base: float | None) -> None: ... # type: ignore[override]
215218
def view_limits(self, dmin: float, dmax: float) -> tuple[float, float]: ...
216219

217220
class 961E _Edge_integer:

lib/matplotlib/transforms.pyi

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
from .path import Path
22
from .patches import Patch
33
from .figure import Figure
4-
from matplotlib._path import (
5-
affine_transform as affine_transform,
6-
count_bboxes_overlapping_bbox as count_bboxes_overlapping_bbox,
7-
update_path_extents as update_path_extents,
8-
)
94
import numpy as np
105
from numpy.typing import ArrayLike
116
from collections.abc import Iterable, Sequence

0 commit comments

Comments
 (0)
0