Skip to content

Commit

Permalink
Add deprecation warning about setting list safety
Browse files Browse the repository at this point in the history
  • Loading branch information
kk7ds committed Sep 9, 2024
1 parent dbfaad6 commit 080d65c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions chirp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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))

Expand Down

0 comments on commit 080d65c

Please sign in to comment.