Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Sign up
Appearance settings

Commit8df07c3

Browse files
committed
[TYP] Change typing for texts to Any/object
1 parentdce9ea4 commit8df07c3

File tree

9 files changed

+29
-24
lines changed

9 files changed

+29
-24
lines changed

‎lib/matplotlib/artist.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ from .transforms import (
1111
TransformedPatchPath,
1212
TransformedPath,
1313
)
14+
from .typingimportStrLike
1415

1516
importnumpyasnp
1617

@@ -117,8 +118,8 @@ class Artist:
117118
defset_visible(self,b:bool)->None: ...
118119
defset_animated(self,b:bool)->None: ...
119120
defset_in_layout(self,in_layout:bool)->None: ...
120-
defget_label(self)->object: ...
121-
defset_label(self,s:object)->None: ...
121+
defget_label(self)->str|None: ...
122+
defset_label(self,s:StrLike)->None: ...
122123
defget_zorder(self)->float: ...
123124
defset_zorder(self,level:float)->None: ...
124125
@property

‎lib/matplotlib/axes/_axes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,8 @@ def text(self, x, y, s, fontdict=None, **kwargs):
644644
coordinates. The coordinate system can be changed using the
645645
*transform* parameter.
646646
647-
s :str
648-
The text.
647+
s :object
648+
The text. Will be converted to `str`, see `.Text.set_text`.
649649
650650
fontdict : dict, default: None
651651

‎lib/matplotlib/axes/_axes.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class Axes(_AxesBase):
111111
self,
112112
x:float,
113113
y:float,
114-
s:str,
114+
s:Any,
115115
fontdict:dict[str,Any]|None= ...,
116116
**kwargs
117117
)->Text: ...

‎lib/matplotlib/offsetbox.pyi

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ from matplotlib.font_manager import FontProperties
77
frommatplotlib.imageimportBboxImage
88
frommatplotlib.patchesimportFancyArrowPatch,FancyBboxPatch
99
frommatplotlib.transformsimportBbox,BboxBase,Transform
10+
frommatplotlib.typingimportStrLike
1011

