Commit 85159ce
committed
MNT: Move "backend" from a regular rcParams dict entry to a class attribute
Working towards matplotlib#31791.
> rcParams should be only configuration, not state; i.e. wrt. backend, it
> can hold the desired backend and backend priorities, but it should not
> hold the currently active backend or trigger backend selection as a
> side-effect. The latter causes a lot of complexity in rcParams.
This PR is the first step in the migration strategy outlined there:
> Make the backend a RcParams class attribute and do not hold
> "backend" as a regular dict entry. There can only be one backend,
> so putting that value in a class attribute `RcParams._backend` makes
> sense. This already reduces the complexity as we don't need special
> handling to sync/copy the value when rcParams are bulk-replaced
> (loading from file or rc_context). Instead add special logic to keep
> behavioral backward compatibility with the dict API
> (`rcParams["backend"]` / `rcParams._get("backend")` /
> `"rcParams._set("backend", val)`).
Note on API compatibility: This PR limits itself to the known typical
dict-API usages in the context of backend handling. I've refrained from
trying to fully replicate dict behavior of a "virtual" "backend" parameter,
i.e. `len(rcParams)` / `rcParams.keys()` / `rcParams.values()` /
`rcParams.items()` do not contain "backend" anymore. I would be willing to
accept this level of API breakage. If deemed critical, we could add
compatibility shims for that too.1 parent 7c377c5 commit 85159ce
4 files changed
Lines changed: 53 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
693 | 693 | | |
694 | 694 | | |
695 | 695 | | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
696 | 702 | | |
697 | 703 | | |
698 | 704 | | |
| |||
715 | 721 | | |
716 | 722 | | |
717 | 723 | | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
718 | 727 | | |
719 | 728 | | |
720 | 729 | | |
| |||
736 | 745 | | |
737 | 746 | | |
738 | 747 | | |
| 748 | + | |
| 749 | + | |
739 | 750 | | |
740 | 751 | | |
741 | 752 | | |
| |||
752 | 763 | | |
753 | 764 | | |
754 | 765 | | |
| 766 | + | |
755 | 767 | | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
756 | 774 | | |
757 | 775 | | |
758 | | - | |
759 | | - | |
760 | | - | |
761 | | - | |
762 | | - | |
763 | | - | |
764 | | - | |
765 | | - | |
766 | | - | |
767 | | - | |
768 | | - | |
769 | | - | |
770 | 776 | | |
771 | | - | |
772 | | - | |
773 | | - | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
774 | 787 | | |
775 | 788 | | |
776 | 789 | | |
| |||
784 | 797 | | |
785 | 798 | | |
786 | 799 | | |
787 | | - | |
788 | | - | |
789 | | - | |
790 | | - | |
791 | | - | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
792 | 805 | | |
793 | 806 | | |
794 | | - | |
| 807 | + | |
| 808 | + | |
795 | 809 | | |
796 | 810 | | |
797 | 811 | | |
798 | | - | |
| 812 | + | |
799 | 813 | | |
800 | 814 | | |
801 | 815 | | |
| |||
992 | 1006 | | |
993 | 1007 | | |
994 | 1008 | | |
995 | | - | |
996 | 1009 | | |
997 | 1010 | | |
998 | 1011 | | |
| |||
1201 | 1214 | | |
1202 | 1215 | | |
1203 | 1216 | | |
1204 | | - | |
1205 | | - | |
| 1217 | + | |
1206 | 1218 | | |
1207 | 1219 | | |
1208 | 1220 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
82 | 81 | | |
83 | 82 | | |
84 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
686 | 686 | | |
687 | 687 | | |
688 | 688 | | |
689 | | - | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
690 | 696 | | |
691 | 697 | | |
692 | 698 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
107 | 116 | | |
108 | 117 | | |
109 | 118 | | |
| |||
0 commit comments