Skip to content

Commit fa7d908

Browse files
authored
chore: roll to ToT driver (microsoft#419)
1 parent e2e93b5 commit fa7d908

File tree

13 files changed

+503
-399
lines changed

13 files changed

+503
-399
lines changed

playwright/_impl/_api_structures.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
import sys
16-
from typing import Dict, List, Optional
16+
from typing import List, Optional
1717

1818
if sys.version_info >= (3, 8): # pragma: no cover
1919
from typing import Literal, TypedDict
@@ -37,12 +37,22 @@ class Cookie(TypedDict, total=False):
3737
expires: Optional[float]
3838
httpOnly: Optional[bool]
3939
secure: Optional[bool]
40-
sameSite: Optional[Literal["Strict", "Lax", "None"]]
40+
sameSite: Optional[Literal["Lax", "None", "Strict"]]
41+
42+
43+
class LocalStorageEntry(TypedDict):
44+
name: str
45+
value: str
46+
47+
48+
class OriginState(TypedDict):
49+
origin: str
50+
localStorage: List[LocalStorageEntry]
4151

4252

4353
class StorageState(TypedDict, total=False):
4454
cookies: Optional[List[Cookie]]
45-
origins: Optional[List[Dict]]
55+
origins: Optional[List[OriginState]]
4656

4757

4858
class ResourceTiming(TypedDict):

playwright/_impl/_browser_context.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ async def unroute(
209209
)
210210

211211
async def wait_for_event(
212-
self, event: str, predicate: Callable[[Any], bool] = None, timeout: float = None
212+
self, event: str, predicate: Callable = None, timeout: float = None
213213
) -> Any:
214214
if timeout is None:
215215
timeout = self._timeout_settings.timeout()
@@ -255,7 +255,7 @@ async def storage_state(self, path: Union[str, Path] = None) -> StorageState:
255255
def expect_event(
256256
self,
257257
event: str,
258-
predicate: Callable[[Any], bool] = None,
258+
predicate: Callable = None,
259259
timeout: float = None,
260260
) -> EventContextManagerImpl:
261261
return EventContextManagerImpl(self.wait_for_event(event, predicate, timeout))

playwright/_impl/_element_handle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ async def select_text(self, timeout: float = None) -> None:
157157

158158
async def set_input_files(
159159
self,
160-
files: Union[str, Path, FilePayload, List[str], List[Path], List[FilePayload]],
160+
files: Union[str, Path, FilePayload, List[Union[str, Path]], List[FilePayload]],
161161
timeout: float = None,
162162
noWaitAfter: bool = None,
163163
) -> None:

playwright/_impl/_file_chooser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ def is_multiple(self) -> bool:
4949

5050
async def set_files(
5151
self,
52-
files: Union[str, FilePayload, List[str], List[FilePayload]],
52+
files: Union[str, Path, FilePayload, List[Union[str, Path]], List[FilePayload]],
5353
timeout: float = None,
5454
noWaitAfter: bool = None,
5555
) -> None:
5656
await self._element_handle.set_input_files(files, timeout, noWaitAfter)
5757

5858

5959
def normalize_file_payloads(
60-
files: Union[str, Path, FilePayload, List[str], List[Path], List[FilePayload]]
60+
files: Union[str, Path, FilePayload, List[Union[str, Path]], List[FilePayload]]
6161
) -> List:
6262
file_list = files if isinstance(files, list) else [files]
6363
file_payloads: List = []

playwright/_impl/_frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ async def select_option(
440440
async def set_input_files(
441441
self,
442442
selector: str,
443-
files: Union[str, Path, FilePayload, List[str], List[Path], List[FilePayload]],
443+
files: Union[str, Path, FilePayload, List[Union[str, Path]], List[FilePayload]],
444444
timeout: float = None,
445445
noWaitAfter: bool = None,
446446
) -> None:

playwright/_impl/_network.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def post_data(self) -> Optional[str]:
8080
return data.decode()
8181

8282
@property
83-
def post_data_json(self) -> Optional[Dict]:
83+
def post_data_json(self) -> Optional[Any]:
8484
post_data = self.post_data
8585
if not post_data:
8686
return None
@@ -251,7 +251,7 @@ async def text(self) -> str:
251251
content = await self.body()
252252
return content.decode()
253253

254-
async def json(self) -> Union[Dict, List]:
254+
async def json(self) -> Union[Any]:
255255
return json.loads(await self.text())
256256

257257
@property
@@ -295,7 +295,7 @@ def url(self) -> str:
295295
return self._initializer["url"]
296296

297297
async def wait_for_event(
298-
self, event: str, predicate: Callable[[Any], bool] = None, timeout: float = None
298+
self, event: str, predicate: Callable = None, timeout: float = None
299299
) -> Any:
300300
if timeout is None:
301301
timeout = cast(Any, self._parent)._timeout_settings.timeout()
@@ -317,7 +317,7 @@ async def wait_for_event(
317317
def expect_event(
318318
self,
319319
event: str,
320-
predicate: Callable[[Any], bool] = None,
320+
predicate: Callable = None,
321321
timeout: float = None,
322322
) -> EventContextManagerImpl:
323323
return EventContextManagerImpl(self.wait_for_event(event, predicate, timeout))

playwright/_impl/_page.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ def my_predicate(response: Response) -> bool:
533533
)
534534

535535
async def wait_for_event(
536-
self, event: str, predicate: Callable[[Any], bool] = None, timeout: float = None
536+
self, event: str, predicate: Callable = None, timeout: float = None
537537
) -> Any:
538538
if timeout is None:
539539
timeout = self._timeout_settings.timeout()
@@ -736,7 +736,7 @@ async def select_option(
736736
async def set_input_files(
737737
self,
738738
selector: str,
739-
files: Union[str, FilePayload, List[str], List[FilePayload]],
739+
files: Union[str, Path, FilePayload, List[Union[str, Path]], List[FilePayload]],
740740
timeout: float = None,
741741
noWaitAfter: bool = None,
742742
) -> None:
@@ -841,7 +841,7 @@ def video(
841841
def expect_event(
842842
self,
843843
event: str,
844-
predicate: Callable[[Any], bool] = None,
844+
predicate: Callable = None,
845845
timeout: float = None,
846846
) -> EventContextManagerImpl:
847847
return EventContextManagerImpl(self.wait_for_event(event, predicate, timeout))

playwright/_impl/_wait_helper.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def reject_on_event(
3030
emitter: EventEmitter,
3131
event: str,
3232
error: Error,
33-
predicate: Callable[[Any], bool] = None,
33+
predicate: Callable = None,
3434
) -> None:
3535
self.reject_on(wait_for_event_future(emitter, event, predicate), error)
3636

@@ -54,7 +54,7 @@ async def wait_for_event(
5454
self,
5555
emitter: EventEmitter,
5656
event: str,
57-
predicate: Callable[[Any], bool] = None,
57+
predicate: Callable = None,
5858
) -> Any:
5959
future = wait_for_event_future(emitter, event, predicate)
6060
return await self.wait_for_future(future)
@@ -75,7 +75,7 @@ async def wait_for_future(self, future: asyncio.Future) -> Any:
7575

7676

7777
def wait_for_event_future(
78-
emitter: EventEmitter, event: str, predicate: Callable[[Any], bool] = None
78+
emitter: EventEmitter, event: str, predicate: Callable = None
7979
) -> asyncio.Future:
8080
future: asyncio.Future = asyncio.Future()
8181

0 commit comments

Comments
 (0)