Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions playwright/_impl/_assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def _not(self) -> "PageAssertions":
return PageAssertions(self._actual_page, not self._is_not)

async def to_have_title(
self, title_or_reg_exp: Union[Pattern, str], timeout: float = None
self, title_or_reg_exp: Union[Pattern[str], str], timeout: float = None
) -> None:
expected_values = to_expected_text_values(
[title_or_reg_exp], normalize_white_space=True
Expand All @@ -81,13 +81,13 @@ async def to_have_title(
)

async def not_to_have_title(
self, title_or_reg_exp: Union[Pattern, str], timeout: float = None
self, title_or_reg_exp: Union[Pattern[str], str], timeout: float = None
) -> None:
__tracebackhide__ = True
await self._not.to_have_title(title_or_reg_exp, timeout)

async def to_have_url(
self, url_or_reg_exp: Union[str, Pattern], timeout: float = None
self, url_or_reg_exp: Union[str, Pattern[str]], timeout: float = None
) -> None:
__tracebackhide__ = True
base_url = self._actual_page.context._options.get("baseURL")
Expand All @@ -102,7 +102,7 @@ async def to_have_url(
)

async def not_to_have_url(
self, url_or_reg_exp: Union[Pattern, str], timeout: float = None
self, url_or_reg_exp: Union[Pattern[str], str], timeout: float = None
) -> None:
__tracebackhide__ = True
await self._not.to_have_url(url_or_reg_exp, timeout)
Expand All @@ -119,7 +119,7 @@ def _not(self) -> "LocatorAssertions":

async def to_contain_text(
self,
expected: Union[List[Union[Pattern, str]], Pattern, str],
expected: Union[List[Union[Pattern[str], str]], Pattern[str], str],
use_inner_text: bool = None,
timeout: float = None,
ignore_case: bool = None,
Expand Down Expand Up @@ -162,7 +162,7 @@ async def to_contain_text(

async def not_to_contain_text(
self,
expected: Union[List[Union[Pattern, str]], Pattern, str],
expected: Union[List[Union[Pattern[str], str]], Pattern[str], str],
use_inner_text: bool = None,
timeout: float = None,
ignore_case: bool = None,
Expand All @@ -173,7 +173,7 @@ async def not_to_contain_text(
async def to_have_attribute(
self,
name: str,
value: Union[str, Pattern],
value: Union[str, Pattern[str]],
timeout: float = None,
) -> None:
__tracebackhide__ = True
Expand All @@ -190,15 +190,15 @@ async def to_have_attribute(
async def not_to_have_attribute(
self,
name: str,
value: Union[str, Pattern],
value: Union[str, Pattern[str]],
timeout: float = None,
) -> None:
__tracebackhide__ = True
await self._not.to_have_attribute(name, value, timeout)

async def to_have_class(
self,
expected: Union[List[Union[Pattern, str]], Pattern, str],
expected: Union[List[Union[Pattern[str], str]], Pattern[str], str],
timeout: float = None,
) -> None:
__tracebackhide__ = True
Expand All @@ -221,7 +221,7 @@ async def to_have_class(

async def not_to_have_class(
self,
expected: Union[List[Union[Pattern, str]], Pattern, str],
expected: Union[List[Union[Pattern[str], str]], Pattern[str], str],
timeout: float = None,
) -> None:
__tracebackhide__ = True
Expand Down Expand Up @@ -251,7 +251,7 @@ async def not_to_have_count(
async def to_have_css(
self,
name: str,
value: Union[str, Pattern],
value: Union[str, Pattern[str]],
timeout: float = None,
) -> None:
__tracebackhide__ = True
Expand All @@ -268,15 +268,15 @@ async def to_have_css(
async def not_to_have_css(
self,
name: str,
value: Union[str, Pattern],
value: Union[str, Pattern[str]],
timeout: float = None,
) -> None:
__tracebackhide__ = True
await self._not.to_have_css(name, value, timeout)

async def to_have_id(
self,
id: Union[str, Pattern],
id: Union[str, Pattern[str]],
timeout: float = None,
) -> None:
__tracebackhide__ = True
Expand All @@ -290,7 +290,7 @@ async def to_have_id(

async def not_to_have_id(
self,
id: Union[str, Pattern],
id: Union[str, Pattern[str]],
timeout: float = None,
) -> None:
__tracebackhide__ = True
Expand Down Expand Up @@ -323,7 +323,7 @@ async def not_to_have_js_property(

async def to_have_value(
self,
value: Union[str, Pattern],
value: Union[str, Pattern[str]],
timeout: float = None,
) -> None:
__tracebackhide__ = True
Expand All @@ -337,15 +337,15 @@ async def to_have_value(

async def not_to_have_value(
self,
value: Union[str, Pattern],
value: Union[str, Pattern[str]],
timeout: float = None,
) -> None:
__tracebackhide__ = True
await self._not.to_have_value(value, timeout)

async def to_have_values(
self,
values: List[Union[Pattern, str]],
values: List[Union[Pattern[str], str]],
timeout: float = None,
) -> None:
__tracebackhide__ = True
Expand All @@ -359,15 +359,15 @@ async def to_have_values(

async def not_to_have_values(
self,
values: List[Union[Pattern, str]],
values: List[Union[Pattern[str], str]],
timeout: float = None,
) -> None:
__tracebackhide__ = True
await self._not.to_have_values(values, timeout)

async def to_have_text(
self,
expected: Union[List[Union[Pattern, str]], Pattern, str],
expected: Union[List[Union[Pattern[str], str]], Pattern[str], str],
use_inner_text: bool = None,
timeout: float = None,
ignore_case: bool = None,
Expand Down Expand Up @@ -406,7 +406,7 @@ async def to_have_text(

async def not_to_have_text(
self,
expected: Union[List[Union[Pattern, str]], Pattern, str],
expected: Union[List[Union[Pattern[str], str]], Pattern[str], str],
use_inner_text: bool = None,
timeout: float = None,
ignore_case: bool = None,
Expand Down Expand Up @@ -602,7 +602,7 @@ async def not_to_be_ok(self) -> None:


def expected_regex(
pattern: Pattern,
pattern: Pattern[str],
match_substring: bool,
normalize_white_space: bool,
ignore_case: Optional[bool] = None,
Expand All @@ -620,7 +620,7 @@ def expected_regex(


def to_expected_text_values(
items: Union[List[Pattern], List[str], List[Union[str, Pattern]]],
items: Union[List[Pattern[str]], List[str], List[Union[str, Pattern[str]]]],
match_substring: bool = False,
normalize_white_space: bool = False,
ignore_case: Optional[bool] = None,
Expand Down
4 changes: 2 additions & 2 deletions playwright/_impl/_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ async def new_context(
baseURL: str = None,
strictSelectors: bool = None,
serviceWorkers: ServiceWorkersPolicy = None,
recordHarUrlFilter: Union[Pattern, str] = None,
recordHarUrlFilter: Union[Pattern[str], str] = None,
recordHarMode: HarMode = None,
recordHarContent: HarContentPolicy = None,
) -> BrowserContext:
Expand Down Expand Up @@ -165,7 +165,7 @@ async def new_page(
baseURL: str = None,
strictSelectors: bool = None,
serviceWorkers: ServiceWorkersPolicy = None,
recordHarUrlFilter: Union[Pattern, str] = None,
recordHarUrlFilter: Union[Pattern[str], str] = None,
recordHarMode: HarMode = None,
recordHarContent: HarContentPolicy = None,
) -> Page:
Expand Down
4 changes: 2 additions & 2 deletions playwright/_impl/_browser_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ async def _record_into_har(
self,
har: Union[Path, str],
page: Optional[Page] = None,
url: Union[Pattern, str] = None,
url: Union[Pattern[str], str] = None,
) -> None:
params = {
"options": prepare_record_har_options(
Expand All @@ -341,7 +341,7 @@ async def _record_into_har(
async def route_from_har(
self,
har: Union[Path, str],
url: Union[Pattern, str] = None,
url: Union[Pattern[str], str] = None,
not_found: RouteFromHarNotFoundPolicy = None,
update: bool = None,
) -> None:
Expand Down
2 changes: 1 addition & 1 deletion playwright/_impl/_browser_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ async def launch_persistent_context(
baseURL: str = None,
strictSelectors: bool = None,
serviceWorkers: ServiceWorkersPolicy = None,
recordHarUrlFilter: Union[Pattern, str] = None,
recordHarUrlFilter: Union[Pattern[str], str] = None,
recordHarMode: HarMode = None,
recordHarContent: HarContentPolicy = None,
) -> BrowserContext:
Expand Down
5 changes: 4 additions & 1 deletion playwright/_impl/_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,10 @@ async def fill(
await self._channel.send("fill", locals_to_params(locals()))

def locator(
self, selector: str, has_text: Union[str, Pattern] = None, has: Locator = None
self,
selector: str,
has_text: Union[str, Pattern[str]] = None,
has: Locator = None,
) -> Locator:
return Locator(self, selector, has_text=has_text, has=has)

Expand Down
8 changes: 4 additions & 4 deletions playwright/_impl/_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
from playwright._impl._api_structures import HeadersArray
from playwright._impl._network import Request, Response, Route

URLMatch = Union[str, Pattern, Callable[[str], bool]]
URLMatchRequest = Union[str, Pattern, Callable[["Request"], bool]]
URLMatchResponse = Union[str, Pattern, Callable[["Response"], bool]]
URLMatch = Union[str, Pattern[str], Callable[[str], bool]]
URLMatchRequest = Union[str, Pattern[str], Callable[["Request"], bool]]
URLMatchResponse = Union[str, Pattern[str], Callable[["Response"], bool]]
RouteHandlerCallback = Union[
Callable[["Route"], Any], Callable[["Route", "Request"], Any]
]
Expand Down Expand Up @@ -152,7 +152,7 @@ class FrameNavigatedEvent(TypedDict):
class URLMatcher:
def __init__(self, base_url: Union[str, None], match: URLMatch) -> None:
self._callback: Optional[Callable[[str], bool]] = None
self._regex_obj: Optional[Pattern] = None
self._regex_obj: Optional[Pattern[str]] = None
if isinstance(match, str):
if base_url and not match.startswith("*"):
match = urljoin(base_url, match)
Expand Down
11 changes: 7 additions & 4 deletions playwright/_impl/_locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(
self,
frame: "Frame",
selector: str,
has_text: Union[str, Pattern] = None,
has_text: Union[str, Pattern[str]] = None,
has: "Locator" = None,
) -> None:
self._frame = frame
Expand Down Expand Up @@ -197,7 +197,7 @@ async def fill(
def locator(
self,
selector: str,
has_text: Union[str, Pattern] = None,
has_text: Union[str, Pattern[str]] = None,
has: "Locator" = None,
) -> "Locator":
return Locator(
Expand Down Expand Up @@ -237,7 +237,7 @@ def nth(self, index: int) -> "Locator":

def filter(
self,
has_text: Union[str, Pattern] = None,
has_text: Union[str, Pattern[str]] = None,
has: "Locator" = None,
) -> "Locator":
return Locator(
Expand Down Expand Up @@ -576,7 +576,10 @@ def __init__(self, frame: "Frame", frame_selector: str) -> None:
self._frame_selector = frame_selector

def locator(
self, selector: str, has_text: Union[str, Pattern] = None, has: "Locator" = None
self,
selector: str,
has_text: Union[str, Pattern[str]] = None,
has: "Locator" = None,
) -> Locator:
return Locator(
self._frame,
Expand Down
4 changes: 2 additions & 2 deletions playwright/_impl/_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ async def unroute(
async def route_from_har(
self,
har: Union[Path, str],
url: Union[Pattern, str] = None,
url: Union[Pattern[str], str] = None,
not_found: RouteFromHarNotFoundPolicy = None,
update: bool = None,
) -> None:
Expand Down Expand Up @@ -732,7 +732,7 @@ async def fill(
def locator(
self,
selector: str,
has_text: Union[str, Pattern] = None,
has_text: Union[str, Pattern[str]] = None,
has: "Locator" = None,
) -> "Locator":
return self._main_frame.locator(selector, has_text=has_text, has=has)
Expand Down
Loading