Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 91d2c54

Browse filesBrowse files
committed
[TYP] Change typing for texts to StrLike
1 parent dce9ea4 commit 91d2c54
Copy full SHA for 91d2c54

14 files changed

+72
-62
lines changed

‎lib/matplotlib/artist.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/artist.pyi
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ from .figure import Figure, SubFigure
44
from .path import Path
55
from .patches import Patch
66
from .patheffects import AbstractPathEffect
7+
from .text import Text
78
from .transforms import (
89
BboxBase,
910
Bbox,
1011
Transform,
1112
TransformedPatchPath,
1213
TransformedPath,
1314
)
15+
from .typing import StrLike
1416

1517
import numpy as np
1618

@@ -117,8 +119,8 @@ class Artist:
117119
def set_visible(self, b: bool) -> None: ...
118120
def set_animated(self, b: bool) -> None: ...
119121
def set_in_layout(self, in_layout: bool) -> None: ...
120-
def get_label(self) -> object: ...
121-
def set_label(self, s: object) -> None: ...
122+
def get_label(self) -> str | Text | None: ...
123+
def set_label(self, s: StrLike | None) -> None: ...
122124
def get_zorder(self) -> float: ...
123125
def set_zorder(self, level: float) -> None: ...
124126
@property

‎lib/matplotlib/axes/_axes.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.pyi
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ from collections.abc import Callable, Sequence
3434
from typing import Any, Literal, overload
3535
import numpy as np
3636
from numpy.typing import ArrayLike
37-
from matplotlib.typing import ColorType, MarkerType, LineStyleType
37+
from matplotlib.typing import ColorType, MarkerType, LineStyleType, StrLike
3838

3939
class Axes(_AxesBase):
4040
def get_title(self, loc: Literal["left", "center", "right"] = ...) -> str: ...
4141
def set_title(
4242
self,
43-
label: str,
43+
label: StrLike,
4444
fontdict: dict[str, Any] | None = ...,
4545
loc: Literal["left", "center", "right"] | None = ...,
4646
pad: float | None = ...,
@@ -111,13 +111,13 @@ class Axes(_AxesBase):
111111
self,
112112
x: float,
113113
y: float,
114-
s: str,
114+
s: StrLike,
115115
fontdict: dict[str, Any] | None = ...,
116116
**kwargs
117117
) -> Text: ...
118118
def annotate(
119119
self,
120-
text: str,
120+
text: StrLike,
121121
xy: tuple[float, float],
122122
xytext: tuple[float, float] | None = ...,
123123
xycoords: str
@@ -164,7 +164,7 @@ class Axes(_AxesBase):
164164
xmax: float | ArrayLike,
165165
colors: ColorType | Sequence[ColorType] | None = ...,
166166
linestyles: LineStyleType = ...,
167-
label: str = ...,
167+
label: StrLike = ...,
168168
*,
169169
data=...,
170170
**kwargs
@@ -176,7 +176,7 @@ class Axes(_AxesBase):
176176
ymax: float | ArrayLike,
177177
colors: ColorType | Sequence[ColorType] | None = ...,
178178
linestyles: LineStyleType = ...,
179-
label: str = ...,
179+
label: StrLike = ...,
180180
*,
181181
data=...,
182182
**kwargs
@@ -289,7 +289,7 @@ class Axes(_AxesBase):
289289
markerfmt: str | None = ...,
290290
basefmt: str | None = ...,
291291
bottom: float = ...,
292-
label: str | None = ...,
292+
label: StrLike | None = ...,
293293
orientation: Literal["vertical", "horizontal"] = ...,
294294
data=...,
295295
) -> StemContainer: ...
@@ -443,7 +443,7 @@ class Axes(_AxesBase):
443443
self, x: float, y: float, dx: float, dy: float, **kwargs
444444
) -> FancyArrow: ...
445445
def quiverkey(
446-
self, Q: Quiver, X: float, Y: float, U: float, label: str, **kwargs
446+
self, Q: Quiver, X: float, Y: float, U: float, label: StrLike, **kwargs
447447
) -> QuiverKey: ...
448448
def quiver(self, *args, data=..., **kwargs) -> Quiver: ...
449449
def barbs(self, *args, data=..., **kwargs) -> Barbs: ...
@@ -549,7 +549,7 @@ class Axes(_AxesBase):
549549
rwidth: float | None = ...,
550550
log: bool = ...,
551551
color: ColorType | Sequence[ColorType] | None = ...,
552-
label: str | Sequence[str] | None = ...,
552+
label: StrLike | Sequence[StrLike] | None = ...,
553553
stacked: bool = ...,
554554
*,
555555
data=...,

