Skip to content

Commit d6d1588

Browse files
committed
Resolve some typing todos
1 parent 6276c39 commit d6d1588

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

lib/matplotlib/axes/_axes.pyi

+10-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ from matplotlib._typing import Color, LineStyleType, MarkerType
3232

3333
import datetime
3434
import PIL
35-
from typing import Any, Callable, Literal, Sequence, Type
35+
from typing import Any, Callable, Literal, Sequence, Type, overload
3636
import numpy as np
3737
from numpy.typing import ArrayLike
3838

@@ -53,8 +53,15 @@ class Axes(_AxesBase):
5353
) -> tuple[list[Artist], list[Any]]: ...
5454
legend_: Legend
5555

56-
# TODO: legend signatures?
57-
def legend(self, *args, **kwargs) -> Legend: ...
56+
@overload
57+
def legend(self) -> Legend: ...
58+
@overload
59+
def legend(self, handles: Sequence[Artist], labels: Sequence[str]) -> Legend: ...
60+
@overload
61+
def legend(self, *, handles: Sequence[Artist]) -> Legend: ...
62+
@overload
63+
def legend(self, labels: Sequence[str]) -> Legend: ...
64+
5865
def inset_axes(
5966
self,
6067
bounds: tuple[float, float, float, float],
@@ -260,8 +267,6 @@ class Axes(_AxesBase):
260267
yrange: tuple[float, float],
261268
**kwargs
262269
) -> BrokenBarHCollection: ...
263-
264-
# TODO, expand out kwargs into override
265270
def stem(
266271
self,
267272
*args: ArrayLike | str,

lib/matplotlib/projections/geo.pyi

-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ class GeoAxes(Axes):
5454
Literal["center", "top", "bottom", "baseline", "center_baseline"],
5555
Literal["center", "left", "right"],
5656
]: ...
57-
# TODO adust set_yscale/set_xscale once Axes stubs written
58-
def set_yscale(self, *args, **kwargs) -> None: ... # type: ignore
5957
def set_xlim(self, *args, **kwargs) -> tuple[float, float]: ...
6058
def set_ylim(self, *args, **kwargs) -> tuple[float, float]: ...
6159
def format_coord(self, lon: float, lat: float) -> str: ...

lib/matplotlib/projections/polar.pyi

+1-4
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ class _AxisWrapper:
5353

5454
class ThetaLocator(mticker.Locator):
5555
base: mticker.Locator
56-
# FIXME: once ticker.pyi is done
57-
axis: _AxisWrapper | None # type: ignore
56+
axis: _AxisWrapper | None
5857
def __init__(self, base: mticker.Locator) -> None: ...
5958

6059
class ThetaTick(maxis.XTick):
@@ -165,8 +164,6 @@ class PolarAxes(Axes):
165164
): ...
166165
def get_rlabel_position(self) -> float: ...
167166
def set_rlabel_position(self, value: float) -> None: ...
168-
# TODO fix signature onces axes stubs are complete
169-
def set_yscale(self, *args, **kwargs) -> None: ... # type: ignore
170167
def set_rscale(self, *args, **kwargs) -> None: ...
171168
def set_rticks(self, *args, **kwargs) -> None: ...
172169
def set_thetagrids(

lib/matplotlib/ticker.pyi

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from matplotlib.axis import Axis
22
from matplotlib.transforms import Transform
3+
from matplotlib.projections.polar import _AxisWrapper
34

45
from typing import Any, Callable, Sequence, Literal
56
import numpy as np
@@ -15,7 +16,7 @@ class _DummyAxis:
1516
def get_tick_space(self) -> int: ...
1617

1718
class TickHelper:
18-
axis: None | Axis | _DummyAxis
19+
axis: None | Axis | _DummyAxis | _AxisWrapper
1920
def set_axis(self, axis: Axis | _DummyAxis | None) -> None: ...
2021
def create_dummy_axis(self, **kwargs) -> None: ...
2122

0 commit comments

Comments
 (0)