Skip to content

[Bug]: Type hint for fontproperties keyword in text.pyi is wrong #30669

@ZhaJiMan

Description

@ZhaJiMan

Bug summary

fontproperties keyword should be annotated with pathlib.Path instead of matplotlib.path.Path in text.pyi.

Code for reproduction

from .path import Path

class Text(Artist):
    zorder: float
    def __init__(
        self,
        x: float = ...,
        y: float = ...,
        text: Any = ...,
        *,
        color: ColorType | None = ...,
        verticalalignment: Literal[
            "bottom", "baseline", "center", "center_baseline", "top"
        ] = ...,
        horizontalalignment: Literal["left", "center", "right"] = ...,
        multialignment: Literal["left", "center", "right"] | None = ...,
        fontproperties: str | Path | FontProperties | None = ...,
        rotation: float | Literal["vertical", "horizontal"] | None = ...,
        linespacing: float | None = ...,
        rotation_mode: Literal["default", "anchor"] | None = ...,
        usetex: bool | None = ...,
        wrap: bool = ...,
        transform_rotates_text: bool = ...,
        parse_math: bool | None = ...,
        antialiased: bool | None = ...,
        **kwargs
    ) -> None: ...
    def set_fontproperties(self, fp: FontProperties | str | Path | None) -> None: ...

Actual outcome

Type checker complains about passing a pathlib.Path object when initializing a Text object.

Expected outcome

Should pass type checking.

Additional information

No response

Operating system

Windows

Matplotlib Version

3.10.5

Matplotlib Backend

tkagg

Python version

3.13.5

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions