50
50
import sys
51
51
import threading
52
52
import time
53
- from typing import TYPE_CHECKING , cast , overload
53
+ from typing import IO , TYPE_CHECKING , cast , overload
54
54
55
55
from cycler import cycler # noqa: F401
56
56
import matplotlib
100
100
import matplotlib .backend_bases
101
101
from matplotlib .axis import Tick
102
102
from matplotlib .axes ._base import _AxesBase
103
- from matplotlib .backend_bases import Event
103
+ from matplotlib .backend_bases import (
104
+ CloseEvent ,
105
+ DrawEvent ,
106
+ KeyEvent ,
107
+ MouseEvent ,
108
+ PickEvent ,
109
+ ResizeEvent ,
110
+ )
104
111
from matplotlib .cm import ScalarMappable
105
112
from matplotlib .contour import ContourSet , QuadContourSet
106
113
from matplotlib .collections import (
126
133
from matplotlib .quiver import Barbs , Quiver , QuiverKey
127
134
from matplotlib .scale import ScaleBase
128
135
from matplotlib .typing import (
136
+ CloseEventType ,
129
137
ColorType ,
130
138
CoordsType ,
139
+ DrawEventType ,
131
140
HashableList ,
141
+ KeyEventType ,
132
142
LineStyleType ,
133
143
MarkerType ,
144
+ MouseEventType ,
145
+ PickEventType ,
146
+ ResizeEventType ,
147
+ LogLevel
134
148
)
135
149
from matplotlib .widgets import SubplotTool
136
150
@@ -338,8 +352,8 @@ def uninstall_repl_displayhook() -> None:
338
352
339
353
# Ensure this appears in the pyplot docs.
340
354
@_copy_docstring_and_deprecators (matplotlib .set_loglevel )
341
- def set_loglevel (* args , ** kwargs ) -> None :
342
- return matplotlib .set_loglevel (* args , ** kwargs )
355
+ def set_loglevel (level : LogLevel ) -> None :
356
+ return matplotlib .set_loglevel (level )
343
357
344
358
345
359
@_copy_docstring_and_deprecators (Artist .findobj )
@@ -1175,8 +1189,32 @@ def get_current_fig_manager() -> FigureManagerBase | None:
1175
1189
return gcf ().canvas .manager
1176
1190
1177
1191
1192
+ @overload
1193
+ def connect (s : MouseEventType , func : Callable [[MouseEvent ], Any ]) -> int : ...
1194
+
1195
+
1196
+ @overload
1197
+ def connect (s : KeyEventType , func : Callable [[KeyEvent ], Any ]) -> int : ...
1198
+
1199
+
1200
+ @overload
1201
+ def connect (s : PickEventType , func : Callable [[PickEvent ], Any ]) -> int : ...
1202
+
1203
+
1204
+ @overload
1205
+ def connect (s : ResizeEventType , func : Callable [[ResizeEvent ], Any ]) -> int : ...
1206
+
1207
+
1208
+ @overload
1209
+ def connect (s : CloseEventType , func : Callable [[CloseEvent ], Any ]) -> int : ...
1210
+
1211
+
1212
+ @overload
1213
+ def connect (s : DrawEventType , func : Callable [[DrawEvent ], Any ]) -> int : ...
1214
+
1215
+
1178
1216
@_copy_docstring_and_deprecators (FigureCanvasBase .mpl_connect )
1179
- def connect (s : str , func : Callable [[ Event ], Any ] ) -> int :
1217
+ def connect (s , func ) -> int :
1180
1218
return gcf ().canvas .mpl_connect (s , func )
1181
1219
1182
1220
@@ -1259,11 +1297,11 @@ def draw() -> None:
1259
1297
1260
1298
1261
1299
@_copy_docstring_and_deprecators (Figure .savefig )
1262
- def savefig (* args , ** kwargs ) -> None :
1300
+ def savefig (fname : str | os . PathLike | IO , ** kwargs ) -> None :
1263
1301
fig = gcf ()
1264
1302
# savefig default implementation has no return, so mypy is unhappy
1265
1303
# presumably this is here because subclasses can return?
1266
- res = fig .savefig (* args , ** kwargs ) # type: ignore[func-returns-value]
1304
+ res = fig .savefig (fname , ** kwargs ) # type: ignore[func-returns-value]
1267
1305
fig .canvas .draw_idle () # Need this if 'transparent=True', to reset colors.
1268
1306
return res
1269
1307
@@ -4718,4 +4756,4 @@ def nipy_spectral() -> None:
4718
4756
This changes the default colormap as well as the colormap of the current
4719
4757
image if there is one. See ``help(colormaps)`` for more information.
4720
4758
"""
4721
- set_cmap ("nipy_spectral" )
4759
+ set_cmap ("nipy_spectral" )
0 commit comments