Repository: beetbox/beets

Issue:
Typos in variables, methods & options
Here are some typos I've noticed:

https://github.com/sampsyo/beets/blob/master/beets/ui/commands.py#L443 `def _summary_judment(rec):` should be `def _summary_judgment(rec):`

https://github.com/sampsyo/beets/blob/master/beetsplug/play.py#L44 `'warning_treshold': 100,` should be `'warning_threshold': 100,`

I'll submit a PR to fix them soon.



Discussion:
Agh; so embarrassing! Thanks!

Yup, I'm the one to blame for the second one. Just let me check if there are more instances of this particular spelling mistake.

E:Ok, I misspelled it systematically.


Resolving patch:
diff --git a/beets/ui/commands.py b/beets/ui/commands.py
--- a/beets/ui/commands.py
+++ b/beets/ui/commands.py
@@ -440,7 +440,7 @@ def summarize_items(items, singleton):
     return ', '.join(summary_parts)
 
 
-def _summary_judment(rec):
+def _summary_judgment(rec):
     """Determines whether a decision should be made without even asking
     the user. This occurs in quiet mode and when an action is chosen for
     NONE recommendations. Return an action or None if the user should be
@@ -697,7 +697,7 @@ def choose_match(self, task):
                u' ({0} items)'.format(len(task.items)))
 
         # Take immediate action if appropriate.
-        action = _summary_judment(task.rec)
+        action = _summary_judgment(task.rec)
         if action == importer.action.APPLY:
             match = task.candidates[0]
             show_change(task.cur_artist, task.cur_album, match)
@@ -757,7 +757,7 @@ def choose_item(self, task):
         candidates, rec = task.candidates, task.rec
 
         # Take immediate action if appropriate.
-        action = _summary_judment(task.rec)
+        action = _summary_judgment(task.rec)
         if action == importer.action.APPLY:
             match = candidates[0]
             show_item_change(task.item, match)
diff --git a/beetsplug/play.py b/beetsplug/play.py
--- a/beetsplug/play.py
+++ b/beetsplug/play.py
@@ -41,6 +41,8 @@ def __init__(self):
             'use_folders': False,
             'relative_to': None,
             'raw': False,
+            # Backwards compatibility. See #1803 and line 74
+            'warning_threshold': -2,
             'warning_treshold': 100,
         })
 
@@ -68,7 +70,18 @@ def play_music(self, lib, opts, args):
         use_folders = config['play']['use_folders'].get(bool)
         relative_to = config['play']['relative_to'].get()
         raw = config['play']['raw'].get(bool)
-        warning_treshold = config['play']['warning_treshold'].get(int)
+        warning_threshold = config['play']['warning_threshold'].get(int)
+        # We use -2 as a default value for warning_threshold to detect if it is
+        # set or not. We can't use a falsey value because it has an actual in
+        # the configuration of this pluginmeaning, and we do not use -1 because
+        # some people might use it as a value to obtain no warning, which
+        # which wouldn't be that bad of a practice.
+        if warning_threshold == -2:
+            # if warning_threshold has not been set by user, look for
+            # warning_treshold, to preserve backwards compatibility. See #1803.
+            # warning_treshold has the correct default value of 100.
+            warning_threshold = config['play']['warning_treshold'].get(int)
+
         if relative_to:
             relative_to = util.normpath(relative_to)
 
@@ -110,7 +123,7 @@ def play_music(self, lib, opts, args):
             return
 
         # Warn user before playing any huge playlists.
-        if warning_treshold and len(selection) > warning_treshold:
+        if warning_threshold and len(selection) > warning_threshold:
             ui.print_(ui.colorize(
                 'text_warning',
                 'You are about to queue {0} {1}.'.format(len(selection),


Test patch:
diff --git a/test/test_play.py b/test/test_play.py
--- a/test/test_play.py
+++ b/test/test_play.py
@@ -97,6 +97,15 @@ def test_not_found(self):
         self.open_mock.assert_not_called()
 
     def test_warning_threshold(self):
+        self.config['play']['warning_threshold'] = 1
+        self.add_item(title='another NiceTitle')
+
+        with control_stdin("a"):
+            self.run_command('play', 'nice')
+
+        self.open_mock.assert_not_called()
+
+    def test_warning_threshold_backwards_compat(self):
         self.config['play']['warning_treshold'] = 1
         self.add_item(title='another NiceTitle')