Skip to content

Create RCKeyType #30316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
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
17 changes: 9 additions & 8 deletions lib/matplotlib/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from packaging.version import Version

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

class _VersionInfo(NamedTuple):
Expand Down Expand Up @@ -70,15 +71,15 @@
class RcParams(dict[str, 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: ...

Check failure on line 80 in lib/matplotlib/__init__.pyi

View workflow job for this annotation

GitHub Actions / mypy

[mypy] reported by reviewdog 🐶 Argument 1 of "__setitem__" is incompatible with supertype "typing.MutableMapping"; supertype defines the argument type as "str" [override] Raw Output: lib/matplotlib/__init__.pyi:80: error: Argument 1 of "__setitem__" is incompatible with supertype "typing.MutableMapping"; supertype defines the argument type as "str" [override]

Check warning on line 80 in lib/matplotlib/__init__.pyi

View workflow job for this annotation

GitHub Actions / mypy

[mypy] reported by reviewdog 🐶 See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides Raw Output: lib/matplotlib/__init__.pyi:80: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides

Check warning on line 80 in lib/matplotlib/__init__.pyi

View workflow job for this annotation

GitHub Actions / mypy

[mypy] reported by reviewdog 🐶 This violates the Liskov substitution principle Raw Output: lib/matplotlib/__init__.pyi:80: note: This violates the Liskov substitution principle

Check failure on line 80 in lib/matplotlib/__init__.pyi

View workflow job for this annotation

GitHub Actions / mypy

[mypy] reported by reviewdog 🐶 Argument 1 of "__setitem__" is incompatible with supertype "builtins.dict"; supertype defines the argument type as "str" [override] Raw Output: lib/matplotlib/__init__.pyi:80: error: Argument 1 of "__setitem__" is incompatible with supertype "builtins.dict"; supertype defines the argument type as "str" [override]
def __getitem__(self, key: RcKeyType) -> Any: ...

Check failure on line 81 in lib/matplotlib/__init__.pyi

View workflow job for this annotation

GitHub Actions / mypy

[mypy] reported by reviewdog 🐶 Argument 1 of "__getitem__" is incompatible with supertype "typing.Mapping"; supertype defines the argument type as "str" [override] Raw Output: lib/matplotlib/__init__.pyi:81: error: Argument 1 of "__getitem__" is incompatible with supertype "typing.Mapping"; supertype defines the argument type as "str" [override]

Check warning on line 81 in lib/matplotlib/__init__.pyi

View workflow job for this annotation

GitHub Actions / mypy

[mypy] reported by reviewdog 🐶 See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides Raw Output: lib/matplotlib/__init__.pyi:81: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides

Check warning on line 81 in lib/matplotlib/__init__.pyi

View workflow job for this annotation

GitHub Actions / mypy

[mypy] reported by reviewdog 🐶 This violates the Liskov substitution principle Raw Output: lib/matplotlib/__init__.pyi:81: note: This violates the Liskov substitution principle

Check failure on line 81 in lib/matplotlib/__init__.pyi

View workflow job for this annotation

GitHub Actions / mypy

[mypy] reported by reviewdog 🐶 Argument 1 of "__getitem__" is incompatible with supertype "builtins.dict"; supertype defines the argument type as "str" [override] Raw Output: lib/matplotlib/__init__.pyi:81: error: Argument 1 of "__getitem__" is incompatible with supertype "builtins.dict"; supertype defines the argument type as "str" [override]
def __iter__(self) -> Generator[RcKeyType, None, None]: ...
def __len__(self) -> int: ...
def find_all(self, pattern: str) -> RcParams: ...
def copy(self) -> RcParams: ...
Expand All @@ -93,17 +94,17 @@
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
3 changes: 2 additions & 1 deletion lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
MarkerType,
MouseEventType,
PickEventType,
RcGroupKeyType,
ResizeEventType,
)
from matplotlib.widgets import SubplotTool
Expand Down Expand Up @@ -786,7 +787,7 @@


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


Expand All @@ -795,7 +796,7 @@
rc: dict[str, Any] | None = None,
fname: str | pathlib.Path | os.PathLike | None = None,
) -> AbstractContextManager[None]:
return matplotlib.rc_context(rc, fname)

Check failure on line 799 in lib/matplotlib/pyplot.py

View workflow job for this annotation

GitHub Actions / mypy

