8000 Fix return value of Text.update · matplotlib/matplotlib@8c689fa · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 8c689fa

Browse files
committed
Fix return value of Text.update
The return value of `Artist.update` is a list of the results from calling the setters. However, while `Text` overrides `update`, it does not preserve that return value.
1 parent d073a36 commit 8c689fa

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lib/matplotlib/text.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,17 +193,19 @@ def _reset_visual_defaults(
193193

194194
def update(self, kwargs):
195195
# docstring inherited
196+
ret = []
196197
kwargs = cbook.normalize_kwargs(kwargs, Text)
197198
sentinel = object() # bbox can be None, so use another sentinel.
198199
# Update fontproperties first, as it has lowest priority.
199200
fontproperties = kwargs.pop("fontproperties", sentinel)
200201
if fontproperties is not sentinel:
201-
self.set_fontproperties(fontproperties)
202+
ret.append(self.set_fontproperties(fontproperties))
202203
# Update bbox last, as it depends on font properties.
203204
bbox = kwargs.pop("bbox", sentinel)
204-
super().update(kwargs)
205+
ret.extend(super().update(kwargs))
205206
if bbox is not sentinel:
206-
self.set_bbox(bbox)
207+
ret.append(self.set_bbox(bbox))
208+
return ret
207209

208210
def __getstate__(self):
209211
d = super().__getstate__()

lib/matplotlib/text.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Text(Artist):
4343
antialiased: bool | None = ...,
4444
**kwargs
4545
) -> None: ...
46-
def update(self, kwargs: dict[str, Any]) -> None: ...
46+
def update(self, kwargs: dict[str, Any]) -> list[Any]: ...
4747
def get_rotation(self) -> float: ...
4848
def get_transform_rotates_text(self) -> bool: ...
4949
def set_rotation_mode(self, m: None | Literal["default", "anchor"]) -> None: ...

0 commit comments

Comments
 (0)
0