MNT: Move "backend" from a regular rcParams dict entry to a class attribute by timhoffm · Pull Request #31792 · matplotlib/matplotlib · GitHub
Skip to content
Open
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
60 changes: 35 additions & 25 deletions lib/matplotlib/__init__.py
1 change: 0 additions & 1 deletion lib/matplotlib/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class RcParams(dict[RcKeyType, Any]):

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

def _ensure_has_backend(self) -> None: ...
def __setitem__(self, key: RcKeyType, val: Any) -> None: ...
def __getitem__(self, key: RcKeyType) -> Any: ...
def __iter__(self) -> Generator[RcKeyType, None, None]: ...
Expand Down
8 changes: 7 additions & 1 deletion lib/matplotlib/tests/test_rcparams.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,13 @@ def test_rc_aliases(group, option, alias, value):


def test_all_params_defined_as_code():
assert set(p.name for p in rcsetup._params_list()) == set(mpl.rcParams.keys())
params_in_code = {p.name for p in rcsetup._params_list()}
# 'backend' is stored in RcParams._backend (a class variable) rather than
# in the underlying dict, so it does not appear in rcParams.keys() /
# __iter__. It is still accessible via rcParams['backend'] and
# 'backend' in rcParams; it just doesn't show up during iteration.
params_in_code.remove("backend")
assert params_in_code == set(mpl.rcParams.keys())


def test_validators_defined_as_code():
Expand Down
9 changes: 9 additions & 0 deletions lib/matplotlib/tests/test_typing.py
Loading