From 46d834696e6a525ba4258c31ffa608c955a31688 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Wed, 29 Nov 2023 12:52:49 -0800 Subject: [PATCH] chore: use Sequence for input List like types --- playwright/_impl/_api_structures.py | 12 +- playwright/_impl/_assertions.py | 65 ++- playwright/_impl/_browser.py | 8 +- playwright/_impl/_browser_context.py | 12 +- playwright/_impl/_browser_type.py | 12 +- playwright/_impl/_connection.py | 5 +- playwright/_impl/_element_handle.py | 50 +- playwright/_impl/_file_chooser.py | 6 +- playwright/_impl/_frame.py | 33 +- playwright/_impl/_impl_to_api_mapping.py | 4 +- playwright/_impl/_js_handle.py | 3 +- playwright/_impl/_locator.py | 23 +- playwright/_impl/_page.py | 24 +- playwright/_impl/_set_input_files_helpers.py | 13 +- playwright/async_api/_generated.py | 462 +++++++++-------- playwright/sync_api/_generated.py | 474 +++++++++--------- pyproject.toml | 2 +- scripts/documentation_provider.py | 7 +- scripts/expected_api_mismatch.txt | 2 +- scripts/generate_api.py | 6 +- .../test_browsercontext_request_fallback.py | 3 +- tests/async/test_interception.py | 6 +- tests/async/test_page_request_fallback.py | 3 +- 23 files changed, 636 insertions(+), 599 deletions(-) diff --git a/playwright/_impl/_api_structures.py b/playwright/_impl/_api_structures.py index a3240ee5c..cb1c74a48 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 @@ -77,7 +77,7 @@ class LocalStorageEntry(TypedDict): class OriginState(TypedDict): origin: str - localStorage: List[LocalStorageEntry] + localStorage: Sequence[LocalStorageEntry] class PdfMargins(TypedDict, total=False): @@ -100,8 +100,8 @@ class ProxySettings(TypedDict, total=False): class StorageState(TypedDict, total=False): - cookies: List[Cookie] - origins: List[OriginState] + cookies: Sequence[Cookie] + origins: Sequence[OriginState] class ResourceTiming(TypedDict): @@ -158,7 +158,7 @@ class NameValue(TypedDict): value: str -HeadersArray = List[NameValue] +HeadersArray = Sequence[NameValue] Headers = Dict[str, str] @@ -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..b5ee4748e 100644 --- a/playwright/_impl/_browser_context.py +++ b/playwright/_impl/_browser_context.py @@ -13,6 +13,7 @@ # limitations under the License. import asyncio +import collections.abc import json import sys from pathlib import Path @@ -25,6 +26,7 @@ List, Optional, Pattern, + Sequence, Set, Union, cast, @@ -284,21 +286,23 @@ 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 not ( + isinstance(urls, collections.abc.Sequence) and not 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..b721f42c1 100644 --- a/playwright/_impl/_page.py +++ b/playwright/_impl/_page.py @@ -27,6 +27,7 @@ List, Optional, Pattern, + Sequence, Union, cast, ) @@ -636,13 +637,14 @@ 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()) if "path" in params: del params["path"] if "mask" in params: + breakpoint() params["mask"] = list( map( lambda locator: ( @@ -680,7 +682,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 +698,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 +713,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 +835,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 +862,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 +883,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..9f0c2124f 100644 --- a/playwright/async_api/_generated.py +++ b/playwright/async_api/_generated.py @@ -368,7 +368,7 @@ async def all_headers(self) -> typing.Dict[str, str]: return mapping.from_maybe_impl(await self._impl_obj.all_headers()) - async def headers_array(self) -> typing.List[NameValue]: + async def headers_array(self) -> typing.Sequence[NameValue]: """Request.headers_array An array with all the request HTTP headers associated with this request. Unlike `request.all_headers()`, @@ -377,7 +377,7 @@ async def headers_array(self) -> typing.List[NameValue]: Returns ------- - List[{name: str, value: str}] + Sequence[{name: str, value: str}] """ return mapping.from_impl_list(await self._impl_obj.headers_array()) @@ -515,7 +515,7 @@ async def all_headers(self) -> typing.Dict[str, str]: return mapping.from_maybe_impl(await self._impl_obj.all_headers()) - async def headers_array(self) -> typing.List[NameValue]: + async def headers_array(self) -> typing.Sequence[NameValue]: """Response.headers_array An array with all the request HTTP headers associated with this response. Unlike `response.all_headers()`, @@ -524,7 +524,7 @@ async def headers_array(self) -> typing.List[NameValue]: Returns ------- - List[{name: str, value: str}] + Sequence[{name: str, value: str}] """ return mapping.from_impl_list(await self._impl_obj.headers_array()) @@ -560,7 +560,7 @@ async def header_values(self, name: str) -> typing.List[str]: Returns ------- - List[str] + Sequence[str] """ return mapping.from_maybe_impl(await self._impl_obj.header_values(name=name)) @@ -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] @@ -2031,7 +2031,7 @@ async def hover( return mapping.from_maybe_impl( await self._impl_obj.hover( - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, timeout=timeout, noWaitAfter=no_wait_after, @@ -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] @@ -2098,7 +2098,7 @@ async def click( return mapping.from_maybe_impl( await self._impl_obj.click( - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, delay=delay, button=button, @@ -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] @@ -2168,7 +2168,7 @@ async def dblclick( return mapping.from_maybe_impl( await self._impl_obj.dblclick( - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, delay=delay, button=button, @@ -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 @@ -2250,14 +2250,14 @@ async def select_option( Returns ------- - List[str] + Sequence[str] """ return mapping.from_maybe_impl( await self._impl_obj.select_option( - value=mapping.to_impl(value), - index=mapping.to_impl(index), - label=mapping.to_impl(label), + value=value, + index=index, + label=label, element=mapping.to_impl(element), timeout=timeout, force=force, @@ -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] @@ -2316,7 +2316,7 @@ async def tap( return mapping.from_maybe_impl( await self._impl_obj.tap( - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, timeout=timeout, force=force, @@ -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. @@ -2455,7 +2455,7 @@ async def set_input_files( return mapping.from_maybe_impl( await self._impl_obj.set_input_files( - files=mapping.to_impl(files), timeout=timeout, noWaitAfter=no_wait_after + files=files, timeout=timeout, noWaitAfter=no_wait_after ) ) @@ -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] @@ -2836,7 +2836,7 @@ async def screenshot( animations=animations, caret=caret, scale=scale, - mask=mapping.to_impl(mask), + mask=mask, mask_color=mask_color, ) ) @@ -2874,7 +2874,7 @@ async def query_selector_all(self, selector: str) -> typing.List["ElementHandle" Returns ------- - List[ElementHandle] + Sequence[ElementHandle] """ return mapping.from_impl_list( @@ -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. @@ -3248,7 +3248,7 @@ async def set_files( return mapping.from_maybe_impl( await self._impl_obj.set_files( - files=mapping.to_impl(files), timeout=timeout, noWaitAfter=no_wait_after + files=files, timeout=timeout, noWaitAfter=no_wait_after ) ) @@ -3316,7 +3316,7 @@ def child_frames(self) -> typing.List["Frame"]: Returns ------- - List[Frame] + Sequence[Frame] """ return mapping.from_impl_list(self._impl_obj.child_frames) @@ -3772,7 +3772,7 @@ async def query_selector_all(self, selector: str) -> typing.List["ElementHandle" Returns ------- - List[ElementHandle] + Sequence[ElementHandle] """ return mapping.from_impl_list( @@ -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] @@ -4461,7 +4461,7 @@ async def click( return mapping.from_maybe_impl( await self._impl_obj.click( selector=selector, - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, delay=delay, button=button, @@ -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] @@ -4541,7 +4541,7 @@ async def dblclick( return mapping.from_maybe_impl( await self._impl_obj.dblclick( selector=selector, - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, delay=delay, button=button, @@ -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] @@ -4613,7 +4613,7 @@ async def tap( return mapping.from_maybe_impl( await self._impl_obj.tap( selector=selector, - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, timeout=timeout, force=force, @@ -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] @@ -5501,7 +5501,7 @@ async def hover( return mapping.from_maybe_impl( await self._impl_obj.hover( selector=selector, - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, timeout=timeout, noWaitAfter=no_wait_after, @@ -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 @@ -5649,15 +5649,15 @@ async def select_option( Returns ------- - List[str] + Sequence[str] """ return mapping.from_maybe_impl( await self._impl_obj.select_option( selector=selector, - value=mapping.to_impl(value), - index=mapping.to_impl(index), - label=mapping.to_impl(label), + value=value, + index=index, + label=label, element=mapping.to_impl(element), timeout=timeout, noWaitAfter=no_wait_after, @@ -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. @@ -5750,7 +5750,7 @@ async def set_input_files( return mapping.from_maybe_impl( await self._impl_obj.set_input_files( selector=selector, - files=mapping.to_impl(files), + files=files, strict=strict, timeout=timeout, noWaitAfter=no_wait_after, @@ -7081,7 +7081,7 @@ def args(self) -> typing.List["JSHandle"]: Returns ------- - List[JSHandle] + Sequence[JSHandle] """ return mapping.from_impl_list(self._impl_obj.args) @@ -8021,7 +8021,7 @@ def frames(self) -> typing.List["Frame"]: Returns ------- - List[Frame] + Sequence[Frame] """ return mapping.from_impl_list(self._impl_obj.frames) @@ -8056,7 +8056,7 @@ def workers(self) -> typing.List["Worker"]: Returns ------- - List[Worker] + Sequence[Worker] """ return mapping.from_impl_list(self._impl_obj.workers) @@ -8216,7 +8216,7 @@ async def query_selector_all(self, selector: str) -> typing.List["ElementHandle" Returns ------- - List[ElementHandle] + Sequence[ElementHandle] """ return mapping.from_impl_list( @@ -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] @@ -9991,7 +9991,7 @@ async def screenshot( animations=animations, caret=caret, scale=scale, - mask=mapping.to_impl(mask), + mask=mask, mask_color=mask_color, ) ) @@ -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] @@ -10116,7 +10116,7 @@ async def click( return mapping.from_maybe_impl( await self._impl_obj.click( selector=selector, - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, delay=delay, button=button, @@ -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] @@ -10196,7 +10196,7 @@ async def dblclick( return mapping.from_maybe_impl( await self._impl_obj.dblclick( selector=selector, - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, delay=delay, button=button, @@ -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] @@ -10268,7 +10268,7 @@ async def tap( return mapping.from_maybe_impl( await self._impl_obj.tap( selector=selector, - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, timeout=timeout, force=force, @@ -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] @@ -11154,7 +11154,7 @@ async def hover( return mapping.from_maybe_impl( await self._impl_obj.hover( selector=selector, - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, timeout=timeout, noWaitAfter=no_wait_after, @@ -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 @@ -11330,15 +11330,15 @@ async def select_option( Returns ------- - List[str] + Sequence[str] """ return mapping.from_maybe_impl( await self._impl_obj.select_option( selector=selector, - value=mapping.to_impl(value), - index=mapping.to_impl(index), - label=mapping.to_impl(label), + value=value, + index=index, + label=label, element=mapping.to_impl(element), timeout=timeout, noWaitAfter=no_wait_after, @@ -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. @@ -11431,7 +11431,7 @@ async def set_input_files( return mapping.from_maybe_impl( await self._impl_obj.set_input_files( selector=selector, - files=mapping.to_impl(files), + files=files, timeout=timeout, strict=strict, noWaitAfter=no_wait_after, @@ -12941,7 +12941,7 @@ def pages(self) -> typing.List["Page"]: Returns ------- - List[Page] + Sequence[Page] """ return mapping.from_impl_list(self._impl_obj.pages) @@ -12967,7 +12967,7 @@ def background_pages(self) -> typing.List["Page"]: Returns ------- - List[Page] + Sequence[Page] """ return mapping.from_impl_list(self._impl_obj.background_pages) @@ -12981,7 +12981,7 @@ def service_workers(self) -> typing.List["Worker"]: Returns ------- - List[Worker] + Sequence[Worker] """ return mapping.from_impl_list(self._impl_obj.service_workers) @@ -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,19 +13072,17 @@ async def cookies( Parameters ---------- - urls : Union[List[str], str, None] + urls : Union[Sequence[str], str, None] Optional list of URLs. Returns ------- - List[{name: str, value: str, domain: str, path: str, expires: float, httpOnly: bool, secure: bool, sameSite: Union["Lax", "None", "Strict"]}] + Sequence[{name: str, value: str, domain: str, path: str, expires: float, httpOnly: bool, secure: bool, sameSite: Union["Lax", "None", "Strict"]}] """ - return mapping.from_impl_list( - await self._impl_obj.cookies(urls=mapping.to_impl(urls)) - ) + return mapping.from_impl_list(await self._impl_obj.cookies(urls=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,14 +13100,14 @@ 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". """ return mapping.from_maybe_impl( - await self._impl_obj.add_cookies(cookies=mapping.to_impl(cookies)) + await self._impl_obj.add_cookies(cookies=cookies) ) async def clear_cookies(self) -> None: @@ -13121,7 +13119,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 +13128,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'` @@ -13153,7 +13151,7 @@ async def grant_permissions( return mapping.from_maybe_impl( await self._impl_obj.grant_permissions( - permissions=mapping.to_impl(permissions), origin=origin + permissions=permissions, origin=origin ) ) @@ -13772,7 +13770,7 @@ async def storage_state( Returns ------- - {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}]}]} + {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}]}]} """ return mapping.from_impl(await self._impl_obj.storage_state(path=path)) @@ -13986,7 +13984,7 @@ def contexts(self) -> typing.List["BrowserContext"]: Returns ------- - List[BrowserContext] + Sequence[BrowserContext] """ return mapping.from_impl_list(self._impl_obj.contexts) @@ -14039,7 +14037,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 +14135,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 +14189,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 @@ -14242,7 +14240,7 @@ async def new_context( locale=locale, timezoneId=timezone_id, geolocation=geolocation, - permissions=mapping.to_impl(permissions), + permissions=permissions, extraHTTPHeaders=mapping.to_impl(extra_http_headers), offline=offline, httpCredentials=http_credentials, @@ -14282,7 +14280,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 +14349,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 +14403,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 @@ -14456,7 +14454,7 @@ async def new_page( locale=locale, timezoneId=timezone_id, geolocation=geolocation, - permissions=mapping.to_impl(permissions), + permissions=permissions, extraHTTPHeaders=mapping.to_impl(extra_http_headers), offline=offline, httpCredentials=http_credentials, @@ -14526,7 +14524,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 +14558,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. """ @@ -14569,7 +14567,7 @@ async def start_tracing( page=page._impl_obj if page else None, path=path, screenshots=screenshots, - categories=mapping.to_impl(categories), + categories=categories, ) ) @@ -14624,9 +14622,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 +14687,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] @@ -14740,8 +14738,8 @@ async def launch( await self._impl_obj.launch( executablePath=executable_path, channel=channel, - args=mapping.to_impl(args), - ignoreDefaultArgs=mapping.to_impl(ignore_default_args), + args=args, + ignoreDefaultArgs=ignore_default_args, handleSIGINT=handle_sigint, handleSIGTERM=handle_sigterm, handleSIGHUP=handle_sighup, @@ -14764,9 +14762,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 +14786,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 +14842,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 +14902,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] @@ -14998,8 +14996,8 @@ async def launch_persistent_context( userDataDir=user_data_dir, channel=channel, executablePath=executable_path, - args=mapping.to_impl(args), - ignoreDefaultArgs=mapping.to_impl(ignore_default_args), + args=args, + ignoreDefaultArgs=ignore_default_args, handleSIGINT=handle_sigint, handleSIGTERM=handle_sigterm, handleSIGHUP=handle_sighup, @@ -15020,7 +15018,7 @@ async def launch_persistent_context( locale=locale, timezoneId=timezone_id, geolocation=geolocation, - permissions=mapping.to_impl(permissions), + permissions=permissions, extraHTTPHeaders=mapping.to_impl(extra_http_headers), offline=offline, httpCredentials=http_credentials, @@ -15620,7 +15618,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 +15674,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] @@ -15704,7 +15702,7 @@ async def click( return mapping.from_maybe_impl( await self._impl_obj.click( - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, delay=delay, button=button, @@ -15720,7 +15718,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 +15750,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] @@ -15778,7 +15776,7 @@ async def dblclick( return mapping.from_maybe_impl( await self._impl_obj.dblclick( - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, delay=delay, button=button, @@ -16733,7 +16731,7 @@ async def element_handles(self) -> typing.List["ElementHandle"]: Returns ------- - List[ElementHandle] + Sequence[ElementHandle] """ return mapping.from_impl_list(await self._impl_obj.element_handles()) @@ -16952,7 +16950,7 @@ async def all(self) -> typing.List["Locator"]: Returns ------- - List[Locator] + Sequence[Locator] """ return mapping.from_impl_list(await self._impl_obj.all()) @@ -17097,7 +17095,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 +17132,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] @@ -17156,7 +17154,7 @@ async def hover( return mapping.from_maybe_impl( await self._impl_obj.hover( - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, timeout=timeout, noWaitAfter=no_wait_after, @@ -17509,7 +17507,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 +17577,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] @@ -17601,7 +17599,7 @@ async def screenshot( animations=animations, caret=caret, scale=scale, - mask=mapping.to_impl(mask), + mask=mask, mask_color=mask_color, ) ) @@ -17628,12 +17626,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 +17685,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 @@ -17709,14 +17707,14 @@ async def select_option( Returns ------- - List[str] + Sequence[str] """ return mapping.from_maybe_impl( await self._impl_obj.select_option( - value=mapping.to_impl(value), - index=mapping.to_impl(index), - label=mapping.to_impl(label), + value=value, + index=index, + label=label, element=mapping.to_impl(element), timeout=timeout, noWaitAfter=no_wait_after, @@ -17758,8 +17756,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 +17817,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. @@ -17831,7 +17829,7 @@ async def set_input_files( return mapping.from_maybe_impl( await self._impl_obj.set_input_files( - files=mapping.to_impl(files), timeout=timeout, noWaitAfter=no_wait_after + files=files, timeout=timeout, noWaitAfter=no_wait_after ) ) @@ -17839,7 +17837,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 +17866,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] @@ -17890,7 +17888,7 @@ async def tap( return mapping.from_maybe_impl( await self._impl_obj.tap( - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, timeout=timeout, force=force, @@ -18115,7 +18113,7 @@ async def all_inner_texts(self) -> typing.List[str]: Returns ------- - List[str] + Sequence[str] """ return mapping.from_maybe_impl(await self._impl_obj.all_inner_texts()) @@ -18140,7 +18138,7 @@ async def all_text_contents(self) -> typing.List[str]: Returns ------- - List[str] + Sequence[str] """ return mapping.from_maybe_impl(await self._impl_obj.all_text_contents()) @@ -18337,7 +18335,7 @@ def headers(self) -> typing.Dict[str, str]: return mapping.from_maybe_impl(self._impl_obj.headers) @property - def headers_array(self) -> typing.List[NameValue]: + def headers_array(self) -> typing.Sequence[NameValue]: """APIResponse.headers_array An array with all the request HTTP headers associated with this response. Header names are not lower-cased. Headers @@ -18345,7 +18343,7 @@ def headers_array(self) -> typing.List[NameValue]: Returns ------- - List[{name: str, value: str}] + Sequence[{name: str, value: str}] """ return mapping.from_impl_list(self._impl_obj.headers_array) @@ -19054,7 +19052,7 @@ async def storage_state( Returns ------- - {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}]}]} + {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}]}]} """ return mapping.from_impl(await self._impl_obj.storage_state(path=path)) @@ -19107,7 +19105,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 +19278,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 +19371,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. @@ -19387,7 +19385,7 @@ async def to_contain_text( return mapping.from_maybe_impl( await self._impl_obj.to_contain_text( - expected=mapping.to_impl(expected), + expected=expected, use_inner_text=use_inner_text, timeout=timeout, ignore_case=ignore_case, @@ -19397,9 +19395,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 +19412,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. @@ -19428,7 +19426,7 @@ async def not_to_contain_text( return mapping.from_maybe_impl( await self._impl_obj.not_to_contain_text( - expected=mapping.to_impl(expected), + expected=expected, use_inner_text=use_inner_text, timeout=timeout, ignore_case=ignore_case, @@ -19518,9 +19516,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 +19570,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`. @@ -19580,17 +19578,15 @@ async def to_have_class( __tracebackhide__ = True return mapping.from_maybe_impl( - await self._impl_obj.to_have_class( - expected=mapping.to_impl(expected), timeout=timeout - ) + await self._impl_obj.to_have_class(expected=expected, timeout=timeout) ) 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 +19599,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`. @@ -19611,9 +19607,7 @@ async def not_to_have_class( __tracebackhide__ = True return mapping.from_maybe_impl( - await self._impl_obj.not_to_have_class( - expected=mapping.to_impl(expected), timeout=timeout - ) + await self._impl_obj.not_to_have_class(expected=expected, timeout=timeout) ) async def to_have_count( @@ -19937,9 +19931,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 +19975,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`. @@ -19989,17 +19983,15 @@ async def to_have_values( __tracebackhide__ = True return mapping.from_maybe_impl( - await self._impl_obj.to_have_values( - values=mapping.to_impl(values), timeout=timeout - ) + await self._impl_obj.to_have_values(values=values, timeout=timeout) ) 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 +20002,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`. @@ -20018,17 +20010,15 @@ async def not_to_have_values( __tracebackhide__ = True return mapping.from_maybe_impl( - await self._impl_obj.not_to_have_values( - values=mapping.to_impl(values), timeout=timeout - ) + await self._impl_obj.not_to_have_values(values=values, timeout=timeout) ) 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 +20108,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. @@ -20132,7 +20122,7 @@ async def to_have_text( return mapping.from_maybe_impl( await self._impl_obj.to_have_text( - expected=mapping.to_impl(expected), + expected=expected, use_inner_text=use_inner_text, timeout=timeout, ignore_case=ignore_case, @@ -20142,9 +20132,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 +20149,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. @@ -20173,7 +20163,7 @@ async def not_to_have_text( return mapping.from_maybe_impl( await self._impl_obj.not_to_have_text( - expected=mapping.to_impl(expected), + expected=expected, use_inner_text=use_inner_text, timeout=timeout, ignore_case=ignore_case, diff --git a/playwright/sync_api/_generated.py b/playwright/sync_api/_generated.py index a0c3ead75..0b5781385 100644 --- a/playwright/sync_api/_generated.py +++ b/playwright/sync_api/_generated.py @@ -368,7 +368,7 @@ def all_headers(self) -> typing.Dict[str, str]: return mapping.from_maybe_impl(self._sync(self._impl_obj.all_headers())) - def headers_array(self) -> typing.List[NameValue]: + def headers_array(self) -> typing.Sequence[NameValue]: """Request.headers_array An array with all the request HTTP headers associated with this request. Unlike `request.all_headers()`, @@ -377,7 +377,7 @@ def headers_array(self) -> typing.List[NameValue]: Returns ------- - List[{name: str, value: str}] + Sequence[{name: str, value: str}] """ return mapping.from_impl_list(self._sync(self._impl_obj.headers_array())) @@ -517,7 +517,7 @@ def all_headers(self) -> typing.Dict[str, str]: return mapping.from_maybe_impl(self._sync(self._impl_obj.all_headers())) - def headers_array(self) -> typing.List[NameValue]: + def headers_array(self) -> typing.Sequence[NameValue]: """Response.headers_array An array with all the request HTTP headers associated with this response. Unlike `response.all_headers()`, @@ -526,7 +526,7 @@ def headers_array(self) -> typing.List[NameValue]: Returns ------- - List[{name: str, value: str}] + Sequence[{name: str, value: str}] """ return mapping.from_impl_list(self._sync(self._impl_obj.headers_array())) @@ -564,7 +564,7 @@ def header_values(self, name: str) -> typing.List[str]: Returns ------- - List[str] + Sequence[str] """ return mapping.from_maybe_impl( @@ -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] @@ -2040,7 +2040,7 @@ def hover( return mapping.from_maybe_impl( self._sync( self._impl_obj.hover( - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, timeout=timeout, noWaitAfter=no_wait_after, @@ -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] @@ -2109,7 +2109,7 @@ def click( return mapping.from_maybe_impl( self._sync( self._impl_obj.click( - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, delay=delay, button=button, @@ -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] @@ -2181,7 +2181,7 @@ def dblclick( return mapping.from_maybe_impl( self._sync( self._impl_obj.dblclick( - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, delay=delay, button=button, @@ -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 @@ -2264,15 +2264,15 @@ def select_option( Returns ------- - List[str] + Sequence[str] """ return mapping.from_maybe_impl( self._sync( self._impl_obj.select_option( - value=mapping.to_impl(value), - index=mapping.to_impl(index), - label=mapping.to_impl(label), + value=value, + index=index, + label=label, element=mapping.to_impl(element), timeout=timeout, force=force, @@ -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] @@ -2333,7 +2333,7 @@ def tap( return mapping.from_maybe_impl( self._sync( self._impl_obj.tap( - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, timeout=timeout, force=force, @@ -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. @@ -2476,9 +2476,7 @@ def set_input_files( return mapping.from_maybe_impl( self._sync( self._impl_obj.set_input_files( - files=mapping.to_impl(files), - timeout=timeout, - noWaitAfter=no_wait_after, + files=files, timeout=timeout, noWaitAfter=no_wait_after ) ) ) @@ -2802,7 +2800,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 +2846,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] @@ -2871,7 +2869,7 @@ def screenshot( animations=animations, caret=caret, scale=scale, - mask=mapping.to_impl(mask), + mask=mask, mask_color=mask_color, ) ) @@ -2910,7 +2908,7 @@ def query_selector_all(self, selector: str) -> typing.List["ElementHandle"]: Returns ------- - List[ElementHandle] + Sequence[ElementHandle] """ return mapping.from_impl_list( @@ -3268,8 +3266,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 +3280,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. @@ -3295,9 +3293,7 @@ def set_files( return mapping.from_maybe_impl( self._sync( self._impl_obj.set_files( - files=mapping.to_impl(files), - timeout=timeout, - noWaitAfter=no_wait_after, + files=files, timeout=timeout, noWaitAfter=no_wait_after ) ) ) @@ -3366,7 +3362,7 @@ def child_frames(self) -> typing.List["Frame"]: Returns ------- - List[Frame] + Sequence[Frame] """ return mapping.from_impl_list(self._impl_obj.child_frames) @@ -3828,7 +3824,7 @@ def query_selector_all(self, selector: str) -> typing.List["ElementHandle"]: Returns ------- - List[ElementHandle] + Sequence[ElementHandle] """ return mapping.from_impl_list( @@ -4481,7 +4477,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 +4507,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] @@ -4544,7 +4540,7 @@ def click( self._sync( self._impl_obj.click( selector=selector, - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, delay=delay, button=button, @@ -4563,7 +4559,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 +4591,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] @@ -4626,7 +4622,7 @@ def dblclick( self._sync( self._impl_obj.dblclick( selector=selector, - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, delay=delay, button=button, @@ -4644,7 +4640,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 +4669,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] @@ -4700,7 +4696,7 @@ def tap( self._sync( self._impl_obj.tap( selector=selector, - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, timeout=timeout, force=force, @@ -5546,7 +5542,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 +5569,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] @@ -5600,7 +5596,7 @@ def hover( self._sync( self._impl_obj.hover( selector=selector, - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, timeout=timeout, noWaitAfter=no_wait_after, @@ -5676,12 +5672,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 +5722,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 @@ -5751,16 +5747,16 @@ def select_option( Returns ------- - List[str] + Sequence[str] """ return mapping.from_maybe_impl( self._sync( self._impl_obj.select_option( selector=selector, - value=mapping.to_impl(value), - index=mapping.to_impl(index), - label=mapping.to_impl(label), + value=value, + index=index, + label=label, element=mapping.to_impl(element), timeout=timeout, noWaitAfter=no_wait_after, @@ -5817,8 +5813,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 +5836,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. @@ -5857,7 +5853,7 @@ def set_input_files( self._sync( self._impl_obj.set_input_files( selector=selector, - files=mapping.to_impl(files), + files=files, strict=strict, timeout=timeout, noWaitAfter=no_wait_after, @@ -7201,7 +7197,7 @@ def args(self) -> typing.List["JSHandle"]: Returns ------- - List[JSHandle] + Sequence[JSHandle] """ return mapping.from_impl_list(self._impl_obj.args) @@ -8041,7 +8037,7 @@ def frames(self) -> typing.List["Frame"]: Returns ------- - List[Frame] + Sequence[Frame] """ return mapping.from_impl_list(self._impl_obj.frames) @@ -8076,7 +8072,7 @@ def workers(self) -> typing.List["Worker"]: Returns ------- - List[Worker] + Sequence[Worker] """ return mapping.from_impl_list(self._impl_obj.workers) @@ -8236,7 +8232,7 @@ def query_selector_all(self, selector: str) -> typing.List["ElementHandle"]: Returns ------- - List[ElementHandle] + Sequence[ElementHandle] """ return mapping.from_impl_list( @@ -9991,7 +9987,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 +10031,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] @@ -10060,7 +10056,7 @@ def screenshot( animations=animations, caret=caret, scale=scale, - mask=mapping.to_impl(mask), + mask=mask, mask_color=mask_color, ) ) @@ -10126,7 +10122,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 +10152,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] @@ -10189,7 +10185,7 @@ def click( self._sync( self._impl_obj.click( selector=selector, - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, delay=delay, button=button, @@ -10208,7 +10204,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 +10236,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] @@ -10271,7 +10267,7 @@ def dblclick( self._sync( self._impl_obj.dblclick( selector=selector, - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, delay=delay, button=button, @@ -10289,7 +10285,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 +10314,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] @@ -10345,7 +10341,7 @@ def tap( self._sync( self._impl_obj.tap( selector=selector, - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, timeout=timeout, force=force, @@ -11189,7 +11185,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 +11212,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] @@ -11243,7 +11239,7 @@ def hover( self._sync( self._impl_obj.hover( selector=selector, - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, timeout=timeout, noWaitAfter=no_wait_after, @@ -11346,12 +11342,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 +11393,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 @@ -11422,16 +11418,16 @@ def select_option( Returns ------- - List[str] + Sequence[str] """ return mapping.from_maybe_impl( self._sync( self._impl_obj.select_option( selector=selector, - value=mapping.to_impl(value), - index=mapping.to_impl(index), - label=mapping.to_impl(label), + value=value, + index=index, + label=label, element=mapping.to_impl(element), timeout=timeout, noWaitAfter=no_wait_after, @@ -11488,8 +11484,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 +11507,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. @@ -11528,7 +11524,7 @@ def set_input_files( self._sync( self._impl_obj.set_input_files( selector=selector, - files=mapping.to_impl(files), + files=files, timeout=timeout, strict=strict, noWaitAfter=no_wait_after, @@ -12991,7 +12987,7 @@ def pages(self) -> typing.List["Page"]: Returns ------- - List[Page] + Sequence[Page] """ return mapping.from_impl_list(self._impl_obj.pages) @@ -13017,7 +13013,7 @@ def background_pages(self) -> typing.List["Page"]: Returns ------- - List[Page] + Sequence[Page] """ return mapping.from_impl_list(self._impl_obj.background_pages) @@ -13031,7 +13027,7 @@ def service_workers(self) -> typing.List["Worker"]: Returns ------- - List[Worker] + Sequence[Worker] """ return mapping.from_impl_list(self._impl_obj.service_workers) @@ -13113,7 +13109,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,19 +13118,17 @@ def cookies( Parameters ---------- - urls : Union[List[str], str, None] + urls : Union[Sequence[str], str, None] Optional list of URLs. Returns ------- - List[{name: str, value: str, domain: str, path: str, expires: float, httpOnly: bool, secure: bool, sameSite: Union["Lax", "None", "Strict"]}] + Sequence[{name: str, value: str, domain: str, path: str, expires: float, httpOnly: bool, secure: bool, sameSite: Union["Lax", "None", "Strict"]}] """ - return mapping.from_impl_list( - self._sync(self._impl_obj.cookies(urls=mapping.to_impl(urls))) - ) + return mapping.from_impl_list(self._sync(self._impl_obj.cookies(urls=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,14 +13146,14 @@ 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". """ return mapping.from_maybe_impl( - self._sync(self._impl_obj.add_cookies(cookies=mapping.to_impl(cookies))) + self._sync(self._impl_obj.add_cookies(cookies=cookies)) ) def clear_cookies(self) -> None: @@ -13171,7 +13165,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 +13174,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'` @@ -13203,9 +13197,7 @@ def grant_permissions( return mapping.from_maybe_impl( self._sync( - self._impl_obj.grant_permissions( - permissions=mapping.to_impl(permissions), origin=origin - ) + self._impl_obj.grant_permissions(permissions=permissions, origin=origin) ) ) @@ -13832,7 +13824,7 @@ def storage_state( Returns ------- - {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}]}]} + {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}]}]} """ return mapping.from_impl(self._sync(self._impl_obj.storage_state(path=path))) @@ -14046,7 +14038,7 @@ def contexts(self) -> typing.List["BrowserContext"]: Returns ------- - List[BrowserContext] + Sequence[BrowserContext] """ return mapping.from_impl_list(self._impl_obj.contexts) @@ -14099,7 +14091,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 +14189,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 +14243,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 @@ -14303,7 +14295,7 @@ def new_context( locale=locale, timezoneId=timezone_id, geolocation=geolocation, - permissions=mapping.to_impl(permissions), + permissions=permissions, extraHTTPHeaders=mapping.to_impl(extra_http_headers), offline=offline, httpCredentials=http_credentials, @@ -14344,7 +14336,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 +14405,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 +14459,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 @@ -14519,7 +14511,7 @@ def new_page( locale=locale, timezoneId=timezone_id, geolocation=geolocation, - permissions=mapping.to_impl(permissions), + permissions=permissions, extraHTTPHeaders=mapping.to_impl(extra_http_headers), offline=offline, httpCredentials=http_credentials, @@ -14590,7 +14582,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 +14616,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. """ @@ -14634,7 +14626,7 @@ def start_tracing( page=page._impl_obj if page else None, path=path, screenshots=screenshots, - categories=mapping.to_impl(categories), + categories=categories, ) ) ) @@ -14690,9 +14682,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 +14747,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] @@ -14807,8 +14799,8 @@ def launch( self._impl_obj.launch( executablePath=executable_path, channel=channel, - args=mapping.to_impl(args), - ignoreDefaultArgs=mapping.to_impl(ignore_default_args), + args=args, + ignoreDefaultArgs=ignore_default_args, handleSIGINT=handle_sigint, handleSIGTERM=handle_sigterm, handleSIGHUP=handle_sighup, @@ -14832,9 +14824,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 +14848,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 +14904,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 +14964,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] @@ -15067,8 +15059,8 @@ def launch_persistent_context( userDataDir=user_data_dir, channel=channel, executablePath=executable_path, - args=mapping.to_impl(args), - ignoreDefaultArgs=mapping.to_impl(ignore_default_args), + args=args, + ignoreDefaultArgs=ignore_default_args, handleSIGINT=handle_sigint, handleSIGTERM=handle_sigterm, handleSIGHUP=handle_sighup, @@ -15089,7 +15081,7 @@ def launch_persistent_context( locale=locale, timezoneId=timezone_id, geolocation=geolocation, - permissions=mapping.to_impl(permissions), + permissions=permissions, extraHTTPHeaders=mapping.to_impl(extra_http_headers), offline=offline, httpCredentials=http_credentials, @@ -15698,7 +15690,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 +15746,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] @@ -15783,7 +15775,7 @@ def click( return mapping.from_maybe_impl( self._sync( self._impl_obj.click( - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, delay=delay, button=button, @@ -15800,7 +15792,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 +15824,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] @@ -15859,7 +15851,7 @@ def dblclick( return mapping.from_maybe_impl( self._sync( self._impl_obj.dblclick( - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, delay=delay, button=button, @@ -16829,7 +16821,7 @@ def element_handles(self) -> typing.List["ElementHandle"]: Returns ------- - List[ElementHandle] + Sequence[ElementHandle] """ return mapping.from_impl_list(self._sync(self._impl_obj.element_handles())) @@ -17050,7 +17042,7 @@ def all(self) -> typing.List["Locator"]: Returns ------- - List[Locator] + Sequence[Locator] """ return mapping.from_impl_list(self._sync(self._impl_obj.all())) @@ -17197,7 +17189,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 +17226,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] @@ -17257,7 +17249,7 @@ def hover( return mapping.from_maybe_impl( self._sync( self._impl_obj.hover( - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, timeout=timeout, noWaitAfter=no_wait_after, @@ -17625,7 +17617,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 +17687,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] @@ -17718,7 +17710,7 @@ def screenshot( animations=animations, caret=caret, scale=scale, - mask=mapping.to_impl(mask), + mask=mask, mask_color=mask_color, ) ) @@ -17746,12 +17738,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 +17797,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 @@ -17827,15 +17819,15 @@ def select_option( Returns ------- - List[str] + Sequence[str] """ return mapping.from_maybe_impl( self._sync( self._impl_obj.select_option( - value=mapping.to_impl(value), - index=mapping.to_impl(index), - label=mapping.to_impl(label), + value=value, + index=index, + label=label, element=mapping.to_impl(element), timeout=timeout, noWaitAfter=no_wait_after, @@ -17878,8 +17870,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 +17931,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. @@ -17952,9 +17944,7 @@ def set_input_files( return mapping.from_maybe_impl( self._sync( self._impl_obj.set_input_files( - files=mapping.to_impl(files), - timeout=timeout, - noWaitAfter=no_wait_after, + files=files, timeout=timeout, noWaitAfter=no_wait_after ) ) ) @@ -17963,7 +17953,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 +17982,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] @@ -18015,7 +18005,7 @@ def tap( return mapping.from_maybe_impl( self._sync( self._impl_obj.tap( - modifiers=mapping.to_impl(modifiers), + modifiers=modifiers, position=position, timeout=timeout, force=force, @@ -18247,7 +18237,7 @@ def all_inner_texts(self) -> typing.List[str]: Returns ------- - List[str] + Sequence[str] """ return mapping.from_maybe_impl(self._sync(self._impl_obj.all_inner_texts())) @@ -18272,7 +18262,7 @@ def all_text_contents(self) -> typing.List[str]: Returns ------- - List[str] + Sequence[str] """ return mapping.from_maybe_impl(self._sync(self._impl_obj.all_text_contents())) @@ -18471,7 +18461,7 @@ def headers(self) -> typing.Dict[str, str]: return mapping.from_maybe_impl(self._impl_obj.headers) @property - def headers_array(self) -> typing.List[NameValue]: + def headers_array(self) -> typing.Sequence[NameValue]: """APIResponse.headers_array An array with all the request HTTP headers associated with this response. Header names are not lower-cased. Headers @@ -18479,7 +18469,7 @@ def headers_array(self) -> typing.List[NameValue]: Returns ------- - List[{name: str, value: str}] + Sequence[{name: str, value: str}] """ return mapping.from_impl_list(self._impl_obj.headers_array) @@ -19202,7 +19192,7 @@ def storage_state( Returns ------- - {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}]}]} + {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}]}]} """ return mapping.from_impl(self._sync(self._impl_obj.storage_state(path=path))) @@ -19255,7 +19245,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 +19428,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 +19521,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. @@ -19546,7 +19536,7 @@ def to_contain_text( return mapping.from_maybe_impl( self._sync( self._impl_obj.to_contain_text( - expected=mapping.to_impl(expected), + expected=expected, use_inner_text=use_inner_text, timeout=timeout, ignore_case=ignore_case, @@ -19557,9 +19547,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 +19564,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. @@ -19589,7 +19579,7 @@ def not_to_contain_text( return mapping.from_maybe_impl( self._sync( self._impl_obj.not_to_contain_text( - expected=mapping.to_impl(expected), + expected=expected, use_inner_text=use_inner_text, timeout=timeout, ignore_case=ignore_case, @@ -19684,9 +19674,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 +19728,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`. @@ -19746,19 +19736,15 @@ def to_have_class( __tracebackhide__ = True return mapping.from_maybe_impl( - self._sync( - self._impl_obj.to_have_class( - expected=mapping.to_impl(expected), timeout=timeout - ) - ) + self._sync(self._impl_obj.to_have_class(expected=expected, timeout=timeout)) ) 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 +19757,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`. @@ -19780,9 +19766,7 @@ def not_to_have_class( return mapping.from_maybe_impl( self._sync( - self._impl_obj.not_to_have_class( - expected=mapping.to_impl(expected), timeout=timeout - ) + self._impl_obj.not_to_have_class(expected=expected, timeout=timeout) ) ) @@ -20113,9 +20097,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 +20141,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`. @@ -20165,19 +20149,15 @@ def to_have_values( __tracebackhide__ = True return mapping.from_maybe_impl( - self._sync( - self._impl_obj.to_have_values( - values=mapping.to_impl(values), timeout=timeout - ) - ) + self._sync(self._impl_obj.to_have_values(values=values, timeout=timeout)) ) 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 +20168,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`. @@ -20197,18 +20177,16 @@ def not_to_have_values( return mapping.from_maybe_impl( self._sync( - self._impl_obj.not_to_have_values( - values=mapping.to_impl(values), timeout=timeout - ) + self._impl_obj.not_to_have_values(values=values, timeout=timeout) ) ) 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 +20276,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. @@ -20313,7 +20291,7 @@ def to_have_text( return mapping.from_maybe_impl( self._sync( self._impl_obj.to_have_text( - expected=mapping.to_impl(expected), + expected=expected, use_inner_text=use_inner_text, timeout=timeout, ignore_case=ignore_case, @@ -20324,9 +20302,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 +20319,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. @@ -20356,7 +20334,7 @@ def not_to_have_text( return mapping.from_maybe_impl( self._sync( self._impl_obj.not_to_have_text( - expected=mapping.to_impl(expected), + expected=expected, use_inner_text=use_inner_text, timeout=timeout, ignore_case=ignore_case, 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..78d29451b 100644 --- a/scripts/documentation_provider.py +++ b/scripts/documentation_provider.py @@ -368,9 +368,12 @@ def serialize_python_type(self, value: Any) -> str: if str(origin) == "": args = get_args(value) return f"Dict[{', '.join(list(map(lambda a: self.serialize_python_type(a), args)))}]" + if str(origin) == "": + args = get_args(value) + return f"Sequence[{', '.join(list(map(lambda a: self.serialize_python_type(a), args)))}]" if str(origin) == "": args = get_args(value) - return f"List[{', '.join(list(map(lambda a: self.serialize_python_type(a), args)))}]" + return f"Sequence[{', '.join(list(map(lambda a: self.serialize_python_type(a), args)))}]" if str(origin) == "": args = get_args(value) return f"Callable[{', '.join(list(map(lambda a: self.serialize_python_type(a), args)))}]" @@ -421,7 +424,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 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/expected_api_mismatch.txt b/scripts/expected_api_mismatch.txt index 47c084c61..9fcf5a23f 100644 --- a/scripts/expected_api_mismatch.txt +++ b/scripts/expected_api_mismatch.txt @@ -5,7 +5,7 @@ Parameter not documented: Browser.new_context(default_browser_type=) Parameter not documented: Browser.new_page(default_browser_type=) # We don't expand the type of the return value here. -Parameter type mismatch in Accessibility.snapshot(return=): documented as Union[{role: str, name: str, value: Union[float, str], description: str, keyshortcuts: str, roledescription: str, valuetext: str, disabled: bool, expanded: bool, focused: bool, modal: bool, multiline: bool, multiselectable: bool, readonly: bool, required: bool, selected: bool, checked: Union["mixed", bool], pressed: Union["mixed", bool], level: int, valuemin: float, valuemax: float, autocomplete: str, haspopup: str, invalid: str, orientation: str, children: List[Dict]}, None], code has Union[Dict, None] +Parameter type mismatch in Accessibility.snapshot(return=): documented as Union[{role: str, name: str, value: Union[float, str], description: str, keyshortcuts: str, roledescription: str, valuetext: str, disabled: bool, expanded: bool, focused: bool, modal: bool, multiline: bool, multiselectable: bool, readonly: bool, required: bool, selected: bool, checked: Union["mixed", bool], pressed: Union["mixed", bool], level: int, valuemin: float, valuemax: float, autocomplete: str, haspopup: str, invalid: str, orientation: str, children: Sequence[Dict]}, None], code has Union[Dict, None] # One vs two arguments in the callback, Python explicitly unions. Parameter type mismatch in BrowserContext.route(handler=): documented as Callable[[Route, Request], Union[Any, Any]], code has Union[Callable[[Route, Request], Any], Callable[[Route], Any]] diff --git a/scripts/generate_api.py b/scripts/generate_api.py index 3045c1e61..e949b0cb0 100644 --- a/scripts/generate_api.py +++ b/scripts/generate_api.py @@ -149,6 +149,7 @@ def arguments(func: FunctionType, indent: int) -> str: "typing.Any" in value_str or "typing.Dict" in value_str or "typing.List" in value_str + or "collections.abc.Sequence" in value_str or "Handle" in value_str ): tokens.append(f"{name}=mapping.to_impl({to_snake_case(name)})") @@ -191,7 +192,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)