File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -221,7 +221,8 @@ def parse_duration(value: Union[str, int]) -> int:
221
221
The number of milliseconds in the duration.
222
222
223
223
Raises:
224
- TypeError, if given something other than an integer or a string
224
+ TypeError: if given something other than an integer or a string, or the
225
+ duration is using an incorrect suffix.
225
226
ValueError: if given a string not of the form described above.
226
227
"""
227
228
if type (value ) is int : # noqa: E721
@@ -246,6 +247,15 @@ def parse_duration(value: Union[str, int]) -> int:
246
247
if suffix in sizes :
247
248
value = value [:- 1 ]
248
249
size = sizes [suffix ]
250
+ elif suffix .isdigit ():
251
+ # No suffix is treated as milliseconds.
252
+ value = value
253
+ size = 1
254
+ else :
255
+ raise TypeError (
256
+ f"Bad duration suffix { value } (expected no suffix or one of these suffixes: { sizes .keys ()} )"
257
+ )
258
+
249
259
return int (value ) * size
250
260
else :
251
261
raise TypeError (f"Bad duration { value !r} " )
You can’t perform that action at this time.
0 commit comments