yiwangai1983 / argparse

Automatically exported from code.google.com/p/argparse
Other
0 stars 0 forks source link

improve exception messages for optparse related errors #51

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Warn about string types in add_argument instead of parse_args:

>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('foo', type='int')
>>> parser.parse_args(['X'])
usage: [-h] foo
: error: argument foo: 'int' is not callable

Warn about using optparse-style %prog formatting:

>>> import argparse
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('foo', help='%prog')
>>> parser.print_help()
Traceback (most recent call last):
  ...
ValueError: unsupported format character 'p' (0x70) at index 1

Original issue reported on code.google.com by steven.b...@gmail.com on 15 Dec 2009 at 5:13

GoogleCodeExporter commented 8 years ago
Looks like I can do the former (and have in r85), but the latter results in too 
many
false positives. (E.g. I need to make sure I still allow "%%prog", "100%", etc.)

Original comment by steven.b...@gmail.com on 28 Feb 2010 at 8:37