@@ -154,17 +154,18 @@ def normalize_list_value(value: str) -> List[ParsedValue]:
154154 # original regex:
155155 # '(?:(?:^|(?<=,))(?:|(?P<pool>[a-zA-Z]+[-?a-zA-Z0-9]*)|(?P<count>-?[0-9]+)|(?:(?P<size>-?[0-9]+(?:\\.[0-9]+)?)(?P<size_exp>[MGTPEZY])(?:i?B)?))(?:$|,))'
156156 # with formatting and explanation -- note that this regex is used with re.finditer:
157- '(?:(?:^|(?<=,))' # start of string or previous match ends with ','
158- '(?:' # match one of the following:
159- '|(?P<pool>[a-zA-Z]+[-?a-zA-Z0-9]*)' # pool: a sequence starting with a letter, ending with a letter or number,
160- # -- and including letters, numbers and hyphens (no more than one in a row)
161- '|(?P<count>-?[0-9]+)' # count: an optional minus sign followed by one or more digits
162- '|(?:' # size (number) and size_exp (units):
163- '(?P<size>-?[0-9]+(?:\\ .[0-9]+)?)' # an optional minus sign followed by one or more digits, optionally with decimal point and more digits
164- '(?P<size_exp>[MGTPEZY])(?:i?B)?' # one of MGTPEZY, optionally followed by iB or B, for example 1M or 2.0MB or -3.3MiB
165- ')'
157+ '(?:'
158+ '(?:^|(?<=,))' # start of string or previous match ends with ','
159+ '(?:' # match one of the following:
160+ '|(?P<pool>[a-zA-Z]+[-?a-zA-Z0-9]*)' # * pool: a sequence starting with a letter, ending with a letter or number,
161+ # ------- and including letters, numbers and hyphens (no more than one in a row)
162+ '|(?P<count>-?[0-9]+)' # * count: an optional minus sign followed by one or more digits
163+ '|(?:' # * size (number) and size_exp (units):
164+ '(?P<size>-?[0-9]+(?:\\ .[0-9]+)?)' # -- * an optional minus sign followed by one or more digits, optionally with decimal point and more digits
165+ '(?P<size_exp>[MGTPEZY])(?:i?B)?)' # -- * one of MGTPEZY, optionally followed by iB or B, for example 1M or 2.0MB or -3.3MiB
166+ ')'
167+ '(?:$|,)' # end of string or ','
166168 ')'
167- '(?:$|,))' # end of string or ','
168169)
169170
170171
@@ -195,7 +196,7 @@ def parse_storage_constraint(constraint: str) -> StorageConstraintDict:
195196DEVICE = re .compile (
196197 # original regex:
197198 # '^(?P<count>[0-9]+)?(?:^|,)(?P<type>[^,]+)(?:$|,(?!$))(?P<attrs>(?:[^=]+=[^;]+)+)*$'
198- # with formatting and explanation:
199+ # with formatting and explanation -- note this regex is used with re.match :
199200 '^' # start of string
200201 '(?P<count>[0-9]+)?' # count is 1+ digits, and is optional
201202 '(?:^|,)' # match start of string or a comma
0 commit comments