diff --git a/playwright/_impl/_api_structures.py b/playwright/_impl/_api_structures.py index a3240ee5c..f45f713a1 100644 --- a/playwright/_impl/_api_structures.py +++ b/playwright/_impl/_api_structures.py @@ -13,7 +13,7 @@ # limitations under the License. import sys -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, Sequence, Union if sys.version_info >= (3, 8): # pragma: no cover from typing import Literal, TypedDict @@ -185,7 +185,7 @@ class ExpectedTextValue(TypedDict, total=False): class FrameExpectOptions(TypedDict, total=False): expressionArg: Any - expectedText: Optional[List[ExpectedTextValue]] + expectedText: Optional[Sequence[ExpectedTextValue]] expectedNumber: Optional[float] expectedValue: Optional[Any] useInnerText: Optional[bool] diff --git a/playwright/_impl/_assertions.py b/playwright/_impl/_assertions.py index d3e3f9e03..73dc76000 100644 --- a/playwright/_impl/_assertions.py +++ b/playwright/_impl/_assertions.py @@ -12,7 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import Any, List, Optional, Pattern, Union +import collections.abc +from typing import Any, List, Optional, Pattern, Sequence, Union from urllib.parse import urljoin from playwright._impl._api_structures import ExpectedTextValue, FrameExpectOptions @@ -149,9 +150,9 @@ def _not(self) -> "LocatorAssertions": async def to_contain_text( self, expected: Union[ - List[str], - List[Pattern[str]], - List[Union[Pattern[str], str]], + Sequence[str], + Sequence[Pattern[str]], + Sequence[Union[Pattern[str], str]], Pattern[str], str, ], @@ -160,7 +161,9 @@ async def to_contain_text( ignore_case: bool = None, ) -> None: __tracebackhide__ = True - if isinstance(expected, list): + if isinstance(expected, collections.abc.Sequence) and not isinstance( + expected, str + ): expected_text = to_expected_text_values( expected, match_substring=True, @@ -198,9 +201,9 @@ async def to_contain_text( async def not_to_contain_text( self, expected: Union[ - List[str], - List[Pattern[str]], - List[Union[Pattern[str], str]], + Sequence[str], + Sequence[Pattern[str]], + Sequence[Union[Pattern[str], str]], Pattern[str], str, ], @@ -244,16 +247,18 @@ async def not_to_have_attribute( async def to_have_class( self, expected: Union[ - List[str], - List[Pattern[str]], - List[Union[Pattern[str], str]], + Sequence[str], + Sequence[Pattern[str]], + Sequence[Union[Pattern[str], str]], Pattern[str], str, ], timeout: float = None, ) -> None: __tracebackhide__ = True - if isinstance(expected, list): + if isinstance(expected, collections.abc.Sequence) and not isinstance( + expected, str + ): expected_text = to_expected_text_values(expected) await self._expect_impl( "to.have.class.array", @@ -273,9 +278,9 @@ async def to_have_class( async def not_to_have_class( self, expected: Union[ - List[str], - List[Pattern[str]], - List[Union[Pattern[str], str]], + Sequence[str], + Sequence[Pattern[str]], + Sequence[Union[Pattern[str], str]], Pattern[str], str, ], @@ -402,7 +407,9 @@ async def not_to_have_value( async def to_have_values( self, - values: Union[List[str], List[Pattern[str]], List[Union[Pattern[str], str]]], + values: Union[ + Sequence[str], Sequence[Pattern[str]], Sequence[Union[Pattern[str], str]] + ], timeout: float = None, ) -> None: __tracebackhide__ = True @@ -416,7 +423,9 @@ async def to_have_values( async def not_to_have_values( self, - values: Union[List[str], List[Pattern[str]], List[Union[Pattern[str], str]]], + values: Union[ + Sequence[str], Sequence[Pattern[str]], Sequence[Union[Pattern[str], str]] + ], timeout: float = None, ) -> None: __tracebackhide__ = True @@ -425,9 +434,9 @@ async def not_to_have_values( async def to_have_text( self, expected: Union[ - List[str], - List[Pattern[str]], - List[Union[Pattern[str], str]], + Sequence[str], + Sequence[Pattern[str]], + Sequence[Union[Pattern[str], str]], Pattern[str], str, ], @@ -436,7 +445,9 @@ async def to_have_text( ignore_case: bool = None, ) -> None: __tracebackhide__ = True - if isinstance(expected, list): + if isinstance(expected, collections.abc.Sequence) and not isinstance( + expected, str + ): expected_text = to_expected_text_values( expected, normalize_white_space=True, @@ -470,9 +481,9 @@ async def to_have_text( async def not_to_have_text( self, expected: Union[ - List[str], - List[Pattern[str]], - List[Union[Pattern[str], str]], + Sequence[str], + Sequence[Pattern[str]], + Sequence[Union[Pattern[str], str]], Pattern[str], str, ], @@ -758,11 +769,13 @@ def expected_regex( def to_expected_text_values( - items: Union[List[Pattern[str]], List[str], List[Union[str, Pattern[str]]]], + items: Union[ + Sequence[Pattern[str]], Sequence[str], Sequence[Union[str, Pattern[str]]] + ], match_substring: bool = False, normalize_white_space: bool = False, ignore_case: Optional[bool] = None, -) -> List[ExpectedTextValue]: +) -> Sequence[ExpectedTextValue]: out: List[ExpectedTextValue] = [] assert isinstance(items, list) for item in items: diff --git a/playwright/_impl/_browser.py b/playwright/_impl/_browser.py index 2fd9a8c50..8a248f703 100644 --- a/playwright/_impl/_browser.py +++ b/playwright/_impl/_browser.py @@ -15,7 +15,7 @@ import json from pathlib import Path from types import SimpleNamespace -from typing import TYPE_CHECKING, Dict, List, Optional, Pattern, Union, cast +from typing import TYPE_CHECKING, Dict, List, Optional, Pattern, Sequence, Union, cast from playwright._impl._api_structures import ( Geolocation, @@ -96,7 +96,7 @@ async def new_context( locale: str = None, timezoneId: str = None, geolocation: Geolocation = None, - permissions: List[str] = None, + permissions: Sequence[str] = None, extraHTTPHeaders: Dict[str, str] = None, offline: bool = None, httpCredentials: HttpCredentials = None, @@ -141,7 +141,7 @@ async def new_page( locale: str = None, timezoneId: str = None, geolocation: Geolocation = None, - permissions: List[str] = None, + permissions: Sequence[str] = None, extraHTTPHeaders: Dict[str, str] = None, offline: bool = None, httpCredentials: HttpCredentials = None, @@ -200,7 +200,7 @@ async def start_tracing( page: Page = None, path: Union[str, Path] = None, screenshots: bool = None, - categories: List[str] = None, + categories: Sequence[str] = None, ) -> None: params = locals_to_params(locals()) if page: diff --git a/playwright/_impl/_browser_context.py b/playwright/_impl/_browser_context.py index d978b1201..74ceac9a1 100644 --- a/playwright/_impl/_browser_context.py +++ b/playwright/_impl/_browser_context.py @@ -25,6 +25,7 @@ List, Optional, Pattern, + Sequence, Set, Union, cast, @@ -284,21 +285,21 @@ async def new_page(self) -> Page: raise Error("Please use browser.new_context()") return from_channel(await self._channel.send("newPage")) - async def cookies(self, urls: Union[str, List[str]] = None) -> List[Cookie]: + async def cookies(self, urls: Union[str, Sequence[str]] = None) -> List[Cookie]: if urls is None: urls = [] - if not isinstance(urls, list): + if isinstance(urls, str): urls = [urls] return await self._channel.send("cookies", dict(urls=urls)) - async def add_cookies(self, cookies: List[SetCookieParam]) -> None: + async def add_cookies(self, cookies: Sequence[SetCookieParam]) -> None: await self._channel.send("addCookies", dict(cookies=cookies)) async def clear_cookies(self) -> None: await self._channel.send("clearCookies") async def grant_permissions( - self, permissions: List[str], origin: str = None + self, permissions: Sequence[str], origin: str = None ) -> None: await self._channel.send("grantPermissions", locals_to_params(locals())) diff --git a/playwright/_impl/_browser_type.py b/playwright/_impl/_browser_type.py index 49013df29..28a0e7cb4 100644 --- a/playwright/_impl/_browser_type.py +++ b/playwright/_impl/_browser_type.py @@ -15,7 +15,7 @@ import asyncio import pathlib from pathlib import Path -from typing import TYPE_CHECKING, Dict, List, Optional, Pattern, Union, cast +from typing import TYPE_CHECKING, Dict, Optional, Pattern, Sequence, Union, cast from playwright._impl._api_structures import ( Geolocation, @@ -72,8 +72,8 @@ async def launch( self, executablePath: Union[str, Path] = None, channel: str = None, - args: List[str] = None, - ignoreDefaultArgs: Union[bool, List[str]] = None, + args: Sequence[str] = None, + ignoreDefaultArgs: Union[bool, Sequence[str]] = None, handleSIGINT: bool = None, handleSIGTERM: bool = None, handleSIGHUP: bool = None, @@ -101,8 +101,8 @@ async def launch_persistent_context( userDataDir: Union[str, Path], channel: str = None, executablePath: Union[str, Path] = None, - args: List[str] = None, - ignoreDefaultArgs: Union[bool, List[str]] = None, + args: Sequence[str] = None, + ignoreDefaultArgs: Union[bool, Sequence[str]] = None, handleSIGINT: bool = None, handleSIGTERM: bool = None, handleSIGHUP: bool = None, @@ -123,7 +123,7 @@ async def launch_persistent_context( locale: str = None, timezoneId: str = None, geolocation: Geolocation = None, - permissions: List[str] = None, + permissions: Sequence[str] = None, extraHTTPHeaders: Dict[str, str] = None, offline: bool = None, httpCredentials: HttpCredentials = None, diff --git a/playwright/_impl/_connection.py b/playwright/_impl/_connection.py index 4c6bac00a..f1e0dd34f 100644 --- a/playwright/_impl/_connection.py +++ b/playwright/_impl/_connection.py @@ -13,6 +13,7 @@ # limitations under the License. import asyncio +import collections.abc import contextvars import datetime import inspect @@ -455,7 +456,9 @@ def _replace_channels_with_guids( return payload if isinstance(payload, Path): return str(payload) - if isinstance(payload, list): + if isinstance(payload, collections.abc.Sequence) and not isinstance( + payload, str + ): return list(map(self._replace_channels_with_guids, payload)) if isinstance(payload, Channel): return dict(guid=payload._guid) diff --git a/playwright/_impl/_element_handle.py b/playwright/_impl/_element_handle.py index 3636f3529..03e49eb04 100644 --- a/playwright/_impl/_element_handle.py +++ b/playwright/_impl/_element_handle.py @@ -15,7 +15,17 @@ import base64 import sys from pathlib import Path -from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Union, cast +from typing import ( + TYPE_CHECKING, + Any, + Callable, + Dict, + List, + Optional, + Sequence, + Union, + cast, +) from playwright._impl._api_structures import FilePayload, FloatRect, Position from playwright._impl._connection import ChannelOwner, from_nullable_channel @@ -103,7 +113,7 @@ async def scroll_into_view_if_needed(self, timeout: float = None) -> None: async def hover( self, - modifiers: List[KeyboardModifier] = None, + modifiers: Sequence[KeyboardModifier] = None, position: Position = None, timeout: float = None, noWaitAfter: bool = None, @@ -114,7 +124,7 @@ async def hover( async def click( self, - modifiers: List[KeyboardModifier] = None, + modifiers: Sequence[KeyboardModifier] = None, position: Position = None, delay: float = None, button: MouseButton = None, @@ -128,7 +138,7 @@ async def click( async def dblclick( self, - modifiers: List[KeyboardModifier] = None, + modifiers: Sequence[KeyboardModifier] = None, position: Position = None, delay: float = None, button: MouseButton = None, @@ -141,10 +151,10 @@ async def dblclick( async def select_option( self, - value: Union[str, List[str]] = None, - index: Union[int, List[int]] = None, - label: Union[str, List[str]] = None, - element: Union["ElementHandle", List["ElementHandle"]] = None, + value: Union[str, Sequence[str]] = None, + index: Union[int, Sequence[int]] = None, + label: Union[str, Sequence[str]] = None, + element: Union["ElementHandle", Sequence["ElementHandle"]] = None, timeout: float = None, force: bool = None, noWaitAfter: bool = None, @@ -161,7 +171,7 @@ async def select_option( async def tap( self, - modifiers: List[KeyboardModifier] = None, + modifiers: Sequence[KeyboardModifier] = None, position: Position = None, timeout: float = None, force: bool = None, @@ -187,7 +197,9 @@ async def input_value(self, timeout: float = None) -> str: async def set_input_files( self, - files: Union[str, Path, FilePayload, List[Union[str, Path]], List[FilePayload]], + files: Union[ + str, Path, FilePayload, Sequence[Union[str, Path]], Sequence[FilePayload] + ], timeout: float = None, noWaitAfter: bool = None, ) -> None: @@ -284,7 +296,7 @@ async def screenshot( animations: Literal["allow", "disabled"] = None, caret: Literal["hide", "initial"] = None, scale: Literal["css", "device"] = None, - mask: List["Locator"] = None, + mask: Sequence["Locator"] = None, mask_color: str = None, ) -> bytes: params = locals_to_params(locals()) @@ -378,10 +390,10 @@ async def wait_for_selector( def convert_select_option_values( - value: Union[str, List[str]] = None, - index: Union[int, List[int]] = None, - label: Union[str, List[str]] = None, - element: Union["ElementHandle", List["ElementHandle"]] = None, + value: Union[str, Sequence[str]] = None, + index: Union[int, Sequence[int]] = None, + label: Union[str, Sequence[str]] = None, + element: Union["ElementHandle", Sequence["ElementHandle"]] = None, ) -> Any: if value is None and index is None and label is None and element is None: return {} @@ -389,19 +401,19 @@ def convert_select_option_values( options: Any = None elements: Any = None if value: - if not isinstance(value, list): + if isinstance(value, str): value = [value] options = (options or []) + list(map(lambda e: dict(valueOrLabel=e), value)) if index: - if not isinstance(index, list): + if isinstance(index, int): index = [index] options = (options or []) + list(map(lambda e: dict(index=e), index)) if label: - if not isinstance(label, list): + if isinstance(label, str): label = [label] options = (options or []) + list(map(lambda e: dict(label=e), label)) if element: - if not isinstance(element, list): + if isinstance(element, ElementHandle): element = [element] elements = list(map(lambda e: e._channel, element)) diff --git a/playwright/_impl/_file_chooser.py b/playwright/_impl/_file_chooser.py index a15050fc0..951919d22 100644 --- a/playwright/_impl/_file_chooser.py +++ b/playwright/_impl/_file_chooser.py @@ -13,7 +13,7 @@ # limitations under the License. from pathlib import Path -from typing import TYPE_CHECKING, List, Union +from typing import TYPE_CHECKING, Sequence, Union from playwright._impl._api_structures import FilePayload @@ -48,7 +48,9 @@ def is_multiple(self) -> bool: async def set_files( self, - files: Union[str, Path, FilePayload, List[Union[str, Path]], List[FilePayload]], + files: Union[ + str, Path, FilePayload, Sequence[Union[str, Path]], Sequence[FilePayload] + ], timeout: float = None, noWaitAfter: bool = None, ) -> None: diff --git a/playwright/_impl/_frame.py b/playwright/_impl/_frame.py index 7fde8c4ef..2cfbb7240 100644 --- a/playwright/_impl/_frame.py +++ b/playwright/_impl/_frame.py @@ -15,7 +15,18 @@ import asyncio import sys from pathlib import Path -from typing import TYPE_CHECKING, Any, Dict, List, Optional, Pattern, Set, Union, cast +from typing import ( + TYPE_CHECKING, + Any, + Dict, + List, + Optional, + Pattern, + Sequence, + Set, + Union, + cast, +) from pyee import EventEmitter @@ -469,7 +480,7 @@ async def add_style_tag( async def click( self, selector: str, - modifiers: List[KeyboardModifier] = None, + modifiers: Sequence[KeyboardModifier] = None, position: Position = None, delay: float = None, button: MouseButton = None, @@ -485,7 +496,7 @@ async def click( async def dblclick( self, selector: str, - modifiers: List[KeyboardModifier] = None, + modifiers: Sequence[KeyboardModifier] = None, position: Position = None, delay: float = None, button: MouseButton = None, @@ -500,7 +511,7 @@ async def dblclick( async def tap( self, selector: str, - modifiers: List[KeyboardModifier] = None, + modifiers: Sequence[KeyboardModifier] = None, position: Position = None, timeout: float = None, force: bool = None, @@ -625,7 +636,7 @@ async def get_attribute( async def hover( self, selector: str, - modifiers: List[KeyboardModifier] = None, + modifiers: Sequence[KeyboardModifier] = None, position: Position = None, timeout: float = None, noWaitAfter: bool = None, @@ -652,10 +663,10 @@ async def drag_and_drop( async def select_option( self, selector: str, - value: Union[str, List[str]] = None, - index: Union[int, List[int]] = None, - label: Union[str, List[str]] = None, - element: Union["ElementHandle", List["ElementHandle"]] = None, + value: Union[str, Sequence[str]] = None, + index: Union[int, Sequence[int]] = None, + label: Union[str, Sequence[str]] = None, + element: Union["ElementHandle", Sequence["ElementHandle"]] = None, timeout: float = None, noWaitAfter: bool = None, strict: bool = None, @@ -684,7 +695,9 @@ async def input_value( async def set_input_files( self, selector: str, - files: Union[str, Path, FilePayload, List[Union[str, Path]], List[FilePayload]], + files: Union[ + str, Path, FilePayload, Sequence[Union[str, Path]], Sequence[FilePayload] + ], strict: bool = None, timeout: float = None, noWaitAfter: bool = None, diff --git a/playwright/_impl/_impl_to_api_mapping.py b/playwright/_impl/_impl_to_api_mapping.py index 60a748fdc..4315e1868 100644 --- a/playwright/_impl/_impl_to_api_mapping.py +++ b/playwright/_impl/_impl_to_api_mapping.py @@ -13,7 +13,7 @@ # limitations under the License. import inspect -from typing import Any, Callable, Dict, List, Optional, Union +from typing import Any, Callable, Dict, List, Optional, Sequence, Union from playwright._impl._errors import Error from playwright._impl._map import Map @@ -81,7 +81,7 @@ def from_impl(self, obj: Any) -> Any: def from_impl_nullable(self, obj: Any = None) -> Optional[Any]: return self.from_impl(obj) if obj else None - def from_impl_list(self, items: List[Any]) -> List[Any]: + def from_impl_list(self, items: Sequence[Any]) -> List[Any]: return list(map(lambda a: self.from_impl(a), items)) def from_impl_dict(self, map: Dict[str, Any]) -> Dict[str, Any]: diff --git a/playwright/_impl/_js_handle.py b/playwright/_impl/_js_handle.py index b23b61ced..4bd8146b1 100644 --- a/playwright/_impl/_js_handle.py +++ b/playwright/_impl/_js_handle.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import collections.abc import math from datetime import datetime from typing import TYPE_CHECKING, Any, Dict, List, Optional @@ -140,7 +141,7 @@ def serialize_value( if value in visitor_info.visited: return dict(ref=visitor_info.visited[value]) - if isinstance(value, list): + if isinstance(value, collections.abc.Sequence) and not isinstance(value, str): id = visitor_info.visit(value) a = [] for e in value: diff --git a/playwright/_impl/_locator.py b/playwright/_impl/_locator.py index 7591ff116..3f9fa5ce3 100644 --- a/playwright/_impl/_locator.py +++ b/playwright/_impl/_locator.py @@ -25,6 +25,7 @@ List, Optional, Pattern, + Sequence, Tuple, TypeVar, Union, @@ -144,7 +145,7 @@ async def check( async def click( self, - modifiers: List[KeyboardModifier] = None, + modifiers: Sequence[KeyboardModifier] = None, position: Position = None, delay: float = None, button: MouseButton = None, @@ -159,7 +160,7 @@ async def click( async def dblclick( self, - modifiers: List[KeyboardModifier] = None, + modifiers: Sequence[KeyboardModifier] = None, position: Position = None, delay: float = None, button: MouseButton = None, @@ -415,7 +416,7 @@ async def get_attribute(self, name: str, timeout: float = None) -> Optional[str] async def hover( self, - modifiers: List[KeyboardModifier] = None, + modifiers: Sequence[KeyboardModifier] = None, position: Position = None, timeout: float = None, noWaitAfter: bool = None, @@ -521,7 +522,7 @@ async def screenshot( animations: Literal["allow", "disabled"] = None, caret: Literal["hide", "initial"] = None, scale: Literal["css", "device"] = None, - mask: List["Locator"] = None, + mask: Sequence["Locator"] = None, mask_color: str = None, ) -> bytes: params = locals_to_params(locals()) @@ -542,10 +543,10 @@ async def scroll_into_view_if_needed( async def select_option( self, - value: Union[str, List[str]] = None, - index: Union[int, List[int]] = None, - label: Union[str, List[str]] = None, - element: Union["ElementHandle", List["ElementHandle"]] = None, + value: Union[str, Sequence[str]] = None, + index: Union[int, Sequence[int]] = None, + label: Union[str, Sequence[str]] = None, + element: Union["ElementHandle", Sequence["ElementHandle"]] = None, timeout: float = None, noWaitAfter: bool = None, force: bool = None, @@ -572,8 +573,8 @@ async def set_input_files( str, pathlib.Path, FilePayload, - List[Union[str, pathlib.Path]], - List[FilePayload], + Sequence[Union[str, pathlib.Path]], + Sequence[FilePayload], ], timeout: float = None, noWaitAfter: bool = None, @@ -587,7 +588,7 @@ async def set_input_files( async def tap( self, - modifiers: List[KeyboardModifier] = None, + modifiers: Sequence[KeyboardModifier] = None, position: Position = None, timeout: float = None, force: bool = None, diff --git a/playwright/_impl/_page.py b/playwright/_impl/_page.py index 8c9f4557a..2bfae2090 100644 --- a/playwright/_impl/_page.py +++ b/playwright/_impl/_page.py @@ -27,6 +27,7 @@ List, Optional, Pattern, + Sequence, Union, cast, ) @@ -636,7 +637,7 @@ async def screenshot( animations: Literal["allow", "disabled"] = None, caret: Literal["hide", "initial"] = None, scale: Literal["css", "device"] = None, - mask: List["Locator"] = None, + mask: Sequence["Locator"] = None, mask_color: str = None, ) -> bytes: params = locals_to_params(locals()) @@ -680,7 +681,7 @@ def is_closed(self) -> bool: async def click( self, selector: str, - modifiers: List[KeyboardModifier] = None, + modifiers: Sequence[KeyboardModifier] = None, position: Position = None, delay: float = None, button: MouseButton = None, @@ -696,7 +697,7 @@ async def click( async def dblclick( self, selector: str, - modifiers: List[KeyboardModifier] = None, + modifiers: Sequence[KeyboardModifier] = None, position: Position = None, delay: float = None, button: MouseButton = None, @@ -711,7 +712,7 @@ async def dblclick( async def tap( self, selector: str, - modifiers: List[KeyboardModifier] = None, + modifiers: Sequence[KeyboardModifier] = None, position: Position = None, timeout: float = None, force: bool = None, @@ -833,7 +834,7 @@ async def get_attribute( async def hover( self, selector: str, - modifiers: List[KeyboardModifier] = None, + modifiers: Sequence[KeyboardModifier] = None, position: Position = None, timeout: float = None, noWaitAfter: bool = None, @@ -860,10 +861,10 @@ async def drag_and_drop( async def select_option( self, selector: str, - value: Union[str, List[str]] = None, - index: Union[int, List[int]] = None, - label: Union[str, List[str]] = None, - element: Union["ElementHandle", List["ElementHandle"]] = None, + value: Union[str, Sequence[str]] = None, + index: Union[int, Sequence[int]] = None, + label: Union[str, Sequence[str]] = None, + element: Union["ElementHandle", Sequence["ElementHandle"]] = None, timeout: float = None, noWaitAfter: bool = None, force: bool = None, @@ -881,7 +882,9 @@ async def input_value( async def set_input_files( self, selector: str, - files: Union[str, Path, FilePayload, List[Union[str, Path]], List[FilePayload]], + files: Union[ + str, Path, FilePayload, Sequence[Union[str, Path]], Sequence[FilePayload] + ], timeout: float = None, strict: bool = None, noWaitAfter: bool = None, diff --git a/playwright/_impl/_set_input_files_helpers.py b/playwright/_impl/_set_input_files_helpers.py index b1e929252..a5db6c1da 100644 --- a/playwright/_impl/_set_input_files_helpers.py +++ b/playwright/_impl/_set_input_files_helpers.py @@ -12,10 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. import base64 +import collections.abc import os import sys from pathlib import Path -from typing import TYPE_CHECKING, Dict, List, Optional, Union, cast +from typing import TYPE_CHECKING, Dict, List, Optional, Sequence, Union, cast if sys.version_info >= (3, 8): # pragma: no cover from typing import TypedDict @@ -41,10 +42,16 @@ class InputFilesList(TypedDict, total=False): async def convert_input_files( - files: Union[str, Path, FilePayload, List[Union[str, Path]], List[FilePayload]], + files: Union[ + str, Path, FilePayload, Sequence[Union[str, Path]], Sequence[FilePayload] + ], context: "BrowserContext", ) -> InputFilesList: - items = files if isinstance(files, list) else [files] + items = ( + files + if isinstance(files, collections.abc.Sequence) and not isinstance(files, str) + else [files] + ) if any([isinstance(item, (str, Path)) for item in items]): if not all([isinstance(item, (str, Path)) for item in items]): diff --git a/playwright/async_api/_generated.py b/playwright/async_api/_generated.py index 4f0fae513..3ab7a143f 100644 --- a/playwright/async_api/_generated.py +++ b/playwright/async_api/_generated.py @@ -1986,7 +1986,7 @@ async def hover( self, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, timeout: typing.Optional[float] = None, @@ -2009,7 +2009,7 @@ async def hover( Parameters ---------- - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -2044,7 +2044,7 @@ async def click( self, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, delay: typing.Optional[float] = None, @@ -2070,7 +2070,7 @@ async def click( Parameters ---------- - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -2114,7 +2114,7 @@ async def dblclick( self, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, delay: typing.Optional[float] = None, @@ -2142,7 +2142,7 @@ async def dblclick( Parameters ---------- - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -2181,12 +2181,12 @@ async def dblclick( async def select_option( self, - value: typing.Optional[typing.Union[str, typing.List[str]]] = None, + value: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, *, - index: typing.Optional[typing.Union[int, typing.List[int]]] = None, - label: typing.Optional[typing.Union[str, typing.List[str]]] = None, + index: typing.Optional[typing.Union[int, typing.Sequence[int]]] = None, + label: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, element: typing.Optional[ - typing.Union["ElementHandle", typing.List["ElementHandle"]] + typing.Union["ElementHandle", typing.Sequence["ElementHandle"]] ] = None, timeout: typing.Optional[float] = None, force: typing.Optional[bool] = None, @@ -2228,15 +2228,15 @@ async def select_option( Parameters ---------- - value : Union[List[str], str, None] + value : Union[Sequence[str], str, None] Options to select by value. If the `` has the `multiple` attribute, all given options are selected, otherwise only the first option matching one of the passed options is selected. Optional. - element : Union[ElementHandle, List[ElementHandle], None] + element : Union[ElementHandle, Sequence[ElementHandle], None] Option elements to select. Optional. timeout : Union[float, None] Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can @@ -2269,7 +2269,7 @@ async def tap( self, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, timeout: typing.Optional[float] = None, @@ -2294,7 +2294,7 @@ async def tap( Parameters ---------- - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -2424,8 +2424,8 @@ async def set_input_files( str, pathlib.Path, FilePayload, - typing.List[typing.Union[str, pathlib.Path]], - typing.List[FilePayload], + typing.Sequence[typing.Union[str, pathlib.Path]], + typing.Sequence[FilePayload], ], *, timeout: typing.Optional[float] = None, @@ -2443,7 +2443,7 @@ async def set_input_files( Parameters ---------- - files : Union[List[Union[pathlib.Path, str]], List[{name: str, mimeType: str, buffer: bytes}], pathlib.Path, str, {name: str, mimeType: str, buffer: bytes}] + files : Union[Sequence[Union[pathlib.Path, str]], Sequence[{name: str, mimeType: str, buffer: bytes}], pathlib.Path, str, {name: str, mimeType: str, buffer: bytes}] timeout : Union[float, None] Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods. @@ -2768,7 +2768,7 @@ async def screenshot( animations: typing.Optional[Literal["allow", "disabled"]] = None, caret: typing.Optional[Literal["hide", "initial"]] = None, scale: typing.Optional[Literal["css", "device"]] = None, - mask: typing.Optional[typing.List["Locator"]] = None, + mask: typing.Optional[typing.Sequence["Locator"]] = None, mask_color: typing.Optional[str] = None ) -> bytes: """ElementHandle.screenshot @@ -2814,7 +2814,7 @@ async def screenshot( screenshots of high-dpi devices will be twice as large or even larger. Defaults to `"device"`. - mask : Union[List[Locator], None] + mask : Union[Sequence[Locator], None] Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box `#FF00FF` (customized by `maskColor`) that completely covers its bounding box. mask_color : Union[str, None] @@ -3222,8 +3222,8 @@ async def set_files( str, pathlib.Path, FilePayload, - typing.List[typing.Union[str, pathlib.Path]], - typing.List[FilePayload], + typing.Sequence[typing.Union[str, pathlib.Path]], + typing.Sequence[FilePayload], ], *, timeout: typing.Optional[float] = None, @@ -3236,7 +3236,7 @@ async def set_files( Parameters ---------- - files : Union[List[Union[pathlib.Path, str]], List[{name: str, mimeType: str, buffer: bytes}], pathlib.Path, str, {name: str, mimeType: str, buffer: bytes}] + files : Union[Sequence[Union[pathlib.Path, str]], Sequence[{name: str, mimeType: str, buffer: bytes}], pathlib.Path, str, {name: str, mimeType: str, buffer: bytes}] timeout : Union[float, None] Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods. @@ -4399,7 +4399,7 @@ async def click( selector: str, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, delay: typing.Optional[float] = None, @@ -4429,7 +4429,7 @@ async def click( selector : str A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -4479,7 +4479,7 @@ async def dblclick( selector: str, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, delay: typing.Optional[float] = None, @@ -4511,7 +4511,7 @@ async def dblclick( selector : str A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -4558,7 +4558,7 @@ async def tap( selector: str, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, timeout: typing.Optional[float] = None, @@ -4587,7 +4587,7 @@ async def tap( selector : str A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -5448,7 +5448,7 @@ async def hover( selector: str, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, timeout: typing.Optional[float] = None, @@ -5475,7 +5475,7 @@ async def hover( selector : str A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -5574,12 +5574,12 @@ async def drag_and_drop( async def select_option( self, selector: str, - value: typing.Optional[typing.Union[str, typing.List[str]]] = None, + value: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, *, - index: typing.Optional[typing.Union[int, typing.List[int]]] = None, - label: typing.Optional[typing.Union[str, typing.List[str]]] = None, + index: typing.Optional[typing.Union[int, typing.Sequence[int]]] = None, + label: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, element: typing.Optional[ - typing.Union["ElementHandle", typing.List["ElementHandle"]] + typing.Union["ElementHandle", typing.Sequence["ElementHandle"]] ] = None, timeout: typing.Optional[float] = None, no_wait_after: typing.Optional[bool] = None, @@ -5624,15 +5624,15 @@ async def select_option( ---------- selector : str A selector to query for. - value : Union[List[str], str, None] + value : Union[Sequence[str], str, None] Options to select by value. If the `` has the `multiple` attribute, all given options are selected, otherwise only the first option matching one of the passed options is selected. Optional. - element : Union[ElementHandle, List[ElementHandle], None] + element : Union[ElementHandle, Sequence[ElementHandle], None] Option elements to select. Optional. timeout : Union[float, None] Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can @@ -5711,8 +5711,8 @@ async def set_input_files( str, pathlib.Path, FilePayload, - typing.List[typing.Union[str, pathlib.Path]], - typing.List[FilePayload], + typing.Sequence[typing.Union[str, pathlib.Path]], + typing.Sequence[FilePayload], ], *, strict: typing.Optional[bool] = None, @@ -5734,7 +5734,7 @@ async def set_input_files( selector : str A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. - files : Union[List[Union[pathlib.Path, str]], List[{name: str, mimeType: str, buffer: bytes}], pathlib.Path, str, {name: str, mimeType: str, buffer: bytes}] + files : Union[Sequence[Union[pathlib.Path, str]], Sequence[{name: str, mimeType: str, buffer: bytes}], pathlib.Path, str, {name: str, mimeType: str, buffer: bytes}] strict : Union[bool, None] When true, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception. @@ -9923,7 +9923,7 @@ async def screenshot( animations: typing.Optional[Literal["allow", "disabled"]] = None, caret: typing.Optional[Literal["hide", "initial"]] = None, scale: typing.Optional[Literal["css", "device"]] = None, - mask: typing.Optional[typing.List["Locator"]] = None, + mask: typing.Optional[typing.Sequence["Locator"]] = None, mask_color: typing.Optional[str] = None ) -> bytes: """Page.screenshot @@ -9967,7 +9967,7 @@ async def screenshot( screenshots of high-dpi devices will be twice as large or even larger. Defaults to `"device"`. - mask : Union[List[Locator], None] + mask : Union[Sequence[Locator], None] Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box `#FF00FF` (customized by `maskColor`) that completely covers its bounding box. mask_color : Union[str, None] @@ -10054,7 +10054,7 @@ async def click( selector: str, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, delay: typing.Optional[float] = None, @@ -10084,7 +10084,7 @@ async def click( selector : str A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -10134,7 +10134,7 @@ async def dblclick( selector: str, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, delay: typing.Optional[float] = None, @@ -10166,7 +10166,7 @@ async def dblclick( selector : str A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -10213,7 +10213,7 @@ async def tap( selector: str, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, timeout: typing.Optional[float] = None, @@ -10242,7 +10242,7 @@ async def tap( selector : str A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -11101,7 +11101,7 @@ async def hover( selector: str, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, timeout: typing.Optional[float] = None, @@ -11128,7 +11128,7 @@ async def hover( selector : str A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -11254,12 +11254,12 @@ async def drag_and_drop( async def select_option( self, selector: str, - value: typing.Optional[typing.Union[str, typing.List[str]]] = None, + value: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, *, - index: typing.Optional[typing.Union[int, typing.List[int]]] = None, - label: typing.Optional[typing.Union[str, typing.List[str]]] = None, + index: typing.Optional[typing.Union[int, typing.Sequence[int]]] = None, + label: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, element: typing.Optional[ - typing.Union["ElementHandle", typing.List["ElementHandle"]] + typing.Union["ElementHandle", typing.Sequence["ElementHandle"]] ] = None, timeout: typing.Optional[float] = None, no_wait_after: typing.Optional[bool] = None, @@ -11305,15 +11305,15 @@ async def select_option( selector : str A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. - value : Union[List[str], str, None] + value : Union[Sequence[str], str, None] Options to select by value. If the `` has the `multiple` attribute, all given options are selected, otherwise only the first option matching one of the passed options is selected. Optional. - element : Union[ElementHandle, List[ElementHandle], None] + element : Union[ElementHandle, Sequence[ElementHandle], None] Option elements to select. Optional. timeout : Union[float, None] Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can @@ -11392,8 +11392,8 @@ async def set_input_files( str, pathlib.Path, FilePayload, - typing.List[typing.Union[str, pathlib.Path]], - typing.List[FilePayload], + typing.Sequence[typing.Union[str, pathlib.Path]], + typing.Sequence[FilePayload], ], *, timeout: typing.Optional[float] = None, @@ -11415,7 +11415,7 @@ async def set_input_files( selector : str A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. - files : Union[List[Union[pathlib.Path, str]], List[{name: str, mimeType: str, buffer: bytes}], pathlib.Path, str, {name: str, mimeType: str, buffer: bytes}] + files : Union[Sequence[Union[pathlib.Path, str]], Sequence[{name: str, mimeType: str, buffer: bytes}], pathlib.Path, str, {name: str, mimeType: str, buffer: bytes}] timeout : Union[float, None] Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods. @@ -13063,7 +13063,7 @@ async def new_page(self) -> "Page": return mapping.from_impl(await self._impl_obj.new_page()) async def cookies( - self, urls: typing.Optional[typing.Union[str, typing.List[str]]] = None + self, urls: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None ) -> typing.List[Cookie]: """BrowserContext.cookies @@ -13072,7 +13072,7 @@ async def cookies( Parameters ---------- - urls : Union[List[str], str, None] + urls : Union[Sequence[str], str, None] Optional list of URLs. Returns @@ -13084,7 +13084,7 @@ async def cookies( await self._impl_obj.cookies(urls=mapping.to_impl(urls)) ) - async def add_cookies(self, cookies: typing.List[SetCookieParam]) -> None: + async def add_cookies(self, cookies: typing.Sequence[SetCookieParam]) -> None: """BrowserContext.add_cookies Adds cookies into this browser context. All pages within this context will have these cookies installed. Cookies @@ -13102,7 +13102,7 @@ async def add_cookies(self, cookies: typing.List[SetCookieParam]) -> None: Parameters ---------- - cookies : List[{name: str, value: str, url: Union[str, None], domain: Union[str, None], path: Union[str, None], expires: Union[float, None], httpOnly: Union[bool, None], secure: Union[bool, None], sameSite: Union["Lax", "None", "Strict", None]}] + cookies : Sequence[{name: str, value: str, url: Union[str, None], domain: Union[str, None], path: Union[str, None], expires: Union[float, None], httpOnly: Union[bool, None], secure: Union[bool, None], sameSite: Union["Lax", "None", "Strict", None]}] Adds cookies to the browser context. For the cookie to apply to all subdomains as well, prefix domain with a dot, like this: ".example.com". @@ -13121,7 +13121,7 @@ async def clear_cookies(self) -> None: return mapping.from_maybe_impl(await self._impl_obj.clear_cookies()) async def grant_permissions( - self, permissions: typing.List[str], *, origin: typing.Optional[str] = None + self, permissions: typing.Sequence[str], *, origin: typing.Optional[str] = None ) -> None: """BrowserContext.grant_permissions @@ -13130,7 +13130,7 @@ async def grant_permissions( Parameters ---------- - permissions : List[str] + permissions : Sequence[str] A permission or an array of permissions to grant. Permissions can be one of the following values: - `'geolocation'` - `'midi'` @@ -14039,7 +14039,7 @@ async def new_context( locale: typing.Optional[str] = None, timezone_id: typing.Optional[str] = None, geolocation: typing.Optional[Geolocation] = None, - permissions: typing.Optional[typing.List[str]] = None, + permissions: typing.Optional[typing.Sequence[str]] = None, extra_http_headers: typing.Optional[typing.Dict[str, str]] = None, offline: typing.Optional[bool] = None, http_credentials: typing.Optional[HttpCredentials] = None, @@ -14137,7 +14137,7 @@ async def new_context( [ICU's metaZones.txt](https://cs.chromium.org/chromium/src/third_party/icu/source/data/misc/metaZones.txt?rcl=faee8bc70570192d82d2978a71e2a615788597d1) for a list of supported timezone IDs. Defaults to the system timezone. geolocation : Union[{latitude: float, longitude: float, accuracy: Union[float, None]}, None] - permissions : Union[List[str], None] + permissions : Union[Sequence[str], None] A list of permissions to grant to all pages in this context. See `browser_context.grant_permissions()` for more details. Defaults to none. extra_http_headers : Union[Dict[str, str], None] @@ -14191,7 +14191,7 @@ async def new_context( Dimensions of the recorded videos. If not specified the size will be equal to `viewport` scaled down to fit into 800x800. If `viewport` is not configured explicitly the video size defaults to 800x450. Actual picture of each page will be scaled down if necessary to fit the specified size. - storage_state : Union[pathlib.Path, str, {cookies: List[{name: str, value: str, domain: str, path: str, expires: float, httpOnly: bool, secure: bool, sameSite: Union["Lax", "None", "Strict"]}], origins: List[{origin: str, localStorage: List[{name: str, value: str}]}]}, None] + storage_state : Union[pathlib.Path, str, {cookies: Sequence[{name: str, value: str, domain: str, path: str, expires: float, httpOnly: bool, secure: bool, sameSite: Union["Lax", "None", "Strict"]}], origins: Sequence[{origin: str, localStorage: Sequence[{name: str, value: str}]}]}, None] Learn more about [storage state and auth](../auth.md). Populates context with given storage state. This option can be used to initialize context with logged-in @@ -14282,7 +14282,7 @@ async def new_page( locale: typing.Optional[str] = None, timezone_id: typing.Optional[str] = None, geolocation: typing.Optional[Geolocation] = None, - permissions: typing.Optional[typing.List[str]] = None, + permissions: typing.Optional[typing.Sequence[str]] = None, extra_http_headers: typing.Optional[typing.Dict[str, str]] = None, offline: typing.Optional[bool] = None, http_credentials: typing.Optional[HttpCredentials] = None, @@ -14351,7 +14351,7 @@ async def new_page( [ICU's metaZones.txt](https://cs.chromium.org/chromium/src/third_party/icu/source/data/misc/metaZones.txt?rcl=faee8bc70570192d82d2978a71e2a615788597d1) for a list of supported timezone IDs. Defaults to the system timezone. geolocation : Union[{latitude: float, longitude: float, accuracy: Union[float, None]}, None] - permissions : Union[List[str], None] + permissions : Union[Sequence[str], None] A list of permissions to grant to all pages in this context. See `browser_context.grant_permissions()` for more details. Defaults to none. extra_http_headers : Union[Dict[str, str], None] @@ -14405,7 +14405,7 @@ async def new_page( Dimensions of the recorded videos. If not specified the size will be equal to `viewport` scaled down to fit into 800x800. If `viewport` is not configured explicitly the video size defaults to 800x450. Actual picture of each page will be scaled down if necessary to fit the specified size. - storage_state : Union[pathlib.Path, str, {cookies: List[{name: str, value: str, domain: str, path: str, expires: float, httpOnly: bool, secure: bool, sameSite: Union["Lax", "None", "Strict"]}], origins: List[{origin: str, localStorage: List[{name: str, value: str}]}]}, None] + storage_state : Union[pathlib.Path, str, {cookies: Sequence[{name: str, value: str, domain: str, path: str, expires: float, httpOnly: bool, secure: bool, sameSite: Union["Lax", "None", "Strict"]}], origins: Sequence[{origin: str, localStorage: Sequence[{name: str, value: str}]}]}, None] Learn more about [storage state and auth](../auth.md). Populates context with given storage state. This option can be used to initialize context with logged-in @@ -14526,7 +14526,7 @@ async def start_tracing( page: typing.Optional["Page"] = None, path: typing.Optional[typing.Union[str, pathlib.Path]] = None, screenshots: typing.Optional[bool] = None, - categories: typing.Optional[typing.List[str]] = None + categories: typing.Optional[typing.Sequence[str]] = None ) -> None: """Browser.start_tracing @@ -14560,7 +14560,7 @@ async def start_tracing( A path to write the trace file to. screenshots : Union[bool, None] captures screenshots in the trace. - categories : Union[List[str], None] + categories : Union[Sequence[str], None] specify custom categories to use instead of default. """ @@ -14624,9 +14624,9 @@ async def launch( *, executable_path: typing.Optional[typing.Union[str, pathlib.Path]] = None, channel: typing.Optional[str] = None, - args: typing.Optional[typing.List[str]] = None, + args: typing.Optional[typing.Sequence[str]] = None, ignore_default_args: typing.Optional[ - typing.Union[bool, typing.List[str]] + typing.Union[bool, typing.Sequence[str]] ] = None, handle_sigint: typing.Optional[bool] = None, handle_sigterm: typing.Optional[bool] = None, @@ -14689,10 +14689,10 @@ async def launch( Browser distribution channel. Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge", "msedge-beta", "msedge-dev", "msedge-canary". Read more about using [Google Chrome and Microsoft Edge](../browsers.md#google-chrome--microsoft-edge). - args : Union[List[str], None] + args : Union[Sequence[str], None] Additional arguments to pass to the browser instance. The list of Chromium flags can be found [here](http://peter.sh/experiments/chromium-command-line-switches/). - ignore_default_args : Union[List[str], bool, None] + ignore_default_args : Union[Sequence[str], bool, None] If `true`, Playwright does not pass its own configurations args and only uses the ones from `args`. If an array is given, then filters out the given default arguments. Dangerous option; use with care. Defaults to `false`. handle_sigint : Union[bool, None] @@ -14764,9 +14764,9 @@ async def launch_persistent_context( *, channel: typing.Optional[str] = None, executable_path: typing.Optional[typing.Union[str, pathlib.Path]] = None, - args: typing.Optional[typing.List[str]] = None, + args: typing.Optional[typing.Sequence[str]] = None, ignore_default_args: typing.Optional[ - typing.Union[bool, typing.List[str]] + typing.Union[bool, typing.Sequence[str]] ] = None, handle_sigint: typing.Optional[bool] = None, handle_sigterm: typing.Optional[bool] = None, @@ -14788,7 +14788,7 @@ async def launch_persistent_context( locale: typing.Optional[str] = None, timezone_id: typing.Optional[str] = None, geolocation: typing.Optional[Geolocation] = None, - permissions: typing.Optional[typing.List[str]] = None, + permissions: typing.Optional[typing.Sequence[str]] = None, extra_http_headers: typing.Optional[typing.Dict[str, str]] = None, offline: typing.Optional[bool] = None, http_credentials: typing.Optional[HttpCredentials] = None, @@ -14844,10 +14844,10 @@ async def launch_persistent_context( Path to a browser executable to run instead of the bundled one. If `executablePath` is a relative path, then it is resolved relative to the current working directory. Note that Playwright only works with the bundled Chromium, Firefox or WebKit, use at your own risk. - args : Union[List[str], None] + args : Union[Sequence[str], None] Additional arguments to pass to the browser instance. The list of Chromium flags can be found [here](http://peter.sh/experiments/chromium-command-line-switches/). - ignore_default_args : Union[List[str], bool, None] + ignore_default_args : Union[Sequence[str], bool, None] If `true`, Playwright does not pass its own configurations args and only uses the ones from `args`. If an array is given, then filters out the given default arguments. Dangerous option; use with care. Defaults to `false`. handle_sigint : Union[bool, None] @@ -14904,7 +14904,7 @@ async def launch_persistent_context( [ICU's metaZones.txt](https://cs.chromium.org/chromium/src/third_party/icu/source/data/misc/metaZones.txt?rcl=faee8bc70570192d82d2978a71e2a615788597d1) for a list of supported timezone IDs. Defaults to the system timezone. geolocation : Union[{latitude: float, longitude: float, accuracy: Union[float, None]}, None] - permissions : Union[List[str], None] + permissions : Union[Sequence[str], None] A list of permissions to grant to all pages in this context. See `browser_context.grant_permissions()` for more details. Defaults to none. extra_http_headers : Union[Dict[str, str], None] @@ -15620,7 +15620,7 @@ async def click( self, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, delay: typing.Optional[float] = None, @@ -15676,7 +15676,7 @@ async def click( Parameters ---------- - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -15720,7 +15720,7 @@ async def dblclick( self, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, delay: typing.Optional[float] = None, @@ -15752,7 +15752,7 @@ async def dblclick( Parameters ---------- - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -17097,7 +17097,7 @@ async def hover( self, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, timeout: typing.Optional[float] = None, @@ -17134,7 +17134,7 @@ async def hover( Parameters ---------- - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -17509,7 +17509,7 @@ async def screenshot( animations: typing.Optional[Literal["allow", "disabled"]] = None, caret: typing.Optional[Literal["hide", "initial"]] = None, scale: typing.Optional[Literal["css", "device"]] = None, - mask: typing.Optional[typing.List["Locator"]] = None, + mask: typing.Optional[typing.Sequence["Locator"]] = None, mask_color: typing.Optional[str] = None ) -> bytes: """Locator.screenshot @@ -17579,7 +17579,7 @@ async def screenshot( screenshots of high-dpi devices will be twice as large or even larger. Defaults to `"device"`. - mask : Union[List[Locator], None] + mask : Union[Sequence[Locator], None] Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box `#FF00FF` (customized by `maskColor`) that completely covers its bounding box. mask_color : Union[str, None] @@ -17628,12 +17628,12 @@ async def scroll_into_view_if_needed( async def select_option( self, - value: typing.Optional[typing.Union[str, typing.List[str]]] = None, + value: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, *, - index: typing.Optional[typing.Union[int, typing.List[int]]] = None, - label: typing.Optional[typing.Union[str, typing.List[str]]] = None, + index: typing.Optional[typing.Union[int, typing.Sequence[int]]] = None, + label: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, element: typing.Optional[ - typing.Union["ElementHandle", typing.List["ElementHandle"]] + typing.Union["ElementHandle", typing.Sequence["ElementHandle"]] ] = None, timeout: typing.Optional[float] = None, no_wait_after: typing.Optional[bool] = None, @@ -17687,15 +17687,15 @@ async def select_option( Parameters ---------- - value : Union[List[str], str, None] + value : Union[Sequence[str], str, None] Options to select by value. If the `` has the `multiple` attribute, all given options are selected, otherwise only the first option matching one of the passed options is selected. Optional. - element : Union[ElementHandle, List[ElementHandle], None] + element : Union[ElementHandle, Sequence[ElementHandle], None] Option elements to select. Optional. timeout : Union[float, None] Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can @@ -17758,8 +17758,8 @@ async def set_input_files( str, pathlib.Path, FilePayload, - typing.List[typing.Union[str, pathlib.Path]], - typing.List[FilePayload], + typing.Sequence[typing.Union[str, pathlib.Path]], + typing.Sequence[FilePayload], ], *, timeout: typing.Optional[float] = None, @@ -17819,7 +17819,7 @@ async def set_input_files( Parameters ---------- - files : Union[List[Union[pathlib.Path, str]], List[{name: str, mimeType: str, buffer: bytes}], pathlib.Path, str, {name: str, mimeType: str, buffer: bytes}] + files : Union[Sequence[Union[pathlib.Path, str]], Sequence[{name: str, mimeType: str, buffer: bytes}], pathlib.Path, str, {name: str, mimeType: str, buffer: bytes}] timeout : Union[float, None] Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods. @@ -17839,7 +17839,7 @@ async def tap( self, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, timeout: typing.Optional[float] = None, @@ -17868,7 +17868,7 @@ async def tap( Parameters ---------- - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -19107,7 +19107,7 @@ async def new_context( timeout : Union[float, None] Maximum time in milliseconds to wait for the response. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. - storage_state : Union[pathlib.Path, str, {cookies: List[{name: str, value: str, domain: str, path: str, expires: float, httpOnly: bool, secure: bool, sameSite: Union["Lax", "None", "Strict"]}], origins: List[{origin: str, localStorage: List[{name: str, value: str}]}]}, None] + storage_state : Union[pathlib.Path, str, {cookies: Sequence[{name: str, value: str, domain: str, path: str, expires: float, httpOnly: bool, secure: bool, sameSite: Union["Lax", "None", "Strict"]}], origins: Sequence[{origin: str, localStorage: Sequence[{name: str, value: str}]}]}, None] Populates context with given storage state. This option can be used to initialize context with logged-in information obtained via `browser_context.storage_state()` or `a_pi_request_context.storage_state()`. Either a path to the file with saved storage, or the value returned by one of @@ -19280,9 +19280,9 @@ class LocatorAssertions(AsyncBase): async def to_contain_text( self, expected: typing.Union[ - typing.List[str], - typing.List[typing.Pattern[str]], - typing.List[typing.Union[typing.Pattern[str], str]], + typing.Sequence[str], + typing.Sequence[typing.Pattern[str]], + typing.Sequence[typing.Union[typing.Pattern[str], str]], typing.Pattern[str], str, ], @@ -19373,7 +19373,7 @@ async def to_contain_text( Parameters ---------- - expected : Union[List[Pattern[str]], List[Union[Pattern[str], str]], List[str], Pattern[str], str] + expected : Union[Pattern[str], Sequence[Pattern[str]], Sequence[Union[Pattern[str], str]], Sequence[str], str] Expected substring or RegExp or a list of those. use_inner_text : Union[bool, None] Whether to use `element.innerText` instead of `element.textContent` when retrieving DOM node text. @@ -19397,9 +19397,9 @@ async def to_contain_text( async def not_to_contain_text( self, expected: typing.Union[ - typing.List[str], - typing.List[typing.Pattern[str]], - typing.List[typing.Union[typing.Pattern[str], str]], + typing.Sequence[str], + typing.Sequence[typing.Pattern[str]], + typing.Sequence[typing.Union[typing.Pattern[str], str]], typing.Pattern[str], str, ], @@ -19414,7 +19414,7 @@ async def not_to_contain_text( Parameters ---------- - expected : Union[List[Pattern[str]], List[Union[Pattern[str], str]], List[str], Pattern[str], str] + expected : Union[Pattern[str], Sequence[Pattern[str]], Sequence[Union[Pattern[str], str]], Sequence[str], str] Expected substring or RegExp or a list of those. use_inner_text : Union[bool, None] Whether to use `element.innerText` instead of `element.textContent` when retrieving DOM node text. @@ -19518,9 +19518,9 @@ async def not_to_have_attribute( async def to_have_class( self, expected: typing.Union[ - typing.List[str], - typing.List[typing.Pattern[str]], - typing.List[typing.Union[typing.Pattern[str], str]], + typing.Sequence[str], + typing.Sequence[typing.Pattern[str]], + typing.Sequence[typing.Union[typing.Pattern[str], str]], typing.Pattern[str], str, ], @@ -19572,7 +19572,7 @@ async def to_have_class( Parameters ---------- - expected : Union[List[Pattern[str]], List[Union[Pattern[str], str]], List[str], Pattern[str], str] + expected : Union[Pattern[str], Sequence[Pattern[str]], Sequence[Union[Pattern[str], str]], Sequence[str], str] Expected class or RegExp or a list of those. timeout : Union[float, None] Time to retry the assertion for in milliseconds. Defaults to `5000`. @@ -19588,9 +19588,9 @@ async def to_have_class( async def not_to_have_class( self, expected: typing.Union[ - typing.List[str], - typing.List[typing.Pattern[str]], - typing.List[typing.Union[typing.Pattern[str], str]], + typing.Sequence[str], + typing.Sequence[typing.Pattern[str]], + typing.Sequence[typing.Union[typing.Pattern[str], str]], typing.Pattern[str], str, ], @@ -19603,7 +19603,7 @@ async def not_to_have_class( Parameters ---------- - expected : Union[List[Pattern[str]], List[Union[Pattern[str], str]], List[str], Pattern[str], str] + expected : Union[Pattern[str], Sequence[Pattern[str]], Sequence[Union[Pattern[str], str]], Sequence[str], str] Expected class or RegExp or a list of those. timeout : Union[float, None] Time to retry the assertion for in milliseconds. Defaults to `5000`. @@ -19937,9 +19937,9 @@ async def not_to_have_value( async def to_have_values( self, values: typing.Union[ - typing.List[str], - typing.List[typing.Pattern[str]], - typing.List[typing.Union[typing.Pattern[str], str]], + typing.Sequence[str], + typing.Sequence[typing.Pattern[str]], + typing.Sequence[typing.Union[typing.Pattern[str], str]], ], *, timeout: typing.Optional[float] = None @@ -19981,7 +19981,7 @@ async def to_have_values( Parameters ---------- - values : Union[List[Pattern[str]], List[Union[Pattern[str], str]], List[str]] + values : Union[Sequence[Pattern[str]], Sequence[Union[Pattern[str], str]], Sequence[str]] Expected options currently selected. timeout : Union[float, None] Time to retry the assertion for in milliseconds. Defaults to `5000`. @@ -19997,9 +19997,9 @@ async def to_have_values( async def not_to_have_values( self, values: typing.Union[ - typing.List[str], - typing.List[typing.Pattern[str]], - typing.List[typing.Union[typing.Pattern[str], str]], + typing.Sequence[str], + typing.Sequence[typing.Pattern[str]], + typing.Sequence[typing.Union[typing.Pattern[str], str]], ], *, timeout: typing.Optional[float] = None @@ -20010,7 +20010,7 @@ async def not_to_have_values( Parameters ---------- - values : Union[List[Pattern[str]], List[Union[Pattern[str], str]], List[str]] + values : Union[Sequence[Pattern[str]], Sequence[Union[Pattern[str], str]], Sequence[str]] Expected options currently selected. timeout : Union[float, None] Time to retry the assertion for in milliseconds. Defaults to `5000`. @@ -20026,9 +20026,9 @@ async def not_to_have_values( async def to_have_text( self, expected: typing.Union[ - typing.List[str], - typing.List[typing.Pattern[str]], - typing.List[typing.Union[typing.Pattern[str], str]], + typing.Sequence[str], + typing.Sequence[typing.Pattern[str]], + typing.Sequence[typing.Union[typing.Pattern[str], str]], typing.Pattern[str], str, ], @@ -20118,7 +20118,7 @@ async def to_have_text( Parameters ---------- - expected : Union[List[Pattern[str]], List[Union[Pattern[str], str]], List[str], Pattern[str], str] + expected : Union[Pattern[str], Sequence[Pattern[str]], Sequence[Union[Pattern[str], str]], Sequence[str], str] Expected string or RegExp or a list of those. use_inner_text : Union[bool, None] Whether to use `element.innerText` instead of `element.textContent` when retrieving DOM node text. @@ -20142,9 +20142,9 @@ async def to_have_text( async def not_to_have_text( self, expected: typing.Union[ - typing.List[str], - typing.List[typing.Pattern[str]], - typing.List[typing.Union[typing.Pattern[str], str]], + typing.Sequence[str], + typing.Sequence[typing.Pattern[str]], + typing.Sequence[typing.Union[typing.Pattern[str], str]], typing.Pattern[str], str, ], @@ -20159,7 +20159,7 @@ async def not_to_have_text( Parameters ---------- - expected : Union[List[Pattern[str]], List[Union[Pattern[str], str]], List[str], Pattern[str], str] + expected : Union[Pattern[str], Sequence[Pattern[str]], Sequence[Union[Pattern[str], str]], Sequence[str], str] Expected string or RegExp or a list of those. use_inner_text : Union[bool, None] Whether to use `element.innerText` instead of `element.textContent` when retrieving DOM node text. diff --git a/playwright/sync_api/_generated.py b/playwright/sync_api/_generated.py index a0c3ead75..af78b6a72 100644 --- a/playwright/sync_api/_generated.py +++ b/playwright/sync_api/_generated.py @@ -1994,7 +1994,7 @@ def hover( self, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, timeout: typing.Optional[float] = None, @@ -2017,7 +2017,7 @@ def hover( Parameters ---------- - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -2054,7 +2054,7 @@ def click( self, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, delay: typing.Optional[float] = None, @@ -2080,7 +2080,7 @@ def click( Parameters ---------- - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -2126,7 +2126,7 @@ def dblclick( self, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, delay: typing.Optional[float] = None, @@ -2154,7 +2154,7 @@ def dblclick( Parameters ---------- - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -2195,12 +2195,12 @@ def dblclick( def select_option( self, - value: typing.Optional[typing.Union[str, typing.List[str]]] = None, + value: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, *, - index: typing.Optional[typing.Union[int, typing.List[int]]] = None, - label: typing.Optional[typing.Union[str, typing.List[str]]] = None, + index: typing.Optional[typing.Union[int, typing.Sequence[int]]] = None, + label: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, element: typing.Optional[ - typing.Union["ElementHandle", typing.List["ElementHandle"]] + typing.Union["ElementHandle", typing.Sequence["ElementHandle"]] ] = None, timeout: typing.Optional[float] = None, force: typing.Optional[bool] = None, @@ -2242,15 +2242,15 @@ def select_option( Parameters ---------- - value : Union[List[str], str, None] + value : Union[Sequence[str], str, None] Options to select by value. If the `` has the `multiple` attribute, all given options are selected, otherwise only the first option matching one of the passed options is selected. Optional. - element : Union[ElementHandle, List[ElementHandle], None] + element : Union[ElementHandle, Sequence[ElementHandle], None] Option elements to select. Optional. timeout : Union[float, None] Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can @@ -2285,7 +2285,7 @@ def tap( self, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, timeout: typing.Optional[float] = None, @@ -2310,7 +2310,7 @@ def tap( Parameters ---------- - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -2444,8 +2444,8 @@ def set_input_files( str, pathlib.Path, FilePayload, - typing.List[typing.Union[str, pathlib.Path]], - typing.List[FilePayload], + typing.Sequence[typing.Union[str, pathlib.Path]], + typing.Sequence[FilePayload], ], *, timeout: typing.Optional[float] = None, @@ -2463,7 +2463,7 @@ def set_input_files( Parameters ---------- - files : Union[List[Union[pathlib.Path, str]], List[{name: str, mimeType: str, buffer: bytes}], pathlib.Path, str, {name: str, mimeType: str, buffer: bytes}] + files : Union[Sequence[Union[pathlib.Path, str]], Sequence[{name: str, mimeType: str, buffer: bytes}], pathlib.Path, str, {name: str, mimeType: str, buffer: bytes}] timeout : Union[float, None] Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods. @@ -2802,7 +2802,7 @@ def screenshot( animations: typing.Optional[Literal["allow", "disabled"]] = None, caret: typing.Optional[Literal["hide", "initial"]] = None, scale: typing.Optional[Literal["css", "device"]] = None, - mask: typing.Optional[typing.List["Locator"]] = None, + mask: typing.Optional[typing.Sequence["Locator"]] = None, mask_color: typing.Optional[str] = None ) -> bytes: """ElementHandle.screenshot @@ -2848,7 +2848,7 @@ def screenshot( screenshots of high-dpi devices will be twice as large or even larger. Defaults to `"device"`. - mask : Union[List[Locator], None] + mask : Union[Sequence[Locator], None] Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box `#FF00FF` (customized by `maskColor`) that completely covers its bounding box. mask_color : Union[str, None] @@ -3268,8 +3268,8 @@ def set_files( str, pathlib.Path, FilePayload, - typing.List[typing.Union[str, pathlib.Path]], - typing.List[FilePayload], + typing.Sequence[typing.Union[str, pathlib.Path]], + typing.Sequence[FilePayload], ], *, timeout: typing.Optional[float] = None, @@ -3282,7 +3282,7 @@ def set_files( Parameters ---------- - files : Union[List[Union[pathlib.Path, str]], List[{name: str, mimeType: str, buffer: bytes}], pathlib.Path, str, {name: str, mimeType: str, buffer: bytes}] + files : Union[Sequence[Union[pathlib.Path, str]], Sequence[{name: str, mimeType: str, buffer: bytes}], pathlib.Path, str, {name: str, mimeType: str, buffer: bytes}] timeout : Union[float, None] Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods. @@ -4481,7 +4481,7 @@ def click( selector: str, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, delay: typing.Optional[float] = None, @@ -4511,7 +4511,7 @@ def click( selector : str A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -4563,7 +4563,7 @@ def dblclick( selector: str, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, delay: typing.Optional[float] = None, @@ -4595,7 +4595,7 @@ def dblclick( selector : str A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -4644,7 +4644,7 @@ def tap( selector: str, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, timeout: typing.Optional[float] = None, @@ -4673,7 +4673,7 @@ def tap( selector : str A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -5546,7 +5546,7 @@ def hover( selector: str, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, timeout: typing.Optional[float] = None, @@ -5573,7 +5573,7 @@ def hover( selector : str A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -5676,12 +5676,12 @@ def drag_and_drop( def select_option( self, selector: str, - value: typing.Optional[typing.Union[str, typing.List[str]]] = None, + value: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, *, - index: typing.Optional[typing.Union[int, typing.List[int]]] = None, - label: typing.Optional[typing.Union[str, typing.List[str]]] = None, + index: typing.Optional[typing.Union[int, typing.Sequence[int]]] = None, + label: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, element: typing.Optional[ - typing.Union["ElementHandle", typing.List["ElementHandle"]] + typing.Union["ElementHandle", typing.Sequence["ElementHandle"]] ] = None, timeout: typing.Optional[float] = None, no_wait_after: typing.Optional[bool] = None, @@ -5726,15 +5726,15 @@ def select_option( ---------- selector : str A selector to query for. - value : Union[List[str], str, None] + value : Union[Sequence[str], str, None] Options to select by value. If the `` has the `multiple` attribute, all given options are selected, otherwise only the first option matching one of the passed options is selected. Optional. - element : Union[ElementHandle, List[ElementHandle], None] + element : Union[ElementHandle, Sequence[ElementHandle], None] Option elements to select. Optional. timeout : Union[float, None] Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can @@ -5817,8 +5817,8 @@ def set_input_files( str, pathlib.Path, FilePayload, - typing.List[typing.Union[str, pathlib.Path]], - typing.List[FilePayload], + typing.Sequence[typing.Union[str, pathlib.Path]], + typing.Sequence[FilePayload], ], *, strict: typing.Optional[bool] = None, @@ -5840,7 +5840,7 @@ def set_input_files( selector : str A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. - files : Union[List[Union[pathlib.Path, str]], List[{name: str, mimeType: str, buffer: bytes}], pathlib.Path, str, {name: str, mimeType: str, buffer: bytes}] + files : Union[Sequence[Union[pathlib.Path, str]], Sequence[{name: str, mimeType: str, buffer: bytes}], pathlib.Path, str, {name: str, mimeType: str, buffer: bytes}] strict : Union[bool, None] When true, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception. @@ -9991,7 +9991,7 @@ def screenshot( animations: typing.Optional[Literal["allow", "disabled"]] = None, caret: typing.Optional[Literal["hide", "initial"]] = None, scale: typing.Optional[Literal["css", "device"]] = None, - mask: typing.Optional[typing.List["Locator"]] = None, + mask: typing.Optional[typing.Sequence["Locator"]] = None, mask_color: typing.Optional[str] = None ) -> bytes: """Page.screenshot @@ -10035,7 +10035,7 @@ def screenshot( screenshots of high-dpi devices will be twice as large or even larger. Defaults to `"device"`. - mask : Union[List[Locator], None] + mask : Union[Sequence[Locator], None] Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box `#FF00FF` (customized by `maskColor`) that completely covers its bounding box. mask_color : Union[str, None] @@ -10126,7 +10126,7 @@ def click( selector: str, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, delay: typing.Optional[float] = None, @@ -10156,7 +10156,7 @@ def click( selector : str A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -10208,7 +10208,7 @@ def dblclick( selector: str, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, delay: typing.Optional[float] = None, @@ -10240,7 +10240,7 @@ def dblclick( selector : str A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -10289,7 +10289,7 @@ def tap( selector: str, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, timeout: typing.Optional[float] = None, @@ -10318,7 +10318,7 @@ def tap( selector : str A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -11189,7 +11189,7 @@ def hover( selector: str, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, timeout: typing.Optional[float] = None, @@ -11216,7 +11216,7 @@ def hover( selector : str A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -11346,12 +11346,12 @@ def drag_and_drop( def select_option( self, selector: str, - value: typing.Optional[typing.Union[str, typing.List[str]]] = None, + value: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, *, - index: typing.Optional[typing.Union[int, typing.List[int]]] = None, - label: typing.Optional[typing.Union[str, typing.List[str]]] = None, + index: typing.Optional[typing.Union[int, typing.Sequence[int]]] = None, + label: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, element: typing.Optional[ - typing.Union["ElementHandle", typing.List["ElementHandle"]] + typing.Union["ElementHandle", typing.Sequence["ElementHandle"]] ] = None, timeout: typing.Optional[float] = None, no_wait_after: typing.Optional[bool] = None, @@ -11397,15 +11397,15 @@ def select_option( selector : str A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. - value : Union[List[str], str, None] + value : Union[Sequence[str], str, None] Options to select by value. If the `` has the `multiple` attribute, all given options are selected, otherwise only the first option matching one of the passed options is selected. Optional. - element : Union[ElementHandle, List[ElementHandle], None] + element : Union[ElementHandle, Sequence[ElementHandle], None] Option elements to select. Optional. timeout : Union[float, None] Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can @@ -11488,8 +11488,8 @@ def set_input_files( str, pathlib.Path, FilePayload, - typing.List[typing.Union[str, pathlib.Path]], - typing.List[FilePayload], + typing.Sequence[typing.Union[str, pathlib.Path]], + typing.Sequence[FilePayload], ], *, timeout: typing.Optional[float] = None, @@ -11511,7 +11511,7 @@ def set_input_files( selector : str A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. - files : Union[List[Union[pathlib.Path, str]], List[{name: str, mimeType: str, buffer: bytes}], pathlib.Path, str, {name: str, mimeType: str, buffer: bytes}] + files : Union[Sequence[Union[pathlib.Path, str]], Sequence[{name: str, mimeType: str, buffer: bytes}], pathlib.Path, str, {name: str, mimeType: str, buffer: bytes}] timeout : Union[float, None] Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods. @@ -13113,7 +13113,7 @@ def new_page(self) -> "Page": return mapping.from_impl(self._sync(self._impl_obj.new_page())) def cookies( - self, urls: typing.Optional[typing.Union[str, typing.List[str]]] = None + self, urls: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None ) -> typing.List[Cookie]: """BrowserContext.cookies @@ -13122,7 +13122,7 @@ def cookies( Parameters ---------- - urls : Union[List[str], str, None] + urls : Union[Sequence[str], str, None] Optional list of URLs. Returns @@ -13134,7 +13134,7 @@ def cookies( self._sync(self._impl_obj.cookies(urls=mapping.to_impl(urls))) ) - def add_cookies(self, cookies: typing.List[SetCookieParam]) -> None: + def add_cookies(self, cookies: typing.Sequence[SetCookieParam]) -> None: """BrowserContext.add_cookies Adds cookies into this browser context. All pages within this context will have these cookies installed. Cookies @@ -13152,7 +13152,7 @@ def add_cookies(self, cookies: typing.List[SetCookieParam]) -> None: Parameters ---------- - cookies : List[{name: str, value: str, url: Union[str, None], domain: Union[str, None], path: Union[str, None], expires: Union[float, None], httpOnly: Union[bool, None], secure: Union[bool, None], sameSite: Union["Lax", "None", "Strict", None]}] + cookies : Sequence[{name: str, value: str, url: Union[str, None], domain: Union[str, None], path: Union[str, None], expires: Union[float, None], httpOnly: Union[bool, None], secure: Union[bool, None], sameSite: Union["Lax", "None", "Strict", None]}] Adds cookies to the browser context. For the cookie to apply to all subdomains as well, prefix domain with a dot, like this: ".example.com". @@ -13171,7 +13171,7 @@ def clear_cookies(self) -> None: return mapping.from_maybe_impl(self._sync(self._impl_obj.clear_cookies())) def grant_permissions( - self, permissions: typing.List[str], *, origin: typing.Optional[str] = None + self, permissions: typing.Sequence[str], *, origin: typing.Optional[str] = None ) -> None: """BrowserContext.grant_permissions @@ -13180,7 +13180,7 @@ def grant_permissions( Parameters ---------- - permissions : List[str] + permissions : Sequence[str] A permission or an array of permissions to grant. Permissions can be one of the following values: - `'geolocation'` - `'midi'` @@ -14099,7 +14099,7 @@ def new_context( locale: typing.Optional[str] = None, timezone_id: typing.Optional[str] = None, geolocation: typing.Optional[Geolocation] = None, - permissions: typing.Optional[typing.List[str]] = None, + permissions: typing.Optional[typing.Sequence[str]] = None, extra_http_headers: typing.Optional[typing.Dict[str, str]] = None, offline: typing.Optional[bool] = None, http_credentials: typing.Optional[HttpCredentials] = None, @@ -14197,7 +14197,7 @@ def new_context( [ICU's metaZones.txt](https://cs.chromium.org/chromium/src/third_party/icu/source/data/misc/metaZones.txt?rcl=faee8bc70570192d82d2978a71e2a615788597d1) for a list of supported timezone IDs. Defaults to the system timezone. geolocation : Union[{latitude: float, longitude: float, accuracy: Union[float, None]}, None] - permissions : Union[List[str], None] + permissions : Union[Sequence[str], None] A list of permissions to grant to all pages in this context. See `browser_context.grant_permissions()` for more details. Defaults to none. extra_http_headers : Union[Dict[str, str], None] @@ -14251,7 +14251,7 @@ def new_context( Dimensions of the recorded videos. If not specified the size will be equal to `viewport` scaled down to fit into 800x800. If `viewport` is not configured explicitly the video size defaults to 800x450. Actual picture of each page will be scaled down if necessary to fit the specified size. - storage_state : Union[pathlib.Path, str, {cookies: List[{name: str, value: str, domain: str, path: str, expires: float, httpOnly: bool, secure: bool, sameSite: Union["Lax", "None", "Strict"]}], origins: List[{origin: str, localStorage: List[{name: str, value: str}]}]}, None] + storage_state : Union[pathlib.Path, str, {cookies: Sequence[{name: str, value: str, domain: str, path: str, expires: float, httpOnly: bool, secure: bool, sameSite: Union["Lax", "None", "Strict"]}], origins: Sequence[{origin: str, localStorage: Sequence[{name: str, value: str}]}]}, None] Learn more about [storage state and auth](../auth.md). Populates context with given storage state. This option can be used to initialize context with logged-in @@ -14344,7 +14344,7 @@ def new_page( locale: typing.Optional[str] = None, timezone_id: typing.Optional[str] = None, geolocation: typing.Optional[Geolocation] = None, - permissions: typing.Optional[typing.List[str]] = None, + permissions: typing.Optional[typing.Sequence[str]] = None, extra_http_headers: typing.Optional[typing.Dict[str, str]] = None, offline: typing.Optional[bool] = None, http_credentials: typing.Optional[HttpCredentials] = None, @@ -14413,7 +14413,7 @@ def new_page( [ICU's metaZones.txt](https://cs.chromium.org/chromium/src/third_party/icu/source/data/misc/metaZones.txt?rcl=faee8bc70570192d82d2978a71e2a615788597d1) for a list of supported timezone IDs. Defaults to the system timezone. geolocation : Union[{latitude: float, longitude: float, accuracy: Union[float, None]}, None] - permissions : Union[List[str], None] + permissions : Union[Sequence[str], None] A list of permissions to grant to all pages in this context. See `browser_context.grant_permissions()` for more details. Defaults to none. extra_http_headers : Union[Dict[str, str], None] @@ -14467,7 +14467,7 @@ def new_page( Dimensions of the recorded videos. If not specified the size will be equal to `viewport` scaled down to fit into 800x800. If `viewport` is not configured explicitly the video size defaults to 800x450. Actual picture of each page will be scaled down if necessary to fit the specified size. - storage_state : Union[pathlib.Path, str, {cookies: List[{name: str, value: str, domain: str, path: str, expires: float, httpOnly: bool, secure: bool, sameSite: Union["Lax", "None", "Strict"]}], origins: List[{origin: str, localStorage: List[{name: str, value: str}]}]}, None] + storage_state : Union[pathlib.Path, str, {cookies: Sequence[{name: str, value: str, domain: str, path: str, expires: float, httpOnly: bool, secure: bool, sameSite: Union["Lax", "None", "Strict"]}], origins: Sequence[{origin: str, localStorage: Sequence[{name: str, value: str}]}]}, None] Learn more about [storage state and auth](../auth.md). Populates context with given storage state. This option can be used to initialize context with logged-in @@ -14590,7 +14590,7 @@ def start_tracing( page: typing.Optional["Page"] = None, path: typing.Optional[typing.Union[str, pathlib.Path]] = None, screenshots: typing.Optional[bool] = None, - categories: typing.Optional[typing.List[str]] = None + categories: typing.Optional[typing.Sequence[str]] = None ) -> None: """Browser.start_tracing @@ -14624,7 +14624,7 @@ def start_tracing( A path to write the trace file to. screenshots : Union[bool, None] captures screenshots in the trace. - categories : Union[List[str], None] + categories : Union[Sequence[str], None] specify custom categories to use instead of default. """ @@ -14690,9 +14690,9 @@ def launch( *, executable_path: typing.Optional[typing.Union[str, pathlib.Path]] = None, channel: typing.Optional[str] = None, - args: typing.Optional[typing.List[str]] = None, + args: typing.Optional[typing.Sequence[str]] = None, ignore_default_args: typing.Optional[ - typing.Union[bool, typing.List[str]] + typing.Union[bool, typing.Sequence[str]] ] = None, handle_sigint: typing.Optional[bool] = None, handle_sigterm: typing.Optional[bool] = None, @@ -14755,10 +14755,10 @@ def launch( Browser distribution channel. Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge", "msedge-beta", "msedge-dev", "msedge-canary". Read more about using [Google Chrome and Microsoft Edge](../browsers.md#google-chrome--microsoft-edge). - args : Union[List[str], None] + args : Union[Sequence[str], None] Additional arguments to pass to the browser instance. The list of Chromium flags can be found [here](http://peter.sh/experiments/chromium-command-line-switches/). - ignore_default_args : Union[List[str], bool, None] + ignore_default_args : Union[Sequence[str], bool, None] If `true`, Playwright does not pass its own configurations args and only uses the ones from `args`. If an array is given, then filters out the given default arguments. Dangerous option; use with care. Defaults to `false`. handle_sigint : Union[bool, None] @@ -14832,9 +14832,9 @@ def launch_persistent_context( *, channel: typing.Optional[str] = None, executable_path: typing.Optional[typing.Union[str, pathlib.Path]] = None, - args: typing.Optional[typing.List[str]] = None, + args: typing.Optional[typing.Sequence[str]] = None, ignore_default_args: typing.Optional[ - typing.Union[bool, typing.List[str]] + typing.Union[bool, typing.Sequence[str]] ] = None, handle_sigint: typing.Optional[bool] = None, handle_sigterm: typing.Optional[bool] = None, @@ -14856,7 +14856,7 @@ def launch_persistent_context( locale: typing.Optional[str] = None, timezone_id: typing.Optional[str] = None, geolocation: typing.Optional[Geolocation] = None, - permissions: typing.Optional[typing.List[str]] = None, + permissions: typing.Optional[typing.Sequence[str]] = None, extra_http_headers: typing.Optional[typing.Dict[str, str]] = None, offline: typing.Optional[bool] = None, http_credentials: typing.Optional[HttpCredentials] = None, @@ -14912,10 +14912,10 @@ def launch_persistent_context( Path to a browser executable to run instead of the bundled one. If `executablePath` is a relative path, then it is resolved relative to the current working directory. Note that Playwright only works with the bundled Chromium, Firefox or WebKit, use at your own risk. - args : Union[List[str], None] + args : Union[Sequence[str], None] Additional arguments to pass to the browser instance. The list of Chromium flags can be found [here](http://peter.sh/experiments/chromium-command-line-switches/). - ignore_default_args : Union[List[str], bool, None] + ignore_default_args : Union[Sequence[str], bool, None] If `true`, Playwright does not pass its own configurations args and only uses the ones from `args`. If an array is given, then filters out the given default arguments. Dangerous option; use with care. Defaults to `false`. handle_sigint : Union[bool, None] @@ -14972,7 +14972,7 @@ def launch_persistent_context( [ICU's metaZones.txt](https://cs.chromium.org/chromium/src/third_party/icu/source/data/misc/metaZones.txt?rcl=faee8bc70570192d82d2978a71e2a615788597d1) for a list of supported timezone IDs. Defaults to the system timezone. geolocation : Union[{latitude: float, longitude: float, accuracy: Union[float, None]}, None] - permissions : Union[List[str], None] + permissions : Union[Sequence[str], None] A list of permissions to grant to all pages in this context. See `browser_context.grant_permissions()` for more details. Defaults to none. extra_http_headers : Union[Dict[str, str], None] @@ -15698,7 +15698,7 @@ def click( self, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, delay: typing.Optional[float] = None, @@ -15754,7 +15754,7 @@ def click( Parameters ---------- - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -15800,7 +15800,7 @@ def dblclick( self, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, delay: typing.Optional[float] = None, @@ -15832,7 +15832,7 @@ def dblclick( Parameters ---------- - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -17197,7 +17197,7 @@ def hover( self, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, timeout: typing.Optional[float] = None, @@ -17234,7 +17234,7 @@ def hover( Parameters ---------- - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -17625,7 +17625,7 @@ def screenshot( animations: typing.Optional[Literal["allow", "disabled"]] = None, caret: typing.Optional[Literal["hide", "initial"]] = None, scale: typing.Optional[Literal["css", "device"]] = None, - mask: typing.Optional[typing.List["Locator"]] = None, + mask: typing.Optional[typing.Sequence["Locator"]] = None, mask_color: typing.Optional[str] = None ) -> bytes: """Locator.screenshot @@ -17695,7 +17695,7 @@ def screenshot( screenshots of high-dpi devices will be twice as large or even larger. Defaults to `"device"`. - mask : Union[List[Locator], None] + mask : Union[Sequence[Locator], None] Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box `#FF00FF` (customized by `maskColor`) that completely covers its bounding box. mask_color : Union[str, None] @@ -17746,12 +17746,12 @@ def scroll_into_view_if_needed( def select_option( self, - value: typing.Optional[typing.Union[str, typing.List[str]]] = None, + value: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, *, - index: typing.Optional[typing.Union[int, typing.List[int]]] = None, - label: typing.Optional[typing.Union[str, typing.List[str]]] = None, + index: typing.Optional[typing.Union[int, typing.Sequence[int]]] = None, + label: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, element: typing.Optional[ - typing.Union["ElementHandle", typing.List["ElementHandle"]] + typing.Union["ElementHandle", typing.Sequence["ElementHandle"]] ] = None, timeout: typing.Optional[float] = None, no_wait_after: typing.Optional[bool] = None, @@ -17805,15 +17805,15 @@ def select_option( Parameters ---------- - value : Union[List[str], str, None] + value : Union[Sequence[str], str, None] Options to select by value. If the `` has the `multiple` attribute, all given options are selected, otherwise only the first option matching one of the passed options is selected. Optional. - element : Union[ElementHandle, List[ElementHandle], None] + element : Union[ElementHandle, Sequence[ElementHandle], None] Option elements to select. Optional. timeout : Union[float, None] Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can @@ -17878,8 +17878,8 @@ def set_input_files( str, pathlib.Path, FilePayload, - typing.List[typing.Union[str, pathlib.Path]], - typing.List[FilePayload], + typing.Sequence[typing.Union[str, pathlib.Path]], + typing.Sequence[FilePayload], ], *, timeout: typing.Optional[float] = None, @@ -17939,7 +17939,7 @@ def set_input_files( Parameters ---------- - files : Union[List[Union[pathlib.Path, str]], List[{name: str, mimeType: str, buffer: bytes}], pathlib.Path, str, {name: str, mimeType: str, buffer: bytes}] + files : Union[Sequence[Union[pathlib.Path, str]], Sequence[{name: str, mimeType: str, buffer: bytes}], pathlib.Path, str, {name: str, mimeType: str, buffer: bytes}] timeout : Union[float, None] Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods. @@ -17963,7 +17963,7 @@ def tap( self, *, modifiers: typing.Optional[ - typing.List[Literal["Alt", "Control", "Meta", "Shift"]] + typing.Sequence[Literal["Alt", "Control", "Meta", "Shift"]] ] = None, position: typing.Optional[Position] = None, timeout: typing.Optional[float] = None, @@ -17992,7 +17992,7 @@ def tap( Parameters ---------- - modifiers : Union[List[Union["Alt", "Control", "Meta", "Shift"]], None] + modifiers : Union[Sequence[Union["Alt", "Control", "Meta", "Shift"]], None] Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current modifiers back. If not specified, currently pressed modifiers are used. position : Union[{x: float, y: float}, None] @@ -19255,7 +19255,7 @@ def new_context( timeout : Union[float, None] Maximum time in milliseconds to wait for the response. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. - storage_state : Union[pathlib.Path, str, {cookies: List[{name: str, value: str, domain: str, path: str, expires: float, httpOnly: bool, secure: bool, sameSite: Union["Lax", "None", "Strict"]}], origins: List[{origin: str, localStorage: List[{name: str, value: str}]}]}, None] + storage_state : Union[pathlib.Path, str, {cookies: Sequence[{name: str, value: str, domain: str, path: str, expires: float, httpOnly: bool, secure: bool, sameSite: Union["Lax", "None", "Strict"]}], origins: Sequence[{origin: str, localStorage: Sequence[{name: str, value: str}]}]}, None] Populates context with given storage state. This option can be used to initialize context with logged-in information obtained via `browser_context.storage_state()` or `a_pi_request_context.storage_state()`. Either a path to the file with saved storage, or the value returned by one of @@ -19438,9 +19438,9 @@ class LocatorAssertions(SyncBase): def to_contain_text( self, expected: typing.Union[ - typing.List[str], - typing.List[typing.Pattern[str]], - typing.List[typing.Union[typing.Pattern[str], str]], + typing.Sequence[str], + typing.Sequence[typing.Pattern[str]], + typing.Sequence[typing.Union[typing.Pattern[str], str]], typing.Pattern[str], str, ], @@ -19531,7 +19531,7 @@ def to_contain_text( Parameters ---------- - expected : Union[List[Pattern[str]], List[Union[Pattern[str], str]], List[str], Pattern[str], str] + expected : Union[Pattern[str], Sequence[Pattern[str]], Sequence[Union[Pattern[str], str]], Sequence[str], str] Expected substring or RegExp or a list of those. use_inner_text : Union[bool, None] Whether to use `element.innerText` instead of `element.textContent` when retrieving DOM node text. @@ -19557,9 +19557,9 @@ def to_contain_text( def not_to_contain_text( self, expected: typing.Union[ - typing.List[str], - typing.List[typing.Pattern[str]], - typing.List[typing.Union[typing.Pattern[str], str]], + typing.Sequence[str], + typing.Sequence[typing.Pattern[str]], + typing.Sequence[typing.Union[typing.Pattern[str], str]], typing.Pattern[str], str, ], @@ -19574,7 +19574,7 @@ def not_to_contain_text( Parameters ---------- - expected : Union[List[Pattern[str]], List[Union[Pattern[str], str]], List[str], Pattern[str], str] + expected : Union[Pattern[str], Sequence[Pattern[str]], Sequence[Union[Pattern[str], str]], Sequence[str], str] Expected substring or RegExp or a list of those. use_inner_text : Union[bool, None] Whether to use `element.innerText` instead of `element.textContent` when retrieving DOM node text. @@ -19684,9 +19684,9 @@ def not_to_have_attribute( def to_have_class( self, expected: typing.Union[ - typing.List[str], - typing.List[typing.Pattern[str]], - typing.List[typing.Union[typing.Pattern[str], str]], + typing.Sequence[str], + typing.Sequence[typing.Pattern[str]], + typing.Sequence[typing.Union[typing.Pattern[str], str]], typing.Pattern[str], str, ], @@ -19738,7 +19738,7 @@ def to_have_class( Parameters ---------- - expected : Union[List[Pattern[str]], List[Union[Pattern[str], str]], List[str], Pattern[str], str] + expected : Union[Pattern[str], Sequence[Pattern[str]], Sequence[Union[Pattern[str], str]], Sequence[str], str] Expected class or RegExp or a list of those. timeout : Union[float, None] Time to retry the assertion for in milliseconds. Defaults to `5000`. @@ -19756,9 +19756,9 @@ def to_have_class( def not_to_have_class( self, expected: typing.Union[ - typing.List[str], - typing.List[typing.Pattern[str]], - typing.List[typing.Union[typing.Pattern[str], str]], + typing.Sequence[str], + typing.Sequence[typing.Pattern[str]], + typing.Sequence[typing.Union[typing.Pattern[str], str]], typing.Pattern[str], str, ], @@ -19771,7 +19771,7 @@ def not_to_have_class( Parameters ---------- - expected : Union[List[Pattern[str]], List[Union[Pattern[str], str]], List[str], Pattern[str], str] + expected : Union[Pattern[str], Sequence[Pattern[str]], Sequence[Union[Pattern[str], str]], Sequence[str], str] Expected class or RegExp or a list of those. timeout : Union[float, None] Time to retry the assertion for in milliseconds. Defaults to `5000`. @@ -20113,9 +20113,9 @@ def not_to_have_value( def to_have_values( self, values: typing.Union[ - typing.List[str], - typing.List[typing.Pattern[str]], - typing.List[typing.Union[typing.Pattern[str], str]], + typing.Sequence[str], + typing.Sequence[typing.Pattern[str]], + typing.Sequence[typing.Union[typing.Pattern[str], str]], ], *, timeout: typing.Optional[float] = None @@ -20157,7 +20157,7 @@ def to_have_values( Parameters ---------- - values : Union[List[Pattern[str]], List[Union[Pattern[str], str]], List[str]] + values : Union[Sequence[Pattern[str]], Sequence[Union[Pattern[str], str]], Sequence[str]] Expected options currently selected. timeout : Union[float, None] Time to retry the assertion for in milliseconds. Defaults to `5000`. @@ -20175,9 +20175,9 @@ def to_have_values( def not_to_have_values( self, values: typing.Union[ - typing.List[str], - typing.List[typing.Pattern[str]], - typing.List[typing.Union[typing.Pattern[str], str]], + typing.Sequence[str], + typing.Sequence[typing.Pattern[str]], + typing.Sequence[typing.Union[typing.Pattern[str], str]], ], *, timeout: typing.Optional[float] = None @@ -20188,7 +20188,7 @@ def not_to_have_values( Parameters ---------- - values : Union[List[Pattern[str]], List[Union[Pattern[str], str]], List[str]] + values : Union[Sequence[Pattern[str]], Sequence[Union[Pattern[str], str]], Sequence[str]] Expected options currently selected. timeout : Union[float, None] Time to retry the assertion for in milliseconds. Defaults to `5000`. @@ -20206,9 +20206,9 @@ def not_to_have_values( def to_have_text( self, expected: typing.Union[ - typing.List[str], - typing.List[typing.Pattern[str]], - typing.List[typing.Union[typing.Pattern[str], str]], + typing.Sequence[str], + typing.Sequence[typing.Pattern[str]], + typing.Sequence[typing.Union[typing.Pattern[str], str]], typing.Pattern[str], str, ], @@ -20298,7 +20298,7 @@ def to_have_text( Parameters ---------- - expected : Union[List[Pattern[str]], List[Union[Pattern[str], str]], List[str], Pattern[str], str] + expected : Union[Pattern[str], Sequence[Pattern[str]], Sequence[Union[Pattern[str], str]], Sequence[str], str] Expected string or RegExp or a list of those. use_inner_text : Union[bool, None] Whether to use `element.innerText` instead of `element.textContent` when retrieving DOM node text. @@ -20324,9 +20324,9 @@ def to_have_text( def not_to_have_text( self, expected: typing.Union[ - typing.List[str], - typing.List[typing.Pattern[str]], - typing.List[typing.Union[typing.Pattern[str], str]], + typing.Sequence[str], + typing.Sequence[typing.Pattern[str]], + typing.Sequence[typing.Union[typing.Pattern[str], str]], typing.Pattern[str], str, ], @@ -20341,7 +20341,7 @@ def not_to_have_text( Parameters ---------- - expected : Union[List[Pattern[str]], List[Union[Pattern[str], str]], List[str], Pattern[str], str] + expected : Union[Pattern[str], Sequence[Pattern[str]], Sequence[Union[Pattern[str], str]], Sequence[str], str] Expected string or RegExp or a list of those. use_inner_text : Union[bool, None] Whether to use `element.innerText` instead of `element.textContent` when retrieving DOM node text. diff --git a/pyproject.toml b/pyproject.toml index 094ca8c81..da6e54e07 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,7 @@ profile = "black" [tool.pyright] include = ["playwright", "tests/sync"] -ignore = ["tests/async/", "scripts/", "examples/"] +ignore = ["tests/async/", "scripts/"] pythonVersion = "3.8" reportMissingImports = false reportTypedDictNotRequiredAccess = false diff --git a/scripts/documentation_provider.py b/scripts/documentation_provider.py index 506d522fb..a68697be1 100644 --- a/scripts/documentation_provider.py +++ b/scripts/documentation_provider.py @@ -172,7 +172,7 @@ def print_entry( if not doc_value: self.errors.add(f"Parameter not documented: {fqname}({name}=)") else: - code_type = self.serialize_python_type(value) + code_type = self.serialize_python_type(value, "in") print(f"{indent}{to_snake_case(original_name)} : {code_type}") if doc_value.get("comment"): @@ -195,7 +195,7 @@ def print_entry( print("") print(" Returns") print(" -------") - print(f" {self.serialize_python_type(value)}") + print(f" {self.serialize_python_type(value, 'out')}") print(f'{indent}"""') for name in args: @@ -309,7 +309,7 @@ def compare_types( ) -> None: if "(arg=)" in fqname or "(pageFunction=)" in fqname: return - code_type = self.serialize_python_type(value) + code_type = self.serialize_python_type(value, direction) doc_type = self.serialize_doc_type(doc_value["type"], direction) if not doc_value["required"]: doc_type = self.make_optional(doc_type) @@ -319,10 +319,10 @@ def compare_types( f"Parameter type mismatch in {fqname}: documented as {doc_type}, code has {code_type}" ) - def serialize_python_type(self, value: Any) -> str: + def serialize_python_type(self, value: Any, direction: str) -> str: str_value = str(value) if isinstance(value, list): - return f"[{', '.join(list(map(lambda a: self.serialize_python_type(a), value)))}]" + return f"[{', '.join(list(map(lambda a: self.serialize_python_type(a, direction), value)))}]" if str_value == "": return "Error" if str_value == "": @@ -356,32 +356,45 @@ def serialize_python_type(self, value: Any) -> str: if hints: signature: List[str] = [] for [name, value] in hints.items(): - signature.append(f"{name}: {self.serialize_python_type(value)}") + signature.append( + f"{name}: {self.serialize_python_type(value, direction)}" + ) return f"{{{', '.join(signature)}}}" if origin == Union: args = get_args(value) if len(args) == 2 and str(args[1]) == "": - return self.make_optional(self.serialize_python_type(args[0])) - ll = list(map(lambda a: self.serialize_python_type(a), args)) + return self.make_optional( + self.serialize_python_type(args[0], direction) + ) + ll = list(map(lambda a: self.serialize_python_type(a, direction), args)) ll.sort(key=lambda item: "}" if item == "None" else item) return f"Union[{', '.join(ll)}]" if str(origin) == "": args = get_args(value) - return f"Dict[{', '.join(list(map(lambda a: self.serialize_python_type(a), args)))}]" + return f"Dict[{', '.join(list(map(lambda a: self.serialize_python_type(a, direction), args)))}]" + if str(origin) == "": + args = get_args(value) + return f"Sequence[{', '.join(list(map(lambda a: self.serialize_python_type(a, direction), args)))}]" if str(origin) == "": args = get_args(value) - return f"List[{', '.join(list(map(lambda a: self.serialize_python_type(a), args)))}]" + list_type = "Sequence" if direction == "in" else "List" + return f"{list_type}[{', '.join(list(map(lambda a: self.serialize_python_type(a, direction), args)))}]" if str(origin) == "": args = get_args(value) - return f"Callable[{', '.join(list(map(lambda a: self.serialize_python_type(a), args)))}]" + return f"Callable[{', '.join(list(map(lambda a: self.serialize_python_type(a, direction), args)))}]" if str(origin) == "": return "Pattern[str]" if str(origin) == "typing.Literal": args = get_args(value) if len(args) == 1: - return '"' + self.serialize_python_type(args[0]) + '"' + return '"' + self.serialize_python_type(args[0], direction) + '"' body = ", ".join( - list(map(lambda a: '"' + self.serialize_python_type(a) + '"', args)) + list( + map( + lambda a: '"' + self.serialize_python_type(a, direction) + '"', + args, + ) + ) ) return f"Union[{body}]" return str_value @@ -421,7 +434,7 @@ def inner_serialize_doc_type(self, type: Any, direction: str) -> str: if "templates" in type: base = type_name if type_name == "Array": - base = "List" + base = "Sequence" if direction == "in" else "List" if type_name == "Object" or type_name == "Map": base = "Dict" return f"{base}[{', '.join(self.serialize_doc_type(t, direction) for t in type['templates'])}]" diff --git a/scripts/generate_api.py b/scripts/generate_api.py index 3045c1e61..388db89e1 100644 --- a/scripts/generate_api.py +++ b/scripts/generate_api.py @@ -148,7 +148,7 @@ def arguments(func: FunctionType, indent: int) -> str: elif ( "typing.Any" in value_str or "typing.Dict" in value_str - or "typing.List" in value_str + or "typing.Sequence" in value_str or "Handle" in value_str ): tokens.append(f"{name}=mapping.to_impl({to_snake_case(name)})") @@ -191,7 +191,10 @@ def return_value(value: Any) -> List[str]: and str(get_args(value)[1]) == "" ): return ["mapping.from_impl_nullable(", ")"] - if str(get_origin(value)) == "": + if str(get_origin(value)) in [ + "", + "", + ]: return ["mapping.from_impl_list(", ")"] if str(get_origin(value)) == "": return ["mapping.from_impl_dict(", ")"] diff --git a/tests/async/test_browsercontext_request_fallback.py b/tests/async/test_browsercontext_request_fallback.py index b003a9db9..f3959490b 100644 --- a/tests/async/test_browsercontext_request_fallback.py +++ b/tests/async/test_browsercontext_request_fallback.py @@ -215,7 +215,8 @@ async def capture_and_continue(route: Route, request: Request) -> None: async def delete_foo_header(route: Route, request: Request) -> None: headers = await request.all_headers() - await route.fallback(headers={**headers, "foo": None}) + del headers["foo"] + await route.fallback(headers=headers) await context.route(server.PREFIX + "/something", delete_foo_header) diff --git a/tests/async/test_interception.py b/tests/async/test_interception.py index 68f749d42..6b0bf0a27 100644 --- a/tests/async/test_interception.py +++ b/tests/async/test_interception.py @@ -16,7 +16,7 @@ import json import re from pathlib import Path -from typing import Callable, List +from typing import Callable, List, Optional import pytest @@ -344,7 +344,7 @@ def _handle(route: Route, request: Request) -> None: assert "/non-existing-page.html" in intercepted[0].url chain = [] - r = response.request + r: Optional[Request] = response.request while r: chain.append(r) assert r.is_navigation_request() @@ -392,7 +392,7 @@ def _handle(route: Route) -> None: assert intercepted[0].resource_type == "document" assert "one-style.html" in intercepted[0].url - r = intercepted[1] + r: Optional[Request] = intercepted[1] for url in [ "/one-style.css", "/two-style.css", diff --git a/tests/async/test_page_request_fallback.py b/tests/async/test_page_request_fallback.py index 199e072e6..456c911a3 100644 --- a/tests/async/test_page_request_fallback.py +++ b/tests/async/test_page_request_fallback.py @@ -194,7 +194,8 @@ async def capture_and_continue(route: Route, request: Request) -> None: async def delete_foo_header(route: Route, request: Request) -> None: headers = await request.all_headers() - await route.fallback(headers={**headers, "foo": None}) + del headers["foo"] + await route.fallback(headers=headers) await page.route(server.PREFIX + "/something", delete_foo_header)