[mypy] reported by reviewdog 🐶 Argument 1 to "rc_context" has incompatible type "dict[str, Any] | None"; expected "dict[Literal['agg.path.chunksize', 'animation.bitrate', 'animation.codec', 'animation.convert_args', 'animation.convert_path', 'animation.embed_limit', 'animation.ffmpeg_args', 'animation.ffmpeg_path', 'animation.frame_format', 'animation.html', 'animation.writer', 'axes.autolimit_mode', 'axes.axisbelow', 'axes.edgecolor', 'axes.facecolor', 'axes.formatter.limits', 'axes.formatter.min_exponent', 'axes.formatter.offset_threshold', 'axes.formatter.use_locale', 'axes.formatter.use_mathtext', 'axes.formatter.useoffset', 'axes.grid', 'axes.grid.axis', 'axes.grid.which', 'axes.labelcolor', 'axes.labelpad', 'axes.labelsize', 'axes.labelweight', 'axes.linewidth', 'axes.prop_cycle', 'axes.spines.bottom', 'axes.spines.left', 'axes.spines.right', 'axes.spines.top', 'axes.titlecolor', 'axes.titlelocation', 'axes.titlepad', 'axes.titlesize', 'axes.titleweight', 'axes.titley', 'axes.unicode_minus', 'axes.xmargin', 'axes.ymargin', 'axes.zmargin', 'axes3d.automargin', 'axes3d.grid', 'axes3d.mouserotationstyle', 'axes3d.trackballborder', 'axes3d.trackballsize', 'axes3d.xaxis.panecolor', 'axes3d.yaxis.panecolor', 'axes3d.zaxis.panecolor', 'backend', 'backend_fallback', 'boxplot.bootstrap', 'boxplot.boxprops.color', 'boxplot.boxprops.linestyle', 'boxplot.boxprops.linewidth', 'boxplot.capprops.color', 'boxplot.capprops.linestyle', 'boxplot.capprops.linewidth', 'boxplot.flierprops.color', 'boxplot.flierprops.linestyle', 'boxplot.flierprops.linewidth', 'boxplot.flierprops.marker', 'boxplot.flierprops.markeredgecolor', 'boxplot.flierprops.markeredgewidth', 'boxplot.flierprops.markerfacecolor', 'boxplot.flierprops.markersize', 'boxplot.meanline', 'boxplot.meanprops.color', 'boxplot.meanprops.linestyle', 'boxplot.meanprops.linewidth', 'boxplot.meanprops.marker', 'boxplot.meanprops.markeredgecolor', 'boxplot.meanprops.markerfacecolor', 'boxplot.meanprops.markersize', 'boxplot.medianprops.color', 'boxplot.medianprops.linestyle', 'boxplot.medianprops.linewidth', 'boxplot.notch', 'boxplot.patchartist', 'boxplot.showbox', 'boxplot.showcaps', 'boxplot.showfliers', 'boxplot.showmeans', 'boxplot.vertical', 'boxplot.whiskerprops.color', 'boxplot.whiskerprops.linestyle', 'boxplot.whiskerprops.linewidth', 'boxplot.whiskers', 'contour.algorithm', 'contour.corner_mask', 'contour.linewidth', 'contour.negative_linestyle', 'date.autoformatter.day', 'date.autoformatter.hour', 'date.autoformatter.microsecond', 'date.autoformatter.minute', 'date.autoformatter.month', 'date.autoformatter.second', 'date.autoformatter.year', 'date.converter', 'date.epoch', 'date.interval_multiples', 'docstring.hardcopy', 'errorbar.capsize', 'figure.autolayout', 'figure.constrained_layout.h_pad', 'figure.constrained_layout.hspace', 'figure.constrained_layout.use', 'figure.constrained_layout.w_pad', 'figure.constrained_layout.wspace', 'figure.dpi', 'figure.edgecolor', 'figure.facecolor', 'figure.figsize', 'figure.frameon', 'figure.hooks', 'figure.labelsize', 'figure.labelweight', 'figure.max_open_warning', 'figure.raise_window', 'figure.subplot.bottom', 'figure.subplot.hspace', 'figure.subplot.left', 'figure.subplot.right', 'figure.subplot.top', 'figure.subplot.wspace', 'figure.titlesize', 'figure.titleweight', 'font.cursive', 'font.family', 'font.fantasy', 'font.monospace', 'font.sans-serif', 'font.serif', 'font.size', 'font.stretch', 'font.style', 'font.variant', 'font.weight', 'grid.alpha', 'grid.color', 'grid.linestyle', 'grid.linewidth', 'hatch.color', 'hatch.linewidth', 'hist.bins', 'image.aspect', 'image.cmap', 'image.composite_image', 'image.interpolation', 'image.interpolation_stage', 'image.lut', 'image.origin', 'image.resample', 'interactive', 'keymap.back', 'keymap.copy', 'keymap.forward', 'keymap.fullscreen', 'keymap.grid', 'keymap.grid_minor', 'keymap.help', 'keymap.home', 'keymap.pan', 'keymap.quit', 'keymap.quit_all', 'keymap.save', 'keymap.xscale', 'keymap.yscale', 'keymap.zoom', 'legend.borderaxespad', 'legend.borderpad', 'legend.columnspacing', 'legend.


@_copy_docstring_and_deprecators(matplotlib.rcdefaults)
Expand Down
Loading
Loading