Skip to content

Commit 95055ce

Browse files
committed
More linter fixes
1 parent 84b9624 commit 95055ce

File tree

3 files changed

+30
-25
lines changed

3 files changed

+30
-25
lines changed

azure/durable_functions/models/DurableOrchestrationContext.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ class DurableOrchestrationContext:
5151
def __init__(self,
5252
history: List[Dict[Any, Any]], instanceId: str, isReplaying: bool,
5353
parentInstanceId: str, input: Any = None, upperSchemaVersion: int = 0,
54-
maximumShortTimerDuration:str = None, longRunningTimerIntervalDuration:str = None,
55-
upperSchemaVersionNew:int = None, **kwargs):
54+
maximumShortTimerDuration: str = None,
55+
longRunningTimerIntervalDuration: str = None, upperSchemaVersionNew: int = None,
56+
**kwargs):
5657
self._histories: List[HistoryEvent] = [HistoryEvent(**he) for he in history]
5758
self._instance_id: str = instanceId
5859
self._is_replaying: bool = isReplaying
@@ -628,14 +629,14 @@ def create_timer(self, fire_at: datetime.datetime) -> TaskBase:
628629
if self._replay_schema.value >= ReplaySchema.V3.value:
629630
if not self.maximum_short_timer_duration or not self.long_timer_interval_duration:
630631
raise Exception(
631-
"A framework-internal error was detected: " +
632-
"replay schema version >= V3 is being used, " +
633-
"but one or more of the properties `maximumShortTimerDuration`" +
634-
"and `longRunningTimerIntervalDuration` are not defined. " +
635-
"This is likely an issue with the Durable Functions Extension. " +
636-
"Please report this bug here: " +
637-
"https://github.com/Azure/azure-functions-durable-python/issues\n" +
638-
f"maximumShortTimerDuration: {self.maximum_short_timer_duration}\n" +
632+
"A framework-internal error was detected: "\
633+
"replay schema version >= V3 is being used, "\
634+
"but one or more of the properties `maximumShortTimerDuration`"\
635+
"and `longRunningTimerIntervalDuration` are not defined. "\
636+
"This is likely an issue with the Durable Functions Extension. "\
637+
"Please report this bug here: "\
638+
"https://github.com/Azure/azure-functions-durable-python/issues\n"\
639+
f"maximumShortTimerDuration: {self.maximum_short_timer_duration}\n"\
639640
f"longRunningTimerIntervalDuration: {self.long_timer_interval_duration}"
640641
)
641642
if fire_at > self.current_utc_datetime + self.maximum_short_timer_duration:
@@ -718,7 +719,7 @@ def _add_to_actions(self, action_repr: Union[List[Action], Action]):
718719

719720
if self._replay_schema is ReplaySchema.V1 and isinstance(action_repr, list):
720721
self._action_payload_v1.append(action_repr)
721-
elif (self._replay_schema.value >= ReplaySchema.V2.value
722+
elif (self._replay_schema.value >= ReplaySchema.V2.value
722723
and isinstance(action_repr, Action)):
723724
self._action_payload_v2.append(action_repr)
724725
else:

azure/durable_functions/models/Task.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,8 @@ def cancel(self):
377377
def try_set_value(self, child: TimerTask):
378378
"""Transition this LongTimer Task to a terminal state and set its value.
379379
380-
If the LongTimer has not yet reached the designated completion time, starts a new
381-
TimerTask for the next interval and does not close.
380+
If the LongTimer has not yet reached the designated completion time, starts a new
381+
TimerTask for the next interval and does not close.
382382
383383
Parameters
384384
----------
@@ -392,8 +392,8 @@ def try_set_value(self, child: TimerTask):
392392
self.add_new_child(next_timer)
393393
return super().try_set_value(child)
394394

395-
def get_next_timer_task(self, final_fire_time: datetime, current_time: datetime) -> TimerTask:
396-
"""Creates a TimerTask that represents the next interval of the LongTimer
395+
def get_next_timer_task(self, final_fire_time: datetime, current_time: datetime) -> TimerTask:
396+
"""Creates a TimerTask that represents the next interval of the LongTimer.
397397
398398
Parameters
399399
----------
@@ -415,7 +415,9 @@ def get_next_timer_task(self, final_fire_time: datetime, current_time: datetime)
415415
return TimerTask(None, CreateTimerAction(next_fire_time))
416416

417417
def add_new_child(self, child_timer: TimerTask):
418-
"""Adds the TimerTask to this Task's children and schedules it in the orchestrationcontext
418+
"""Add the TimerTask to this task's children.
419+
420+
Also register the TimerTask with the orchestration context.
419421
420422
Parameters
421423
----------
@@ -428,6 +430,7 @@ def add_new_child(self, child_timer: TimerTask):
428430
self.orchestration_context._add_to_actions(child_timer.action_repr)
429431
child_timer._set_is_scheduled(True)
430432

433+
431434
class WhenAnyTask(CompoundTask):
432435
"""A Task representing `when_any` scenarios."""
433436

azure/durable_functions/models/utils/json_utils.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,14 @@ def add_datetime_attrib(json_dict: Dict[str, Any], object_,
3838
json_dict[alt_name or attribute_name] = \
3939
getattr(object_, attribute_name).strftime(DATETIME_STRING_FORMAT)
4040

41-
# When we recieve properties from WebJobs extension originally parsed as
42-
# TimeSpan objects through Newtonsoft, the format complies with the constant
41+
42+
# When we recieve properties from WebJobs extension originally parsed as
43+
# TimeSpan objects through Newtonsoft, the format complies with the constant
4344
# format specifier for TimeSpan in .NET.
44-
# Python offers no convenient way to parse these back into timedeltas,
45+
# Python offers no convenient way to parse these back into timedeltas,
4546
# so we use this regex method instead
4647
def parse_timespan_attrib(from_str: str) -> datetime.timedelta:
47-
"""Converts a string representing TimeSpan.ToString("c") in .NET to python timespan.timedelta
48+
"""Convert a string representing TimeSpan.ToString("c") in .NET to a python timedelta.
4849
4950
Parameters
5051
----------
@@ -60,12 +61,12 @@ def parse_timespan_attrib(from_str: str) -> datetime.timedelta:
6061
match = re.match(expr, from_str)
6162
if match:
6263
span = datetime.timedelta(
63-
days=int(match.group(2) or "0"),
64-
hours=int(match.group(3)),
65-
minutes=int(match.group(4)),
66-
seconds=int(match.group(5)),
64+
days=int(match.group(2) or "0"),
65+
hours=int(match.group(3)),
66+
minutes=int(match.group(4)),
67+
seconds=int(match.group(5)),
6768
microseconds=int(match.group(6) or "0") // 10)
68-
69+
6970
if match.group(1):
7071
span = -span
7172
return span

0 commit comments

Comments
 (0)