|
50 | 50 | import sys |
51 | 51 | import threading |
52 | 52 | import time |
53 | | -from typing import IO, TYPE_CHECKING, cast, overload |
| 53 | +from typing import 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 ( |
104 | | - CloseEvent, |
105 | | - DrawEvent, |
106 | | - KeyEvent, |
107 | | - MouseEvent, |
108 | | - PickEvent, |
109 | | - ResizeEvent, |
110 | | - ) |
| 103 | + from matplotlib.backend_bases import Event |
111 | 104 | from matplotlib.cm import ScalarMappable |
112 | 105 | from matplotlib.contour import ContourSet, QuadContourSet |
113 | 106 | from matplotlib.collections import ( |
|
133 | 126 | from matplotlib.quiver import Barbs, Quiver, QuiverKey |
134 | 127 | from matplotlib.scale import ScaleBase |
135 | 128 | from matplotlib.typing import ( |
136 | | - CloseEventType, |
137 | 129 | ColorType, |
138 | 130 | CoordsType, |
139 | | - DrawEventType, |
140 | 131 | HashableList, |
141 | | - KeyEventType, |
142 | 132 | LineStyleType, |
143 | 133 | MarkerType, |
144 | | - MouseEventType, |
145 | | - PickEventType, |
146 | | - ResizeEventType, |
147 | | - RcGroupType, |
148 | 134 | ) |
149 | 135 | from matplotlib.widgets import SubplotTool |
150 | 136 |
|
@@ -352,8 +338,8 @@ def uninstall_repl_displayhook() -> None: |
352 | 338 |
|
353 | 339 | # Ensure this appears in the pyplot docs. |
354 | 340 | @_copy_docstring_and_deprecators(matplotlib.set_loglevel) |
355 | | -def set_loglevel(level: str) -> None: |
356 | | - return matplotlib.set_loglevel(level) |
| 341 | +def set_loglevel(*args, **kwargs) -> None: |
| 342 | + return matplotlib.set_loglevel(*args, **kwargs) |
357 | 343 |
|
358 | 344 |
|
359 | 345 | @_copy_docstring_and_deprecators(Artist.findobj) |
@@ -787,9 +773,10 @@ def pause(interval: float) -> None: |
787 | 773 |
|
788 | 774 |
|
789 | 775 | @_copy_docstring_and_deprecators(matplotlib.rc) |
790 | | -def rc(group: RcGroupType, **kwargs) -> None: |
| 776 | +def rc(group: str, **kwargs) -> None: |
791 | 777 | matplotlib.rc(group, **kwargs) |
792 | 778 |
|
| 779 | + |
793 | 780 | @_copy_docstring_and_deprecators(matplotlib.rc_context) |
794 | 781 | def rc_context( |
795 | 782 | rc: dict[str, Any] | None = None, |
@@ -1188,32 +1175,8 @@ def get_current_fig_manager() -> FigureManagerBase | None: |
1188 | 1175 | return gcf().canvas.manager |
1189 | 1176 |
|
1190 | 1177 |
|
1191 | | -@overload |
1192 | | -def connect(s: MouseEventType, func: Callable[[MouseEvent], Any]) -> int: ... |
1193 | | - |
1194 | | - |
1195 | | -@overload |
1196 | | -def connect(s: KeyEventType, func: Callable[[KeyEvent], Any]) -> int: ... |
1197 | | - |
1198 | | - |
1199 | | -@overload |
1200 | | -def connect(s: PickEventType, func: Callable[[PickEvent], Any]) -> int: ... |
1201 | | - |
1202 | | - |
1203 | | -@overload |
1204 | | -def connect(s: ResizeEventType, func: Callable[[ResizeEvent], Any]) -> int: ... |
1205 | | - |
1206 | | - |
1207 | | -@overload |
1208 | | -def connect(s: CloseEventType, func: Callable[[CloseEvent], Any]) -> int: ... |
1209 | | - |
1210 | | - |
1211 | | -@overload |
1212 | | -def connect(s: DrawEventType, func: Callable[[DrawEvent], Any]) -> int: ... |
1213 | | - |
1214 | | - |
1215 | 1178 | @_copy_docstring_and_deprecators(FigureCanvasBase.mpl_connect) |
1216 | | -def connect(s, func) -> int: |
| 1179 | +def connect(s: str, func: Callable[[Event], Any]) -> int: |
1217 | 1180 | return gcf().canvas.mpl_connect(s, func) |
1218 | 1181 |
|
1219 | 1182 |
|
@@ -1296,11 +1259,11 @@ def draw() -> None: |
1296 | 1259 |
|
1297 | 1260 |
|
1298 | 1261 | @_copy_docstring_and_deprecators(Figure.savefig) |
1299 | | -def savefig(fname: str | os.PathLike | IO, **kwargs) -> None: |
| 1262 | +def savefig(*args, **kwargs) -> None: |
1300 | 1263 | fig = gcf() |
1301 | 1264 | # savefig default implementation has no return, so mypy is unhappy |
1302 | 1265 | # presumably this is here because subclasses can return? |
1303 | | - res = fig.savefig(fname, **kwargs) # type: ignore[func-returns-value] |
| 1266 | + res = fig.savefig(*args, **kwargs) # type: ignore[func-returns-value] |
1304 | 1267 | fig.canvas.draw_idle() # Need this if 'transparent=True', to reset colors. |
1305 | 1268 | return res |
1306 | 1269 |
|
|
0 commit comments