argparse icon indicating copy to clipboard operation
argparse copied to clipboard

bug when setting a float value to -10. and not -10.0

Open londumas opened this issue 9 years ago • 0 comments

The bugs is due to self._negative_number_matcher

change: self._negative_number_matcher = _re.compile(r'^-\d+$|^-\d*\.\d+$')

by

self._negative_number_matcher = _re.compile(r'^-\d+$|^-\d*\.\d+$|^-\d*\.')

test with: import argparse as ap p = ap.ArgumentParser() p.add_argument("-x", type=float, required=True) options = p.parse_args() print(options)

londumas avatar Nov 09 '16 08:11 londumas