@@ -96,6 +96,9 @@ def _valid_make_mpf_style_kwargs():
96
96
'rc' : { 'Default' : None ,
97
97
'Validator' : lambda value : isinstance (value ,dict ) },
98
98
99
+ 'legacy_rc' : { 'Default' : None , # Just in case someone depended upon old behavior
100
+ 'Validator' : lambda value : isinstance (value ,dict ) },
101
+
99
102
'style_name' : { 'Default' : None ,
100
103
'Validator' : lambda value : isinstance (value ,str ) },
101
104
@@ -108,6 +111,19 @@ def available_styles():
108
111
109
112
def make_mpf_style ( ** kwargs ):
110
113
config = _process_kwargs (kwargs , _valid_make_mpf_style_kwargs ())
114
+ if config ['rc' ] is not None and config ['legacy_rc' ] is not None :
115
+ raise ValueError ('kwargs `rc` and `legacy_rc` may NOT be used together!' )
116
+
117
+ # -----------
118
+ # March 2021: Found bug that if caller used `base_mpf_style` and `rc` at
119
+ # the same time, then the caller's `rc` will completely replace the `rc`
120
+ # of `base_mpf_style`. That was never the intention! Rather it should be
121
+ # that the caller's `rc` merely adds to and/or modifies the `rc` of the
122
+ # `base_mpf_style`. In order to provide a path to "backwards compatibility"
123
+ # for users who may have depended on the bug behavior (callers `rc` replaces
124
+ # `rc` of `base_mpf_style`) we provide a new kwarg `legacy_rc` which will
125
+ # now behave the way that `rc` used to behave.
126
+ # -----------
111
127
112
128
if config ['base_mpf_style' ] is not None :
113
129
style = _get_mpfstyle (config ['base_mpf_style' ])
@@ -122,6 +138,9 @@ def make_mpf_style( **kwargs ):
122
138
if style ['rc' ] is None :
123
139
style ['rc' ] = {}
124
140
style ['rc' ].update (rc )
141
+ elif config ['legacy_rc' ] is not None :
142
+ config ['rc' ] = config ['legacy_rc' ]
143
+ del config ['legacy_rc' ]
125
144
update = [ (k ,v ) for k ,v in config .items () if v is not None ]
126
145
style .update (update )
127
146
else :
0 commit comments