Skip to content

Commit

Permalink
style: make flake8 happy about indentation of continuations
Browse files Browse the repository at this point in the history
  • Loading branch information
james-garner-canonical committed Oct 15, 2024
1 parent c34f23d commit 554ca7d
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions juju/constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,18 @@ def normalize_list_value(value: str) -> List[ParsedValue]:
# original regex:
# '(?:(?:^|(?<=,))(?:|(?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)?))(?:$|,))'
# with formatting and explanation -- note that this regex is used with re.finditer:
'(?:(?:^|(?<=,))' # start of string or previous match ends with ','
'(?:' # match one of the following:
'|(?P<pool>[a-zA-Z]+[-?a-zA-Z0-9]*)' # pool: a sequence starting with a letter, ending with a letter or number,
# -- and including letters, numbers and hyphens (no more than one in a row)
'|(?P<count>-?[0-9]+)' # count: an optional minus sign followed by one or more digits
'|(?:' # size (number) and size_exp (units):
'(?P<size>-?[0-9]+(?:\\.[0-9]+)?)' # an optional minus sign followed by one or more digits, optionally with decimal point and more digits
'(?P<size_exp>[MGTPEZY])(?:i?B)?' # one of MGTPEZY, optionally followed by iB or B, for example 1M or 2.0MB or -3.3MiB
')'
'(?:'
'(?:^|(?<=,))' # start of string or previous match ends with ','
'(?:' # match one of the following:
'|(?P<pool>[a-zA-Z]+[-?a-zA-Z0-9]*)' # * pool: a sequence starting with a letter, ending with a letter or number,
# ------- and including letters, numbers and hyphens (no more than one in a row)
'|(?P<count>-?[0-9]+)' # * count: an optional minus sign followed by one or more digits
'|(?:' # * size (number) and size_exp (units):
'(?P<size>-?[0-9]+(?:\\.[0-9]+)?)' # -- * an optional minus sign followed by one or more digits, optionally with decimal point and more digits
'(?P<size_exp>[MGTPEZY])(?:i?B)?)' # -- * one of MGTPEZY, optionally followed by iB or B, for example 1M or 2.0MB or -3.3MiB
')'
'(?:$|,)' # end of string or ','
')'
'(?:$|,))' # end of string or ','
)


Expand Down Expand Up @@ -195,7 +196,7 @@ def parse_storage_constraint(constraint: str) -> StorageConstraintDict:
DEVICE = re.compile(
# original regex:
# '^(?P<count>[0-9]+)?(?:^|,)(?P<type>[^,]+)(?:$|,(?!$))(?P<attrs>(?:[^=]+=[^;]+)+)*$'
# with formatting and explanation:
# with formatting and explanation -- note this regex is used with re.match:
'^' # start of string
'(?P<count>[0-9]+)?' # count is 1+ digits, and is optional
'(?:^|,)' # match start of string or a comma
Expand Down

0 comments on commit 554ca7d

Please sign in to comment.