Skip to content

Commit 4cefc05

Browse files
Relax type hints for xy and xytext in annotate (matplotlib#31428)
* Relax type hints for xy and xytext in annotate The current type hints for xy and xytext are too strict (tuple[float, float]) compared to the actual flexibility supported at runtime (example, dates, etc). This change relaxes the type hints to better reflect real usage. * Apply suggestion from @timhoffm Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> * Change types of xy and xytext parameters to Any Update pyplot.py annotate function to use tuple[Any, Any] for xy and xytext parameters to match _axes.pyi changes and reflect actual runtime behavior of the API. --------- Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
1 parent 04371c0 commit 4cefc05

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

lib/matplotlib/axes/_axes.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ class Axes(_AxesBase):
133133
def annotate(
134134
self,
135135
text: str,
136-
xy: tuple[float, float],
137-
xytext: tuple[float, float] | None = ...,
136+
xy: tuple[Any, Any],
137+
xytext: tuple[Any, Any] | None = ...,
138138
xycoords: CoordsType = ...,
139139
textcoords: CoordsType | None = ...,
140140
arrowprops: dict[str, Any] | None = ...,

lib/matplotlib/pyplot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3033,8 +3033,8 @@ def angle_spectrum(
30333033
@_copy_docstring_and_deprecators(Axes.annotate)
30343034
def annotate(
30353035
text: str,
3036-
xy: tuple[float, float],
3037-
xytext: tuple[float, float] | None = None,
3036+
xy: tuple[Any, Any],
3037+
xytext: tuple[Any, Any] | None = None,
30383038
xycoords: CoordsType = "data",
30393039
textcoords: CoordsType | None = None,
30403040
arrowprops: dict[str, Any] | None = None,

0 commit comments

Comments
 (0)