‎lib/matplotlib/axes/_base.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_base.pyi
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ from cycler import Cycler
2727
import numpy as np
2828
from numpy.typing import ArrayLike
2929
from typing import Any, Literal, TypeVar, overload
30-
from matplotlib.typing import ColorType
30+
from matplotlib.typing import ColorType, StrLike
3131

3232
_T = TypeVar("_T", bound=Artist)
3333

@@ -305,7 +305,7 @@ class _AxesBase(martist.Artist):
305305
def get_xlabel(self) -> str: ...
306306
def set_xlabel(
307307
self,
308-
xlabel: str,
308+
xlabel: StrLike,
309309
fontdict: dict[str, Any] | None = ...,
310310
labelpad: float | None = ...,
311311
*,
@@ -331,7 +331,7 @@ class _AxesBase(martist.Artist):
331331
def get_ylabel(self) -> str: ...
332332
def set_ylabel(
333333
self,
334-
ylabel: str,
334+
ylabel: StrLike,
335335
fontdict: dict[str, Any] | None = ...,
336336
labelpad: float | None = ...,
337337
*,

‎lib/matplotlib/axis.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/axis.pyi
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ from matplotlib.lines import Line2D
1313
from matplotlib.text import Text
1414
from matplotlib.ticker import Locator, Formatter
1515
from matplotlib.transforms import Transform, Bbox
16-
from matplotlib.typing import ColorType
16+
from matplotlib.typing import ColorType, StrLike
1717

1818

1919
GRIDLINE_INTERPOLATION_STEPS: int
@@ -211,7 +211,7 @@ class Axis(martist.Artist):
211211
def set_units(self, u) -> None: ...
212212
def get_units(self): ...
213213
def set_label_text(
214-
self, label: str, fontdict: dict[str, Any] | None = ..., **kwargs
214+
self, label: StrLike, fontdict: dict[str, Any] | None = ..., **kwargs
215215
) -> Text: ...
216216
def set_major_formatter(
217217
self, formatter: Formatter | str | Callable[[float, float], str]

‎lib/matplotlib/colorbar.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/colorbar.pyi
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import numpy as np
1010
from numpy.typing import ArrayLike
1111
from collections.abc import Sequence
1212
from typing import Any, Literal, overload
13-
from .typing import ColorType
13+
from .typing import ColorType, StrLike
1414

1515
class _ColorbarSpine(mspines.Spines):
1616
def __init__(self, axes: Axes): ...
@@ -59,7 +59,7 @@ class Colorbar:
5959
drawedges: bool = ...,
6060
extendfrac: Literal["auto"] | float | Sequence[float] | None = ...,
6161
extendrect: bool = ...,
62-
label: str = ...,
62+
label: StrLike = ...,
6363
location: Literal["left", "right", "top", "bottom"] | None = ...
6464
) -> None: ...
6565
@property
@@ -108,7 +108,7 @@ class Colorbar:
108108
) -> None: ...
109109
def minorticks_on(self) -> None: ...
110110
def minorticks_off(self) -> None: ...
111-
def set_label(self, label: str, *, loc: str | None = ..., **kwargs) -> None: ...
111+
def set_label(self, label: StrLike, *, loc: str | None = ..., **kwargs) -> None: ...
112112
def set_alpha(self, alpha: float | np.ndarray) -> None: ...
113113
def remove(self) -> None: ...
114114
def drag_pan(self, button: Any, key: Any, x: float, y: float) -> None: ...

‎lib/matplotlib/offsetbox.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/offsetbox.pyi
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ from matplotlib.font_manager import FontProperties
77
from matplotlib.image import BboxImage
88
from matplotlib.patches import FancyArrowPatch, FancyBboxPatch
99
from matplotlib.transforms import Bbox, BboxBase, Transform
10+
from matplotlib.typing import StrLike
1011

1112
import numpy as np
1213
from numpy.typing import ArrayLike
@@ -117,12 +118,12 @@ class TextArea(OffsetBox):
117118
offset_transform: Transform
118119
def __init__(
119120
self,
120-
s: str,
121+
s: StrLike,
121122
*,
122123
textprops: dict[str, Any] | None = ...,
123124
multilinebaseline: bool = ...,
124125
) -> None: ...
125-
def set_text(self, s: str) -> None: ...
126+
def set_text(self, s: StrLike) -> None: ...
126127
def get_text(self) -> str: ...
127128
def set_multilinebaseline(self, t: bool) -> None: ...
128129
def get_multilinebaseline(self) -> bool: ...
@@ -180,7 +181,7 @@ class AnchoredText(AnchoredOffsetbox):
180181
txt: TextArea
181182
def __init__(
182183
self,
183-
s: str,
184+
s: StrLike,
184185
loc: str,
185186
*,
186187
pad: float = ...,

‎lib/matplotlib/pyplot.py

Copy file name to clipboardExpand all lines: lib/matplotlib/pyplot.py
+12-11Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@
119119
from matplotlib.quiver import Barbs, Quiver, QuiverKey
120120
from matplotlib.scale import ScaleBase
121121
from matplotlib.transforms import Transform, Bbox
122-
from matplotlib.typing import ColorType, LineStyleType, MarkerType, HashableList
122+
from matplotlib.typing import (ColorType, HashableList, LineStyleType, MarkerType,
123+
StrLike)
123124
from matplotlib.widgets import SubplotTool
124125

125126
_P = ParamSpec('_P')
@@ -2640,7 +2641,7 @@ def angle_spectrum(
26402641
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
26412642
@_copy_docstring_and_deprecators(Axes.annotate)
26422643
def annotate(
2643-
text: str,
2644+
text: StrLike,
26442645
xy: tuple[float, float],
26452646
xytext: tuple[float, float] | None = None,
26462647
xycoords: str
@@ -3222,7 +3223,7 @@ def hist(
32223223
rwidth: float | None = None,
32233224
log: bool = False,
32243225
color: ColorType | Sequence[ColorType] | None = None,
3225-
label: str | Sequence[str] | None = None,
3226+
label: StrLike | Sequence[StrLike] | None = None,
32263227
stacked: bool = False,
32273228
*,
32283229
data=None,
@@ -3315,7 +3316,7 @@ def hlines(
33153316
xmax: float | ArrayLike,
33163317
colors: ColorType | Sequence[ColorType] | None = None,
33173318
linestyles: LineStyleType = "solid",
3318-
label: str = "",
3319+
label: StrLike = "",
33193320
*,
33203321
data=None,
33213322
**kwargs,
@@ -3670,7 +3671,7 @@ def quiver(*args, data=None, **kwargs) -> Quiver:
36703671
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
36713672
@_copy_docstring_and_deprecators(Axes.quiverkey)
36723673
def quiverkey(
3673-
Q: Quiver, X: float, Y: float, U: float, label: str, **kwargs
3674+
Q: Quiver, X: float, Y: float, U: float, label: StrLike, **kwargs
36743675
) -> QuiverKey:
36753676
return gca().quiverkey(Q, X, Y, U, label, **kwargs)
36763677

@@ -3827,7 +3828,7 @@ def stem(
38273828
markerfmt: str | None = None,
38283829
basefmt: str | None = None,
38293830
bottom: float = 0,
3830-
label: str | None = None,
3831+
label: StrLike | None = None,
38313832
orientation: Literal["vertical", "horizontal"] = "vertical",
38323833
data=None,
38333834
) -> StemContainer:
@@ -3951,7 +3952,7 @@ def table(
39513952
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
39523953
@_copy_docstring_and_deprecators(Axes.text)
39533954
def text(
3954-
x: float, y: float, s: str, fontdict: dict[str, Any] | None = None, **kwargs
3955+
x: float, y: float, s: StrLike, fontdict: dict[str, Any] | None = None, **kwargs
39553956
) -> Text:
39563957
return gca().text(x, y, s, fontdict=fontdict, **kwargs)
39573958

@@ -4077,7 +4078,7 @@ def vlines(
40774078
ymax: float | ArrayLike,
40784079
colors: ColorType | Sequence[ColorType] | None = None,
40794080
linestyles: LineStyleType = "solid",
4080-
label: str = "",
4081+
label: StrLike = "",
40814082
*,
40824083
data=None,
40834084
**kwargs,
@@ -4128,7 +4129,7 @@ def sci(im: ScalarMappable) -> None:
41284129
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
41294130
@_copy_docstring_and_deprecators(Axes.set_title)
41304131
def title(
4131-
label: str,
4132+
label: StrLike,
41324133
fontdict: dict[str, Any] | None = None,
41334134
loc: Literal["left", "center", "right"] | None = None,
41344135
pad: float | None = None,
@@ -4142,7 +4143,7 @@ def title(
41424143
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
41434144
@_copy_docstring_and_deprecators(Axes.set_xlabel)
41444145
def xlabel(
4145-
xlabel: str,
4146+
xlabel: StrLike,
41464147
fontdict: dict[str, Any] | None = None,
41474148
labelpad: float | None = None,
41484149
*,
@@ -4157,7 +4158,7 @@ def xlabel(
41574158
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
41584159
@_copy_docstring_and_deprecators(Axes.set_ylabel)
41594160
def ylabel(
4160-
ylabel: str,
4161+
ylabel: StrLike,
41614162
fontdict: dict[str, Any] | None = None,
41624163
labelpad: float | None = None,
41634164
*,

‎lib/matplotlib/quiver.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/quiver.pyi
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import numpy as np
1010
from numpy.typing import ArrayLike
1111
from collections.abc import Sequence
1212
from typing import Any, Literal, overload
13-
from matplotlib.typing import ColorType
13+
from matplotlib.typing import ColorType, StrLike
1414

1515
class QuiverKey(martist.Artist):
1616
halign: dict[Literal["N", "S", "E", "W"], Literal["left", "center", "right"]]
@@ -23,7 +23,7 @@ class QuiverKey(martist.Artist):
2323
angle: float
2424
coord: Literal["axes", "figure", "data", "inches"]
2525
color: ColorType | None
26-
label: str
26+
label: StrLike
2727
labelpos: Literal["N", "S", "E", "W"]
2828
labelcolor: ColorType | None
2929
fontproperties: dict[str, Any]
@@ -36,7 +36,7 @@ class QuiverKey(martist.Artist):
3636
X: float,
3737
Y: float,
3838
U: float,
39-
label: str,
39+
label: StrLike,
4040
*,
4141
angle: float = ...,
4242
coordinates: Literal["axes", "figure", "data", "inches"] = ...,

‎lib/matplotlib/sankey.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/sankey.pyi
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from matplotlib.axes import Axes
2+
from matplotlib.typing import StrLike
23

34
from collections.abc import Callable, Iterable
45
from typing import Any
@@ -46,7 +47,7 @@ class Sankey:
4647
) -> None: ...
4748
def add(
4849
self,
49-
patchlabel: str = ...,
50+
patchlabel: StrLike = ...,
5051
flows: Iterable[float] | None = ...,
5152
orientations: Iterable[int] | None = ...,
5253
labels: str | Iterable[str | None] = ...,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.