@@ -386,13 +386,15 @@ def _get_next(
386
386
387
387
# exception to support day of month and day of week as defined in cron
388
388
dom_dow_exception_processed = False
389
- if (expanded [DAY_FIELD ][0 ] != "*" and expanded [DOW_FIELD ][0 ] != "*" ) and self ._day_or :
389
+ if (
390
+ expanded [DAY_FIELD ][0 ] != "*" and expanded [DOW_FIELD ][0 ] != "*"
391
+ ) and self ._day_or :
390
392
# If requested, handle a bug in vixie cron/ISC cron where day_of_month and day_of_week form
391
393
# an intersection (AND) instead of a union (OR) if either field is an asterisk or starts with an asterisk
392
394
# (https://crontab.guru/cron-bug.html)
393
- if (
394
- self ._implement_cron_bug and
395
- ( re_star . match ( self . expressions [ DAY_FIELD ]) or re_star .match (self .expressions [DOW_FIELD ]) )
395
+ if self . _implement_cron_bug and (
396
+ re_star . match ( self .expressions [ DAY_FIELD ])
397
+ or re_star .match (self .expressions [DOW_FIELD ])
396
398
):
397
399
# To produce a schedule identical to the cron bug, we'll bypass the code that
398
400
# makes a union of DOM and DOW, and instead skip to the code that does an intersect instead
@@ -433,15 +435,17 @@ def _get_next(
433
435
)
434
436
hours_before_midnight = 24 - dtstarttime .hour
435
437
if dtresult_utcoffset != dtstarttime_utcoffset :
436
- if (
437
- (lag > 0 and abs (lag_hours ) >= hours_before_midnight )
438
- or (lag < 0 and
439
- ((3600 * abs (lag_hours ) + abs (lag )) >= hours_before_midnight * 3600 ))
438
+ if (lag > 0 and abs (lag_hours ) >= hours_before_midnight ) or (
439
+ lag < 0
440
+ and ((3600 * abs (lag_hours ) + abs (lag )) >= hours_before_midnight * 3600 )
440
441
):
441
442
dtresult_adjusted = dtresult - datetime .timedelta (seconds = lag )
442
443
result_adjusted = self ._datetime_to_timestamp (dtresult_adjusted )
443
444
# Do the actual adjust only if the result time actually exists
444
- if self ._timestamp_to_datetime (result_adjusted ).tzinfo == dtresult_adjusted .tzinfo :
445
+ if (
446
+ self ._timestamp_to_datetime (result_adjusted ).tzinfo
447
+ == dtresult_adjusted .tzinfo
448
+ ):
445
449
dtresult = dtresult_adjusted
446
450
result = result_adjusted
447
451
self .dst_start_time = result
@@ -642,9 +646,8 @@ def proc_day_of_week_nth(d):
642
646
continue
643
647
else :
644
648
candidate = c [n - 1 ]
645
- if (
646
- (is_prev and candidate <= d .day ) or
647
- (not is_prev and d .day <= candidate )
649
+ if (is_prev and candidate <= d .day ) or (
650
+ not is_prev and d .day <= candidate
648
651
):
649
652
candidates .append (candidate )
650
653
@@ -997,8 +1000,8 @@ def _expand(
997
1000
998
1001
low , high = [cls .value_alias (int (_val ), field_index , expressions ) for _val in (low , high )]
999
1002
1000
- if (
1001
- max ( low , high ) > max ( cls .RANGES [field_index ][0 ], cls .RANGES [field_index ][1 ])
1003
+ if max ( low , high ) > max (
1004
+ cls .RANGES [field_index ][0 ], cls .RANGES [field_index ][1 ]
1002
1005
):
1003
1006
raise CroniterBadCronError (
1004
1007
"{0} is out of bands" .format (expr_format )
@@ -1027,7 +1030,9 @@ def _expand(
1027
1030
if rng :
1028
1031
already_skipped = list (reversed (whole_field_range )).index (rng [- 1 ])
1029
1032
curpos = whole_field_range .index (rng [- 1 ])
1030
- if ((curpos + step ) > len (whole_field_range )) and (already_skipped < step ):
1033
+ if ((curpos + step ) > len (whole_field_range )) and (
1034
+ already_skipped < step
1035
+ ):
1031
1036
to_skip = step - already_skipped
1032
1037
rng += list (
1033
1038
range (cls .RANGES [field_index ][0 ] + to_skip , high + 1 , step )
@@ -1067,10 +1072,9 @@ def _expand(
1067
1072
1068
1073
t = cls .value_alias (t , field_index , expressions )
1069
1074
1070
- if (
1071
- t not in ["*" , "l" ]
1072
- and (int (t ) < cls .RANGES [field_index ][0 ] or
1073
- int (t ) > cls .RANGES [field_index ][1 ])
1075
+ if t not in ["*" , "l" ] and (
1076
+ int (t ) < cls .RANGES [field_index ][0 ]
1077
+ or int (t ) > cls .RANGES [field_index ][1 ]
1074
1078
):
1075
1079
raise CroniterBadCronError (
1076
1080
"[{0}] is not acceptable, out of range" .format (expr_format )
@@ -1089,9 +1093,8 @@ def _expand(
1089
1093
)
1090
1094
if len (res ) == cls .LEN_MEANS_ALL [field_index ]:
1091
1095
# Make sure the wildcard is used in the correct way (avoid over-optimization)
1092
- if (
1093
- (field_index == DAY_FIELD and "*" not in expressions [DOW_FIELD ]) or
1094
- (field_index == DOW_FIELD and "*" not in expressions [DAY_FIELD ])
1096
+ if (field_index == DAY_FIELD and "*" not in expressions [DOW_FIELD ]) or (
1097
+ field_index == DOW_FIELD and "*" not in expressions [DAY_FIELD ]
1095
1098
):
1096
1099
pass
1097
1100
else :
@@ -1105,7 +1108,10 @@ def _expand(
1105
1108
dow_expanded_set = dow_expanded_set .difference (nth_weekday_of_month .keys ())
1106
1109
dow_expanded_set .discard ("*" )
1107
1110
# Skip: if it's all weeks instead of wildcard
1108
- if dow_expanded_set and len (set (expanded [DOW_FIELD ])) != cls .LEN_MEANS_ALL [DOW_FIELD ]:
1111
+ if (
1112
+ dow_expanded_set
1113
+ and len (set (expanded [DOW_FIELD ])) != cls .LEN_MEANS_ALL [DOW_FIELD ]
1114
+ ):
1109
1115
raise CroniterUnsupportedSyntaxError (
1110
1116
"day-of-week field does not support mixing literal values and nth day of week syntax. "
1111
1117
"Cron: '{}' dow={} vs nth={}" .format (expr_format , dow_expanded_set , nth_weekday_of_month ))
@@ -1270,10 +1276,8 @@ def croniter_range(
1270
1276
_croniter = _croniter or croniter
1271
1277
auto_rt = datetime .datetime
1272
1278
# type is used in first if branch for perfs reasons
1273
- if (
1274
- type (start ) is not type (stop ) and not (
1275
- isinstance (start , type (stop )) or
1276
- isinstance (stop , type (start )))
1279
+ if type (start ) is not type (stop ) and not (
1280
+ isinstance (start , type (stop )) or isinstance (stop , type (start ))
1277
1281
):
1278
1282
raise CroniterBadTypeRangeError (
1279
1283
"The start and stop must be same type. {0} != {1}" .
0 commit comments