Skip to content

Commit fb9a258

Browse files
authored
chore: validate properties in the docs (microsoft#424)
1 parent 79f6ce0 commit fb9a258

21 files changed

+319
-533
lines changed

playwright/_impl/_chromium_browser_context.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ def _on_service_worker(self, worker: Worker) -> None:
5555
self._service_workers.add(worker)
5656
self.emit(ChromiumBrowserContext.Events.ServiceWorker, worker)
5757

58+
@property
5859
def background_pages(self) -> List[Page]:
5960
return list(self._background_pages)
6061

62+
@property
6163
def service_workers(self) -> List[Worker]:
6264
return list(self._service_workers)
6365

playwright/_impl/_download.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import pathlib
1516
from pathlib import Path
1617
from typing import Dict, Optional, Union
1718

@@ -39,8 +40,8 @@ async def delete(self) -> None:
3940
async def failure(self) -> Optional[str]:
4041
return patch_error_message(await self._channel.send("failure"))
4142

42-
async def path(self) -> Optional[str]:
43-
return await self._channel.send("path")
43+
async def path(self) -> Optional[pathlib.Path]:
44+
return pathlib.Path(await self._channel.send("path"))
4445

4546
async def save_as(self, path: Union[str, Path]) -> None:
4647
path = str(Path(path))

playwright/_impl/_file_chooser.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def page(self) -> "Page":
4343
def element(self) -> "ElementHandle":
4444
return self._element_handle
4545

46-
@property
4746
def is_multiple(self) -> bool:
4847
return self._is_multiple
4948

playwright/_impl/_frame.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -526,13 +526,6 @@ async def wait_for_function(
526526
async def title(self) -> str:
527527
return await self._channel.send("title")
528528

529-
def expect_load_state(
530-
self,
531-
state: DocumentLoadState = None,
532-
timeout: float = None,
533-
) -> EventContextManagerImpl:
534-
return EventContextManagerImpl(self.wait_for_load_state(state, timeout))
535-
536529
def expect_navigation(
537530
self,
538531
url: URLMatch = None,

playwright/_impl/_network.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ async def response(self) -> Optional["Response"]:
109109
def frame(self) -> "Frame":
110110
return from_channel(self._initializer["frame"])
111111

112-
@property
113112
def is_navigation_request(self) -> bool:
114113
return self._initializer["isNavigationRequest"]
115114

playwright/_impl/_page.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ async def set_viewport_size(self, viewportSize: ViewportSize) -> None:
587587
self._viewport_size = viewportSize
588588
await self._channel.send("setViewportSize", locals_to_params(locals()))
589589

590+
@property
590591
def viewport_size(self) -> Optional[ViewportSize]:
591592
return self._viewport_size
592593

@@ -882,13 +883,6 @@ def expect_file_chooser(
882883
self.wait_for_event("filechooser", predicate, timeout)
883884
)
884885

885-
def expect_load_state(
886-
self,
887-
state: DocumentLoadState = None,
888-
timeout: float = None,
889-
) -> EventContextManagerImpl:
890-
return EventContextManagerImpl(self.wait_for_load_state(state, timeout))
891-
892886
def expect_navigation(
893887
self,
894888
url: URLMatch = None,

playwright/_impl/_video.py

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

1515
import os
16+
import pathlib
1617
from typing import TYPE_CHECKING, cast
1718

1819
if TYPE_CHECKING: # pragma: no cover
@@ -26,13 +27,17 @@ def __init__(self, page: "Page") -> None:
2627
self._page = page
2728
self._path_future = page._loop.create_future()
2829

29-
async def path(self) -> str:
30+
async def path(self) -> pathlib.Path:
3031
return await self._path_future
3132

3233
def _set_relative_path(self, relative_path: str) -> None:
3334
self._path_future.set_result(
34-
os.path.join(
35-
cast(str, self._page._browser_context._options["recordVideo"]["dir"]),
36-
relative_path,
35+
pathlib.Path(
36+
os.path.join(
37+
cast(
38+
str, self._page._browser_context._options["recordVideo"]["dir"]
39+
),
40+
relative_path,
41+
)
3742
)
3843
)

0 commit comments

Comments
 (0)