Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/matplotlib/text.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Text(Artist):
self,
x: float = ...,
y: float = ...,
text: Any = ...,
text: object = ...,
*,
color: ColorType | None = ...,
verticalalignment: Literal[
Expand All @@ -41,9 +41,10 @@ class Text(Artist):
transform_rotates_text: bool = ...,
parse_math: bool | None = ...,
antialiased: bool | None = ...,
**kwargs
**kwargs: Any

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The supported kwargs are actually known. See the docs https://matplotlib.org/stable/api/text_api.html#matplotlib.text.Text

We could be more specific and define them in a TextProperties TypedDict and Unpack[TextProperties] here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timhoffm thanks for the review, this indirectly answerd my question from other PR.

The supported kwargs are actually known. See the docs https://matplotlib.org/stable/api/text_api.html#matplotlib.text.Text

We could be more specific and define them in a TextProperties TypedDict and Unpack[TextProperties] here.

make sense, i'll update with this and my other PRs too

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do this separately, because it's a dedicated and complex enough effort: Basically what we want is a Typed Dict for the artist properties. Artist properties are essentially the things you can set_[propname] on any object. These are in many cases the accepted and passed though by kwargs, and therefore artist property Typed Dicts make sense.

You'll want to create a Typed Dict hierarchy following the Artist hierarchy, i.e. TextProperties inheriting from ArtistProperties.

I'll merge this PR as, and you can do a follow-up with the typed dicts.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do this separately, because it's a dedicated and complex enough effort: Basically what we want is a Typed Dict for the artist properties. Artist properties are essentially the things you can set_[propname] on any object. These are in many cases the accepted and passed though by kwargs, and therefore artist property Typed Dicts make sense.

thanks for explanation, make sense.

Would it be fine if I open one issue for type annotation, which basically keep track, and maybe i can ask or discuss, any point there.

I'll merge this PR as, and you can do a follow-up with the typed dicts.

also, thanks for merging this, i've two more opened PR, those are also simple with small changes, please have a look when you get chance and share your thoughts.

) -> None: ...
def update(self, kwargs: dict[str, Any]) -> list[Any]: ...
def __getstate__(self) -> dict[str, Any]: ...
def get_rotation(self) -> float: ...
def get_transform_rotates_text(self) -> bool: ...
def set_rotation_mode(self, m: None | Literal["default", "anchor", "xtick", "ytick"]) -> None: ...
Expand Down Expand Up @@ -100,7 +101,7 @@ class Text(Artist):
def set_verticalalignment(
self, align: Literal["bottom", "baseline", "center", "center_baseline", "top"]
) -> None: ...
def set_text(self, s: Any) -> None: ...
def set_text(self, s: object) -> None: ...
def set_fontproperties(self, fp: FontProperties | str | Path | None) -> None: ...
def set_usetex(self, usetex: bool | None) -> None: ...
def get_usetex(self) -> bool: ...
Expand Down Expand Up @@ -152,7 +153,7 @@ class Annotation(Text, _AnnotationBase):
textcoords: CoordsType | None = ...,
arrowprops: dict[str, Any] | None = ...,
annotation_clip: bool | None = ...,
**kwargs
**kwargs: Any
) -> None: ...
@property
def xycoords(
Expand Down
Loading