GH-124321: Fix argparse negative number parsing to capture -.5(GH-124322)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
This commit is contained in:
Savannah Ostrowski 2024-09-23 11:16:55 -07:00 committed by GitHub
parent 2f6d4109b8
commit dc48312717
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View file

@ -1360,7 +1360,7 @@ class _ActionsContainer(object):
self._defaults = {}
# determines whether an "option" looks like a negative number
self._negative_number_matcher = _re.compile(r'^-\d[\d_]*(\.\d[\d_]*)?$')
self._negative_number_matcher = _re.compile(r'^-(?:\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?|\.\d+(?:_\d+)*)$')
# whether or not there are any optionals that look like negative
# numbers -- uses a list so it can be shared and edited