typo = True
elif curr_count is not None and abs(curr_count) >= 100 and bool(match["neg"]) == (curr_count < 0):
goal_parts = _separate(str(abs(curr_count)))
+ [*head, tail] = goal_parts
partials = [
- goal_parts[: -1] + [goal_parts[-1][: -1]], # missing last digit
- goal_parts[: -1] + [goal_parts[-1][: -2]], # missing last two digits
- goal_parts[: -1] + [goal_parts[-1][: -2] + goal_parts[-1][-1]], # missing second-last digit
+ [*head, tail[:-1]], # missing last digit
+ [*head, tail[:-2]], # missing last two digits
+ [*head, tail[:-2] + tail[-1]], # missing second-last digit
]
if parts in partials:
# missing any of last two digits
typo = True
- elif any(parts == p[: -1] + [p[-1] + goal_parts[0]] + goal_parts[1 :] for p in partials):
+ elif any(parts == [*p[:-1], p[-1] + goal_parts[0], *goal_parts[1:]] for p in partials):
# double paste
typo = True
else:
groups_okay = True
if curr_count is not None and sep and sep.isspace():
- # Presume that the intended count consists of as many valid digit groups as necessary to match the
- # number of digits in the expected count, if possible.
+ # Presume that the intended count consists of as many valid digit groups as
+ # necessary to match the number of digits in the expected count, if possible.
digit_count = len(str(abs(curr_count)))
use_parts = []
accum = 0
else:
break
- # could still be a no-separator count with some extra digit groups on the same line
+ # could still be a no-separator count with some extra digit groups on the same
+ # line
if not use_parts:
use_parts = [parts[0]]
lone = lone and len(use_parts) == len(parts)
else:
- # current count is unknown or no separator was used
+ # current count is unknown, or any detected separator unambiguously delineates
+ # the number
groups_okay = all_parts_valid
use_parts = parts