Skip to content

Commit 734e425

Browse files
authored
chore: fixed mypy on impl files (microsoft#643)
1 parent ef1f86a commit 734e425

File tree

7 files changed

+17
-16
lines changed

7 files changed

+17
-16
lines changed

playwright/_impl/__init__.py

Whitespace-only changes.

playwright/_impl/_page.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ def my_predicate(request: Request) -> bool:
850850
if matcher:
851851
return matcher.matches(request.url)
852852
if predicate:
853-
return url_or_predicate(request)
853+
return predicate(request)
854854
return True
855855

856856
return self.expect_event(

playwright/_impl/_stream.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import base64
1616
from pathlib import Path
17-
from typing import Dict
17+
from typing import Dict, Union
1818

1919
from playwright._impl._connection import ChannelOwner
2020

@@ -25,7 +25,7 @@ def __init__(
2525
) -> None:
2626
super().__init__(parent, type, guid, initializer)
2727

28-
async def save_as(self, path: Path) -> None:
28+
async def save_as(self, path: Union[str, Path]) -> None:
2929
with open(path, mode="wb") as file:
3030
while True:
3131
binary = await self._channel.send("read")

playwright/_impl/_wait_helper.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,15 @@
1515
import asyncio
1616
import uuid
1717
from asyncio.tasks import Task
18-
from typing import Any, Callable, Generic, List, Tuple, TypeVar
18+
from typing import Any, Callable, List, Tuple
1919

2020
from pyee import EventEmitter
2121

2222
from playwright._impl._api_types import Error, TimeoutError
2323
from playwright._impl._connection import ChannelOwner
2424

25-
T = TypeVar("T")
2625

27-
28-
class WaitHelper(Generic[T]):
26+
class WaitHelper:
2927
def __init__(self, channel_owner: ChannelOwner, api_name: str) -> None:
3028
self._result: asyncio.Future = asyncio.Future()
3129
self._wait_id = uuid.uuid4().hex

tests/async/test_download.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ async def test_should_report_downloads_with_accept_downloads_false(page: Page, s
6464
await download.path()
6565
except Error as exc:
6666
error = exc
67-
assert "accept_downloads" in await download.failure()
67+
failure_reason = await download.failure()
68+
assert failure_reason
69+
assert "accept_downloads" in failure_reason
6870
assert error
6971
assert "accept_downloads: True" in error.message
7072

tests/async/test_network.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ async def test_page_events_request_should_report_requests_and_responses_handled_
123123
assert sw_response == "responseFromServiceWorker:foo"
124124
assert request.url == server.PREFIX + "/serviceworkers/fetchdummy/foo"
125125
response = await request.response()
126+
assert response
126127
assert response.url == server.PREFIX + "/serviceworkers/fetchdummy/foo"
127128
assert await response.text() == "responseFromServiceWorker:foo"
128129

tests/sync/test_element_handle_wait_for_element_state.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
def test_should_wait_for_visible(page):
2121
page.set_content('<div id=div style="display:none">content</div>')
2222
div = page.query_selector("div")
23-
page.evaluate('setTimeout(() => div.style.display = "block", 1000)')
23+
page.evaluate('setTimeout(() => div.style.display = "block", 500)')
2424
assert div.is_visible() is False
2525
div.wait_for_element_state("visible")
2626
assert div.is_visible()
@@ -43,7 +43,7 @@ def test_should_timeout_waiting_for_visible(page):
4343
def test_should_throw_waiting_for_visible_when_detached(page):
4444
page.set_content('<div id=div style="display:none">content</div>')
4545
div = page.query_selector("div")
46-
page.evaluate("setTimeout(() => div.remove(), 250)")
46+
page.evaluate("setTimeout(() => div.remove(), 500)")
4747
with pytest.raises(Error) as exc_info:
4848
div.wait_for_element_state("visible")
4949
assert "Element is not attached to the DOM" in exc_info.value.message
@@ -52,7 +52,7 @@ def test_should_throw_waiting_for_visible_when_detached(page):
5252
def test_should_wait_for_hidden(page):
5353
page.set_content("<div id=div>content</div>")
5454
div = page.query_selector("div")
55-
page.evaluate('setTimeout(() => div.style.display = "none", 250)')
55+
page.evaluate('setTimeout(() => div.style.display = "none", 500)')
5656
assert div.is_hidden() is False
5757
div.wait_for_element_state("hidden")
5858
assert div.is_hidden()
@@ -67,7 +67,7 @@ def test_should_wait_for_already_hidden(page):
6767
def test_should_wait_for_hidden_when_detached(page):
6868
page.set_content("<div id=div>content</div>")
6969
div = page.query_selector("div")
70-
page.evaluate("setTimeout(() => div.remove(), 250)")
70+
page.evaluate("setTimeout(() => div.remove(), 500)")
7171
div.wait_for_element_state("hidden")
7272
assert div.is_hidden()
7373

@@ -76,15 +76,15 @@ def test_should_wait_for_enabled_button(page, server):
7676
page.set_content("<button id=button disabled><span>Target</span></button>")
7777
span = page.query_selector("text=Target")
7878
assert span.is_enabled() is False
79-
page.evaluate("setTimeout(() => button.disabled = false, 250)")
79+
page.evaluate("setTimeout(() => button.disabled = false, 500)")
8080
span.wait_for_element_state("enabled")
8181
assert span.is_enabled()
8282

8383

8484
def test_should_throw_waiting_for_enabled_when_detached(page):
8585
page.set_content("<button id=button disabled>Target</button>")
8686
button = page.query_selector("button")
87-
page.evaluate("setTimeout(() => button.remove(), 250)")
87+
page.evaluate("setTimeout(() => button.remove(), 500)")
8888
with pytest.raises(Error) as exc_info:
8989
button.wait_for_element_state("enabled")
9090
assert "Element is not attached to the DOM" in exc_info.value.message
@@ -94,15 +94,15 @@ def test_should_wait_for_disabled_button(page):
9494
page.set_content("<button id=button><span>Target</span></button>")
9595
span = page.query_selector("text=Target")
9696
assert span.is_disabled() is False
97-
page.evaluate("setTimeout(() => button.disabled = true, 250)")
97+
page.evaluate("setTimeout(() => button.disabled = true, 500)")
9898
span.wait_for_element_state("disabled")
9999
assert span.is_disabled()
100100

101101

102102
def test_should_wait_for_editable_input(page, server):
103103
page.set_content("<input id=input readonly>")
104104
input = page.query_selector("input")
105-
page.evaluate("setTimeout(() => input.readOnly = false, 250)")
105+
page.evaluate("setTimeout(() => input.readOnly = false, 500)")
106106
assert input.is_editable() is False
107107
input.wait_for_element_state("editable")
108108
assert input.is_editable()

0 commit comments

Comments
 (0)