diff --git a/qutebrowser/commands/argparser.py b/qutebrowser/commands/argparser.py index bf41f707f..825e0d623 100644 --- a/qutebrowser/commands/argparser.py +++ b/qutebrowser/commands/argparser.py @@ -119,7 +119,7 @@ def type_conv(param, typ, value, *, str_choices=None): if utils.is_enum(typ): _check_choices(param, value, [arg_name(e.name) for e in typ]) return typ[value.replace('-', '_')] - elif typ in [str, None]: + elif typ is str: if str_choices is not None: _check_choices(param, value, str_choices) return value diff --git a/qutebrowser/commands/command.py b/qutebrowser/commands/command.py index 40a10fadf..59b690cbd 100644 --- a/qutebrowser/commands/command.py +++ b/qutebrowser/commands/command.py @@ -422,9 +422,11 @@ class Command: choices = self.get_arg_info(param).choices value = argparser.multitype_conv(param, types, value, str_choices=choices) - elif typ in [str, None]: + elif typ is str: choices = self.get_arg_info(param).choices value = argparser.type_conv(param, typ, value, str_choices=choices) + elif typ is None: + pass elif typ is bool: # no type conversion for flags assert isinstance(value, bool) else: diff --git a/tests/unit/commands/test_cmdutils.py b/tests/unit/commands/test_cmdutils.py index 82e18f211..1bef17d86 100644 --- a/tests/unit/commands/test_cmdutils.py +++ b/tests/unit/commands/test_cmdutils.py @@ -295,20 +295,6 @@ class TestRegister: else: assert cmd._get_call_args(win_id=0) == ([expected], {}) - def test_choices_no_annotation(self): - # https://github.com/The-Compiler/qutebrowser/issues/1871 - @cmdutils.register() - @cmdutils.argument('arg', choices=['foo', 'bar']) - def fun(arg): - """Blah.""" - pass - - cmd = cmdutils.cmd_dict['fun'] - cmd.namespace = cmd.parser.parse_args(['fish']) - - with pytest.raises(cmdexc.ArgumentTypeError): - cmd._get_call_args(win_id=0) - def test_pos_arg_info(self): @cmdutils.register() @cmdutils.argument('foo', choices=('a', 'b'))