1616import fnmatch
1717import re
1818import traceback
19+ from types import TracebackType
1920
2021from typing import (
2122 Any ,
3132
3233import sys
3334
34- if sys .version_info >= (3 , 8 ):
35+ if sys .version_info >= (3 , 8 ): # pragma: no cover
3536 from typing import Literal , TypedDict
36- else :
37+ else : # pragma: no cover
3738 from typing_extensions import Literal , TypedDict
3839
3940
40- if TYPE_CHECKING :
41+ if TYPE_CHECKING : # pragma: no cover
4142 from playwright .network import Route , Request
4243
4344Cookie = List [Dict [str , Union [str , int , bool ]]]
@@ -98,7 +99,7 @@ class ParsedMessagePayload(TypedDict, total=False):
9899
99100
100101class URLMatcher :
101- def __init__ (self , match : URLMatch ):
102+ def __init__ (self , match : URLMatch ) -> None :
102103 self ._callback : Optional [Callable [[str ], bool ]] = None
103104 self ._regex_obj : Optional [Pattern ] = None
104105 if isinstance (match , str ):
@@ -124,7 +125,7 @@ def __init__(self, parent: Optional["TimeoutSettings"]) -> None:
124125 self ._timeout = 30000
125126 self ._navigation_timeout = 30000
126127
127- def set_timeout (self , timeout : int ):
128+ def set_timeout (self , timeout : int ) -> None :
128129 self ._timeout = timeout
129130
130131 def timeout (self ) -> int :
@@ -134,7 +135,7 @@ def timeout(self) -> int:
134135 return self ._parent .timeout ()
135136 return 30000
136137
137- def set_navigation_timeout (self , navigation_timeout : int ):
138+ def set_navigation_timeout (self , navigation_timeout : int ) -> None :
138139 self ._navigation_timeout = navigation_timeout
139140
140141 def navigation_timeout (self ) -> int :
@@ -155,7 +156,7 @@ class TimeoutError(Error):
155156 pass
156157
157158
158- def serialize_error (ex : Exception , tb ) -> ErrorPayload :
159+ def serialize_error (ex : Exception , tb : Optional [ TracebackType ] ) -> ErrorPayload :
159160 return dict (message = str (ex ), stack = "" .join (traceback .format_tb (tb )))
160161
161162
@@ -193,7 +194,7 @@ def __init__(
193194 self .future = future
194195 self .timeout_future = timeout_future
195196
196- def reject (self , is_crash : bool , target : str ):
197+ def reject (self , is_crash : bool , target : str ) -> None :
197198 self .timeout_future .cancel ()
198199 if self .event == "close" and not is_crash :
199200 return
0 commit comments