Issue 9347: Calling argparse add_argument with a sequence as 'type' causes spurious error message (original) (raw)
What steps will reproduce the problem?
parser = argparse.ArgumentParser() parser.add_argument('--foo', type=(int, float))
What is the expected output?
ValueError: (<type 'int'>, <type 'float'>) is not callable
What do you see instead?
TypeError: not all arguments converted during string formatting
Please provide any additional information below.
This is caused by calling using the % string formatting operator without proper wrapping of the argument. The fix is basically:
raise ValueError('%r is not callable' % type_func)
raise ValueError('%r is not callable' % (type_func,))