Skip to content

Commit afcc560

Browse files
committed
[TYP] Remove some stubtest allowlist entries
Mark the expected interface for some things such as Transform.input_dims as read-only via a property and remove redundant versions in subclasses Same for some offsetbox code Fix rcsetup ignores
1 parent d60de5e commit afcc560

File tree

4 files changed

+21
-34
lines changed

4 files changed

+21
-34
lines changed

ci/mypy-stubtest-allowlist.txt

-18
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,6 @@ matplotlib.ticker.LogitLocator.nonsingular
3232
matplotlib.backend_bases._Mode.__new__
3333
matplotlib.units.Number.__hash__
3434

35-
# Property read-write vs read-only weirdness, fix if possible
36-
matplotlib.offsetbox.DraggableBase.canvas
37-
matplotlib.offsetbox.DraggableBase.cids
38-
matplotlib.transforms.BboxTransform.is_separable
39-
matplotlib.transforms.BboxTransformFrom.is_separable
40-
matplotlib.transforms.BboxTransformTo.is_separable
41-
matplotlib.transforms.BlendedAffine2D.is_separable
42-
matplotlib.transforms.CompositeGenericTransform.is_separable
43-
matplotlib.transforms.TransformWrapper.input_dims
44-
matplotlib.transforms.TransformWrapper.is_separable
45-
matplotlib.transforms.TransformWrapper.output_dims
46-
4735
# 3.6 Pending deprecations
4836
matplotlib.figure.Figure.set_constrained_layout
4937
matplotlib.figure.Figure.set_constrained_layout_pads
@@ -148,16 +136,10 @@ matplotlib.text.Text.set_weight
148136
matplotlib.axes._base._AxesBase.get_fc
149137
matplotlib.axes._base._AxesBase.set_fc
150138

151-
# Other dynamic python behaviors not type hinted
152-
matplotlib.rcsetup.defaultParams
153-
154139
# Maybe should be abstractmethods, required for subclasses, stubs define once
155140
matplotlib.tri.*TriInterpolator.__call__
156141
matplotlib.tri.*TriInterpolator.gradient
157142

158-
# Functionally a method call, but actually a class instance, type hinted as former
159-
matplotlib.rcsetup.validate_fillstyle
160-
161143
# TypeVar used only in type hints
162144
matplotlib.backend_bases.FigureCanvasBase._T
163145
matplotlib.backend_managers.ToolManager._T

lib/matplotlib/offsetbox.pyi

+6-2
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,15 @@ class AnnotationBbox(martist.Artist, mtext._AnnotationBase):
280280
class DraggableBase:
281281
ref_artist: martist.Artist
282282
got_artist: bool
283-
canvas: FigureCanvasBase
284-
cids: list[int]
285283
mouse_x: int
286284
mouse_y: int
287285
background: Any
286+
287+
@property
288+
def canvas(self) -> FigureCanvasBase: ...
289+
@property
290+
def cids(self) -> list[int]: ...
291+
288292
def __init__(self, ref_artist: martist.Artist, use_blit: bool = ...) -> None: ...
289293
def on_motion(self, evt: Event) -> None: ...
290294
def on_pick(self, evt: Event) -> None: ...

lib/matplotlib/rcsetup.pyi

+6-3
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ def validate_fontstretch(
129129
def validate_font_properties(s: Any) -> dict[str, Any]: ...
130130
def validate_whiskers(s: Any) -> list[float] | float: ...
131131
def validate_ps_distiller(s: Any) -> None | Literal["ghostscript", "xpdf"]: ...
132-
def validate_fillstyle(
133-
s: Any,
134-
) -> Literal["full", "left", "right", "bottom", "top", "none"]: ...
132+
133+
validate_fillstyle: ValidateInStrings
134+
135135
def validate_fillstylelist(
136136
s: Any,
137137
) -> list[Literal["full", "left", "right", "bottom", "top", "none"]]: ...
@@ -152,3 +152,6 @@ def validate_hist_bins(
152152
) -> Literal["auto", "sturges", "fd", "doane", "scott", "rice", "sqrt"] | int | list[
153153
float
154154
]: ...
155+
156+
# At runtime is added in __init__.py
157+
defaultParams: dict[str, Any]

lib/matplotlib/transforms.pyi

+9-11
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,17 @@ class LockableBbox(BboxBase):
175175
def locked_y1(self, y1: float | None) -> None: ...
176176

177177
class Transform(TransformNode):
178-
input_dims: int | None
179-
output_dims: int | None
180-
is_separable: bool
181-
# Implemented as a standard attr in base class, but functionally readonly and some subclasses implement as such
178+
179+
# Implemented as a standard attrs in base class, but functionally readonly and some subclasses implement as such
180+
@property
181+
def input_dims(self) -> int | None: ...
182+
@property
183+
def output_dims(self) -> int | None: ...
184+
@property
185+
def is_separable(self) -> bool: ...
182186
@property
183187
def has_inverse(self) -> bool: ...
188+
184189
def __add__(self, other: Transform) -> Transform: ...
185190
@property
186191
def depth(self) -> int: ...
@@ -225,8 +230,6 @@ class Affine2DBase(AffineBase):
225230
input_dims: Literal[2]
226231
output_dims: Literal[2]
227232
def frozen(self) -> Affine2D: ...
228-
@property
229-
def is_separable(self): ...
230233
def to_values(self) -> tuple[float, float, float, float, float, float]: ...
231234

232235
class Affine2D(Affine2DBase):
@@ -255,7 +258,6 @@ class _BlendedMixin:
255258
class BlendedGenericTransform(_BlendedMixin, Transform):
256259
input_dims: Literal[2]
257260
output_dims: Literal[2]
258-
is_separable: bool
259261
pass_through: bool
260262
def __init__(
261263
self, x_transform: Transform, y_transform: Transform, **kwargs
@@ -265,8 +267,6 @@ class BlendedGenericTransform(_BlendedMixin, Transform):
265267
def contains_branch(self, other: Transform) -> Literal[False]: ...
266268
@property
267269
def is_affine(self) -> bool: ...
268-
@property
269-
def has_inverse(self) -> bool: ...
270270

271271
class BlendedAffine2D(_BlendedMixin, Affine2DBase):
272272
def __init__(
@@ -279,8 +279,6 @@ def blended_transform_factory(
279279

280280
class CompositeGenericTransform(Transform):
281281
pass_through: bool
282-
input_dims: int | None
283-
output_dims: int | None
284282
def __init__(self, a: Transform, b: Transform, **kwargs) -> None: ...
285283

286284
class CompositeAffine2D(Affine2DBase):

0 commit comments

Comments
 (0)