ThomasWaldmann / argparse

python argparse, pypi version (moved from google code)
Other
59 stars 18 forks source link

Calling add_argument with a sequence as 'type' causes spurious error message. #66

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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

What version of the product are you using?

argparse 1.1

On what operating system?

Debian Linux

Please provide any additional information below.

This is caused by calling using the % string formatting operator without
proper wrapping of the argument. The attached patch corrects this.

This was discovered by assuming that 'type' accept handle a sequence like
metavar does. It is unfortunate that it does not, but I'll raise that as a
seperate issue.

Original issue reported on code.google.com by Karatorian on 14 Mar 2010 at 1:40

Attachments:

GoogleCodeExporter commented 9 years ago
Moved to http://bugs.python.org/issue9347

Original comment by steven.b...@gmail.com on 23 Jul 2010 at 1:28