Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

black: Format raise calls #129

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 21 additions & 30 deletions src/croniter/croniter.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,11 @@ def _alphaconv(cls, index, key, expressions):
try:
return cls.ALPHACONV[index][key]
except KeyError:
raise CroniterNotAlphaError(
"[{0}] is not acceptable".format(" ".join(expressions))
)
raise CroniterNotAlphaError("[{0}] is not acceptable".format(" ".join(expressions)))

def get_next(self, ret_type=None, start_time=None, update_current=True):
if start_time and self._expand_from_start_time:
raise ValueError(
"start_time is not supported when using expand_from_start_time = True."
)
raise ValueError("start_time is not supported when using expand_from_start_time = True.")
return self._get_next(
ret_type=ret_type,
start_time=start_time,
Expand Down Expand Up @@ -382,8 +378,7 @@ def _get_next(
ret_type = ret_type or self._ret_type

if not issubclass(ret_type, (float, datetime.datetime)):
raise TypeError("Invalid ret_type, only 'float' or 'datetime' "
"is acceptable.")
raise TypeError("Invalid ret_type, only 'float' or 'datetime' is acceptable.")

# exception to support day of month and day of week as defined in cron
dom_dow_exception_processed = False
Expand Down Expand Up @@ -879,9 +874,7 @@ def _expand(
expressions = efl.split()

if len(expressions) not in VALID_LEN_EXPRESSION:
raise CroniterBadCronError(
"Exactly 5, 6 or 7 columns has to be specified for iterator expression."
)
raise CroniterBadCronError("Exactly 5, 6 or 7 columns has to be specified for iterator expression.")

if len(expressions) > UNIX_CRON_LEN and second_at_beginning:
# move second to it's own(6th) field to process by same logical
Expand All @@ -903,13 +896,13 @@ def _expand(
if "?" in expr:
if expr != "?":
raise CroniterBadCronError(
"[{0}] is not acceptable. Question mark can not "
"used with other characters".format(expr_format)
"[{0}] is not acceptable. Question mark can not used with other characters".format(expr_format)
)
if field_index not in [DAY_FIELD, DOW_FIELD]:
raise CroniterBadCronError(
"[{0}] is not acceptable. Question mark can only used "
"in day_of_month or day_of_week".format(expr_format)
"[{0}] is not acceptable. Question mark can only used in day_of_month or day_of_week".format(
expr_format
)
)
# currently just trade `?` as `*`
expr = "*"
Expand All @@ -934,8 +927,10 @@ def _expand(
assert nth >= 1 and nth <= 5
except (KeyError, ValueError, AssertionError):
raise CroniterBadCronError(
"[{0}] is not acceptable. Invalid day_of_week "
"value: '{1}'".format(expr_format, nth))
"[{0}] is not acceptable. Invalid day_of_week value: '{1}'".format(
expr_format, nth
)
)
elif last:
e = last
nth = g["pre"] # 'l'
Expand Down Expand Up @@ -980,9 +975,7 @@ def _expand(
# normally, it's already guarded by the RE that should not accept not-int values.
if not only_int_re.search(str(step)):
raise CroniterBadCronError(
"[{0}] step '{2}' in field {1} is not acceptable".format(
expr_format, field_index, step
)
"[{0}] step '{2}' in field {1} is not acceptable".format(expr_format, field_index, step)
)
step = int(step)

Expand Down Expand Up @@ -1057,10 +1050,9 @@ def _expand(
e_list += [a for a in rng if a not in e_list]
else:
if t.startswith("-"):
raise CroniterBadCronError((
"[{0}] is not acceptable,"
"negative numbers not allowed"
).format(expr_format))
raise CroniterBadCronError(
"[{0}] is not acceptable," "negative numbers not allowed".format(expr_format)
)
if not star_or_int_re.search(t):
t = cls._alphaconv(field_index, t, expressions)

Expand All @@ -1075,9 +1067,7 @@ def _expand(
int(t) < cls.RANGES[field_index][0]
or int(t) > cls.RANGES[field_index][1]
):
raise CroniterBadCronError(
"[{0}] is not acceptable, out of range".format(expr_format)
)
raise CroniterBadCronError("[{0}] is not acceptable, out of range".format(expr_format))

res.append(t)

Expand Down Expand Up @@ -1113,7 +1103,8 @@ def _expand(
):
raise CroniterUnsupportedSyntaxError(
"day-of-week field does not support mixing literal values and nth day of week syntax. "
"Cron: '{}' dow={} vs nth={}".format(expr_format, dow_expanded_set, nth_weekday_of_month))
"Cron: '{}' dow={} vs nth={}".format(expr_format, dow_expanded_set, nth_weekday_of_month)
)

EXPRESSIONS[(expr_format, hash_id, second_at_beginning)] = expressions
return expanded, nth_weekday_of_month
Expand Down Expand Up @@ -1279,8 +1270,8 @@ def croniter_range(
isinstance(start, type(stop)) or isinstance(stop, type(start))
):
raise CroniterBadTypeRangeError(
"The start and stop must be same type. {0} != {1}".
format(type(start), type(stop)))
"The start and stop must be same type. {0} != {1}".format(type(start), type(stop))
)
if isinstance(start, (float, int)):
start, stop = (
datetime.datetime.fromtimestamp(t, tzutc()).replace(tzinfo=None)
Expand Down
Loading