mirror of
https://github.com/kk7ds/chirp.git
synced 2024-09-21 02:27:21 +00:00
Add deprecation warning about setting list safety
This commit is contained in:
parent
dbfaad6a6c
commit
080d65c958
@ -14,6 +14,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import logging
|
||||
import warnings
|
||||
|
||||
from chirp import chirp_common
|
||||
|
||||
@ -226,6 +227,14 @@ class RadioSettingValueList(RadioSettingValue):
|
||||
def __init__(self, options, current=None, current_index=0):
|
||||
RadioSettingValue.__init__(self)
|
||||
self._options = list(options)
|
||||
if current is not None:
|
||||
# Using current_index is safer than using current because we can
|
||||
# gracefully handle out-of-range values without crashing. All new
|
||||
# code should use current_index and old code should be fixed.
|
||||
warnings.warn(
|
||||
'RadioSettingValueList should be provided with '
|
||||
'current_index instead of current (value) for '
|
||||
'safety', FutureWarning, stacklevel=2)
|
||||
self.queue_current(current if current is not None
|
||||
else int(current_index))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user