8000 Formatting. · kubernetes-client/python@8e3d9c4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8e3d9c4

Browse files
committed
Formatting.
Signed-off-by: Flynn <emissary@flynn.kodachi.com>
1 parent 40aaae5 commit 8e3d9c4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

kubernetes/utils/duration.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
# really be a big deal.
2222
reDuration = re.compile(r'^([0-9]{1,5}(h|m|s|ms)){1,4}$')
2323

24-
# maxDuration_ms is the maximum duration that GEP-2257 can support, in milliseconds.
24+
# maxDuration_ms is the maximum duration that GEP-2257 can support, in
25+
# milliseconds.
2526
maxDuration_ms = (((99999 * 3600) + (59 * 60) + 59) * 1_000) + 999
2627

28+
2729
def parse_duration(duration) -> datetime.timedelta:
2830
"""
2931
Parse GEP-2257 Duration format to a datetime.timedelta object.
@@ -75,6 +77,7 @@ def parse_duration(duration) -> datetime.timedelta:
7577

7678
return durationpy.from_str(duration)
7779

80+
7881
def format_duration(delta: datetime.timedelta) -> str:
7982
"""
8083
Format a datetime.timedelta object to GEP-2257 Duration format.
@@ -130,7 +133,8 @@ def format_duration(delta: datetime.timedelta) -> str:
130133
raise ValueError("Cannot express negative durations in GEP-2257: {}".format(delta))
131134

132135
if delta > datetime.timedelta(milliseconds=maxDuration_ms):
133-
raise ValueError("Cannot express durations longer than 99999h59m59s999ms in GEP-2257: {}".format(delta))
136+
raise ValueError(
137+
"Cannot express durations longer than 99999h59m59s999ms in GEP-2257: {}".format(delta))
134138

135139
# durationpy.to_str() is happy to use floating-point seconds, which
136140
# GEP-2257 is _not_ happy with. So start by peeling off any microseconds
@@ -158,4 +162,3 @@ def format_duration(delta: datetime.timedelta) -> str:
158162
delta_str += f"{delta_ms}ms"
159163

160164
return delta_str
161-

0 commit comments

Comments
 (0)
0