🌐 AI搜索 & 代理 主页
Skip to content
Merged
Show file tree
Hide file tree
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
19 changes: 10 additions & 9 deletions lib/matplotlib/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import contextlib
from packaging.version import Version

from matplotlib._api import MatplotlibDeprecationWarning
from matplotlib.typing import RcKeyType, RcGroupKeyType
from typing import Any, Literal, NamedTuple, overload
from matplotlib.typing import LogLevel

Expand Down Expand Up @@ -69,18 +70,18 @@ def get_cachedir() -> str: ...
def get_data_path() -> str: ...
def matplotlib_fname() -> str: ...

class RcParams(dict[str, Any]):
class RcParams(dict[RcKeyType, Any]):
validate: dict[str, Callable]
def __init__(self, *args, **kwargs) -> None: ...
def _set(self, key: str, val: Any) -> None: ...
def _get(self, key: str) -> Any: ...
def _set(self, key: RcKeyType, val: Any) -> None: ...
def _get(self, key: RcKeyType) -> Any: ...

def _update_raw(self, other_params: dict | RcParams) -> None: ...

def _ensure_has_backend(self) -> None: ...
def __setitem__(self, key: str, val: Any) -> None: ...
def __getitem__(self, key: str) -> Any: ...
def __iter__(self) -> Generator[str, None, None]: ...
def __setitem__(self, key: RcKeyType, val: Any) -> None: ...
def __getitem__(self, key: RcKeyType) -> Any: ...
def __iter__(self) -> Generator[RcKeyType, None, None]: ...
def __len__(self) -> int: ...
def find_all(self, pattern: str) -> RcParams: ...
def copy(self) -> RcParams: ...
Expand All @@ -95,17 +96,17 @@ def rc_params_from_file(
rcParamsDefault: RcParams
rcParams: RcParams
rcParamsOrig: RcParams
defaultParams: dict[str, Any]
defaultParams: dict[RcKeyType, Any]

def rc(group: str, **kwargs) -> None: ...
def rc(group: RcGroupKeyType, **kwargs) -> None: ...
def rcdefaults() -> None: ...
def rc_file_defaults() -> None: ...
def rc_file(
fname: str | Path | os.PathLike, *, use_default_template: bool = ...
) -> None: ...
@contextlib.contextmanager
def rc_context(
rc: dict[str, Any] | None = ..., fname: str | Path | os.PathLike | None = ...
rc: dict[RcKeyType, Any] | None = ..., fname: str | Path | os.PathLike | None = ...
) -> Generator[None, None, None]: ...
def use(backend: str, *, force: bool = ...) -> None: ...
@overload
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/_mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ def __init__(self, default_font_prop: FontProperties, load_glyph_flags: LoadFlag

super().__init__(default_font_prop, load_glyph_flags)
for texfont in "cal rm tt it bf sf bfit".split():
prop = mpl.rcParams['mathtext.' + texfont]
prop = mpl.rcParams['mathtext.' + texfont] # type: ignore[index]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no getter for a group so I think ignoring the error is the only solution.

Copy link
Member

@timhoffm timhoffm Sep 8, 2025

Choose a reason for hiding this comment

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

I assume mypy is complaining here. Would it help to make the list explicit?

for texfont in ["cal", "rm", "tt", "it", "bf", "sf", "bfit"]:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately mypy consider textfont as a str and the sum also as str so we have the same error

Copy link
Member

Choose a reason for hiding this comment

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

Ok in that case, ignoring is likely the simplest solution.

font = findfont(prop)
self.fontmap[texfont] = font
prop = FontProperties('cmex10')
Expand Down
6 changes: 4 additions & 2 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@
MarkerType,
MouseEventType,
PickEventType,
RcGroupKeyType,
RcKeyType,
ResizeEventType,
LogLevel
)
Expand Down Expand Up @@ -787,13 +789,13 @@ def pause(interval: float) -> None:


@_copy_docstring_and_deprecators(matplotlib.rc)
def rc(group: str, **kwargs) -> None:
def rc(group: RcGroupKeyType, **kwargs) -> None:
matplotlib.rc(group, **kwargs)


@_copy_docstring_and_deprecators(matplotlib.rc_context)
def rc_context(
rc: dict[str, Any] | None = None,
rc: dict[RcKeyType, Any] | None = None,
fname: str | pathlib.Path | os.PathLike | None = None,
) -> AbstractContextManager[None]:
return matplotlib.rc_context(rc, fname)
Expand Down
Loading
Loading