Skip to content

Commit 9df9fac

Browse files
Skn0ttCopilot
andauthored
feat: accept datetime.timedelta for timeout parameters (#3059)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 856ae37 commit 9df9fac

6 files changed

Lines changed: 1578 additions & 876 deletions

File tree

playwright/_impl/_helper.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
import asyncio
15+
import datetime
1516
import math
1617
import os
1718
import re
@@ -574,3 +575,13 @@ def is_file_payload(value: Optional[Any]) -> bool:
574575

575576
def is_textual_mime_type(mime_type: str) -> bool:
576577
return bool(TEXTUAL_MIME_TYPE.match(mime_type))
578+
579+
580+
def to_milliseconds(
581+
value: Union[float, datetime.timedelta, None],
582+
) -> Optional[float]:
583+
if value is None:
584+
return None
585+
if isinstance(value, datetime.timedelta):
586+
return value / datetime.timedelta(milliseconds=1)
587+
return value

0 commit comments

Comments
 (0)