1112
importnumpyasnp
1213
fromnumpy.typingimportArrayLike
@@ -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-
defset_text(self,s:str)->None: ...
126+
defset_text(self,s:StrLike)->None: ...
126127
defget_text(self)->str: ...
127128
defset_multilinebaseline(self,t:bool)->None: ...
128129
defget_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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3951,7 +3951,7 @@ def table(
39513951
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
39523952
@_copy_docstring_and_deprecators(Axes.text)
39533953
deftext(
3954-
x:float,y:float,s:str,fontdict:dict[str,Any]|None=None,**kwargs
3954+
x:float,y:float,s:Any,fontdict:dict[str,Any]|None=None,**kwargs
39553955
)->Text:
39563956
returngca().text(x,y,s,fontdict=fontdict,**kwargs)
39573957

‎lib/matplotlib/table.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ def __init__(self, xy, width, height, *,
7676
The cell facecolor.
7777
fill : bool, default: True
7878
Whether the cell background is filled.
79-
text : str,optional
79+
text : str,default: ''
8080
The cell text.
81-
loc : {'right', 'center', 'left'}
81+
loc : {'center', 'left', 'right'}, default: 'right'
8282
The alignment of the text within the cell.
8383
fontproperties : dict, optional
8484
A dict defining the font properties of the text. Supported keys and
8585
values are the keyword arguments accepted by `.FontProperties`.
8686
visible_edges : {'closed', 'open', 'horizontal', 'vertical'} or\
87-
substring of 'BRTL'
87+
substring of 'BRTL', default: 'closed'
8888
The cell edges to be drawn with a line: a substring of 'BRTL'
8989
(bottom, right, top, left), or one of 'open' (no edges drawn),
9090
'closed' (all edges drawn), 'horizontal' (bottom and top),
@@ -684,7 +684,7 @@ def table(ax,
684684
cellColours : 2D list of colors, optional
685685
The background colors of the cells.
686686
687-
cellLoc : {'right', 'center', 'left'}
687+
cellLoc : {'center', 'left', 'right'}, default: 'right'
688688
The alignment of the text within the cells.
689689
690690
colWidths : list of float, optional
@@ -697,7 +697,7 @@ def table(ax,
697697
rowColours : list of colors, optional
698698
The colors of the row header cells.
699699
700-
rowLoc : {'left', 'center', 'right'}
700+
rowLoc : {'center', 'left', 'right'}, default: 'center'
701701
The text alignment of the row header cells.
702702
703703
colLabels : list of str, optional
@@ -706,7 +706,7 @@ def table(ax,
706706
colColours : list of colors, optional
707707
The colors of the column header cells.
708708
709-
colLoc : {'center', 'left', 'right'}
709+
colLoc : {'center', 'left', 'right'}, default: 'center'
710710
The text alignment of the column header cells.
711711
712712
loc : str, default: 'bottom'
@@ -717,9 +717,9 @@ def table(ax,
717717
A bounding box to draw the table into. If this is not *None*, this
718718
overrides *loc*.
719719
720-
edges : {'closed', 'open', 'horizontal', 'vertical'} or substring of 'BRTL'
721-
The cell edges to be drawn with a line. See also
722-
`~.Cell.visible_edges`.
720+
edges : {'closed', 'open', 'horizontal', 'vertical'} or substring of 'BRTL',\
721+
default: 'closed'
722+
The cell edges to be drawn with a line. See also`~.Cell.visible_edges`.
723723
724724
Returns
725725
-------

‎lib/matplotlib/table.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from .patches import Rectangle
55
from .pathimportPath
66
from .textimportText
77
from .transformsimportBbox
8-
from .typingimportColorType
8+
from .typingimportColorType,StrLike
99

1010
fromcollections.abcimportSequence
1111
fromtypingimportAny,Literal
@@ -21,7 +21,7 @@ class Cell(Rectangle):
2121
edgecolor:ColorType= ...,
2222
facecolor:ColorType= ...,
2323
fill:bool= ...,
24-
text:str= ...,
24+
text:StrLike= ...,
2525
loc:Literal["left","center","right"]= ...,
2626
fontproperties:dict[str,Any]|None= ...,
2727
visible_edges:str|None= ...
@@ -68,7 +68,7 @@ class Table(Artist):
6868

6969
deftable(
7070
ax:Axes,
71-
cellText:Sequence[Sequence[str]]|None= ...,
71+
cellText:Sequence[Sequence[Any]]|None= ...,
7272
cellColours:Sequence[Sequence[ColorType]]|None= ...,
7373
cellLoc:Literal["left","center","right"]= ...,
7474
colWidths:Sequence[float]|None= ...,

‎lib/matplotlib/text.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ from .transforms import (
1616

1717
fromcollections.abcimportCallable,Iterable
1818
fromtypingimportAny,Literal
19-
from .typingimportColorType
19+
from .typingimportColorType,StrLike
2020

2121
classText(Artist):
2222
zorder:float
2323
def__init__(
2424
self,
2525
x:float= ...,
2626
y:float= ...,
27-
text:Any= ...,
27+
text:StrLike= ...,
2828
*,
2929
color:ColorType|None= ...,
3030
verticalalignment:Literal[
@@ -97,7 +97,7 @@ class Text(Artist):
9797
defset_verticalalignment(
9898
self,align:Literal["bottom","baseline","center","center_baseline","top"]
9999
)->None: ...
100-
defset_text(self,s:Any)->None: ...
100+
defset_text(self,s:StrLike)->None: ...
101101
defset_fontproperties(self,fp:FontProperties|str|Path|None)->None: ...
102102
defset_usetex(self,usetex:bool|None)->None: ...
103103
defget_usetex(self)->bool: ...

‎lib/matplotlib/typing.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,6 @@
5858
_HT=TypeVar("_HT",bound=Hashable)
5959
HashableList=list[Union[_HT,"HashableList[_HT]"]]
6060
"""A nested list of Hashable values."""
61+
62+
# Many methods accept arbitrary objects which are then converted to strings
63+
StrLike=Any

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp