Skip to content

Commit e5dc9b1

Browse files
authored
docs: update generator to the new docs infra (microsoft#414)
1 parent 0b4a980 commit e5dc9b1

23 files changed

+4598
-3633
lines changed

playwright/_impl/_api_structures.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
else: # pragma: no cover
2121
from typing_extensions import Literal, TypedDict
2222

23-
# These are the structures that we like keeping in a JSON form for their potential reuse between SDKs / services.
23+
# These are the structures that we like keeping in a JSON form for their potential
24+
# reuse between SDKs / services. They are public and are a part of the
25+
# stable API.
2426

2527
# Explicitly mark optional params as such for the documentation
2628
# If there is at least one optional param, set total=False for better mypy handling.
@@ -32,7 +34,7 @@ class Cookie(TypedDict, total=False):
3234
url: Optional[str]
3335
domain: Optional[str]
3436
path: Optional[str]
35-
expires: Optional[int]
37+
expires: Optional[float]
3638
httpOnly: Optional[bool]
3739
secure: Optional[bool]
3840
sameSite: Optional[Literal["Strict", "Lax", "None"]]

playwright/_impl/_api_types.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
else: # pragma: no cover
2121
from typing_extensions import TypedDict
2222

23+
# These are types that we use in the API. They are public and are a part of the
24+
# stable API.
25+
2326

2427
class Error(Exception):
2528
def __init__(self, message: str, stack: str = None) -> None:
@@ -93,17 +96,17 @@ def __init__(self, latitude: float, longitude: float, accuracy: float = None):
9396

9497

9598
class PdfMargins(ApiType):
96-
top: Optional[Union[str, int]]
97-
right: Optional[Union[str, int]]
98-
bottom: Optional[Union[str, int]]
99-
left: Optional[Union[str, int]]
99+
top: Optional[Union[str, float]]
100+
right: Optional[Union[str, float]]
101+
bottom: Optional[Union[str, float]]
102+
left: Optional[Union[str, float]]
100103

101104
def __init__(
102105
self,
103-
top: Union[str, int],
104-
right: Union[str, int],
105-
bottom: Union[str, int],
106-
left: Union[str, int],
106+
top: Union[str, float],
107+
right: Union[str, float],
108+
bottom: Union[str, float],
109+
left: Union[str, float],
107110
):
108111
self.top = top
109112
self.right = right
@@ -132,13 +135,13 @@ def __init__(
132135

133136
class SourceLocation(ApiType):
134137
url: str
135-
line: int
136-
column: int
138+
line_number: int
139+
column_number: int
137140

138-
def __init__(self, url: str, line: int, column: int):
141+
def __init__(self, url: str, line_number: int, column_number: int):
139142
self.url = url
140-
self.line = line
141-
self.column = column
143+
self.line_number = line_number
144+
self.column_number = column_number
142145

143146

144147
def filter_out_none(args: Dict) -> Any:

playwright/_impl/_browser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ async def newContext(
7878
extraHTTPHeaders: Dict[str, str] = None,
7979
offline: bool = None,
8080
httpCredentials: Tuple[str, str] = None,
81-
deviceScaleFactor: int = None,
81+
deviceScaleFactor: float = None,
8282
isMobile: bool = None,
8383
hasTouch: bool = None,
8484
colorScheme: ColorScheme = None,
@@ -115,7 +115,7 @@ async def newPage(
115115
extraHTTPHeaders: Dict[str, str] = None,
116116
offline: bool = None,
117117
httpCredentials: Tuple[str, str] = None,
118-
deviceScaleFactor: int = None,
118+
deviceScaleFactor: float = None,
119119
isMobile: bool = None,
120120
hasTouch: bool = None,
121121
colorScheme: ColorScheme = None,

playwright/_impl/_browser_context.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ def _on_binding(self, binding_call: BindingCall) -> None:
9797
return
9898
asyncio.create_task(binding_call.call(func))
9999

100-
def setDefaultNavigationTimeout(self, timeout: int) -> None:
100+
def setDefaultNavigationTimeout(self, timeout: float) -> None:
101101
self._timeout_settings.set_navigation_timeout(timeout)
102102
self._channel.send_no_reply(
103103
"setDefaultNavigationTimeoutNoReply", dict(timeout=timeout)
104104
)
105105

106-
def setDefaultTimeout(self, timeout: int) -> None:
106+
def setDefaultTimeout(self, timeout: float) -> None:
107107
self._timeout_settings.set_timeout(timeout)
108108
self._channel.send_no_reply("setDefaultTimeoutNoReply", dict(timeout=timeout))
109109

@@ -160,17 +160,17 @@ async def setOffline(self, offline: bool) -> None:
160160
await self._channel.send("setOffline", dict(offline=offline))
161161

162162
async def addInitScript(
163-
self, source: str = None, path: Union[str, Path] = None
163+
self, script: str = None, path: Union[str, Path] = None
164164
) -> None:
165165
if path:
166166
with open(path, "r") as file:
167-
source = file.read()
168-
if not isinstance(source, str):
167+
script = file.read()
168+
if not isinstance(script, str):
169169
raise Error("Either path or source parameter must be specified")
170-
await self._channel.send("addInitScript", dict(source=source))
170+
await self._channel.send("addInitScript", dict(source=script))
171171

172172
async def exposeBinding(
173-
self, name: str, binding: Callable, handle: bool = None
173+
self, name: str, callback: Callable, handle: bool = None
174174
) -> None:
175175
for page in self._pages:
176176
if name in page._bindings:
@@ -179,13 +179,13 @@ async def exposeBinding(
179179
)
180180
if name in self._bindings:
181181
raise Error(f'Function "{name}" has been already registered')
182-
self._bindings[name] = binding
182+
self._bindings[name] = callback
183183
await self._channel.send(
184184
"exposeBinding", dict(name=name, needsHandle=handle or False)
185185
)
186186

187-
async def exposeFunction(self, name: str, binding: Callable) -> None:
188-
await self.exposeBinding(name, lambda source, *args: binding(*args))
187+
async def exposeFunction(self, name: str, callback: Callable) -> None:
188+
await self.exposeBinding(name, lambda source, *args: callback(*args))
189189

190190
async def route(self, url: URLMatch, handler: RouteHandler) -> None:
191191
self._routes.append(RouteHandlerEntry(URLMatcher(url), handler))
@@ -209,7 +209,7 @@ async def unroute(
209209
)
210210

211211
async def waitForEvent(
212-
self, event: str, predicate: Callable[[Any], bool] = None, timeout: int = None
212+
self, event: str, predicate: Callable[[Any], bool] = None, timeout: float = None
213213
) -> Any:
214214
if timeout is None:
215215
timeout = self._timeout_settings.timeout()
@@ -256,13 +256,13 @@ def expect_event(
256256
self,
257257
event: str,
258258
predicate: Callable[[Any], bool] = None,
259-
timeout: int = None,
259+
timeout: float = None,
260260
) -> EventContextManagerImpl:
261261
return EventContextManagerImpl(self.waitForEvent(event, predicate, timeout))
262262

263263
def expect_page(
264264
self,
265265
predicate: Callable[[Page], bool] = None,
266-
timeout: int = None,
266+
timeout: float = None,
267267
) -> EventContextManagerImpl[Page]:
268268
return EventContextManagerImpl(self.waitForEvent("page", predicate, timeout))

playwright/_impl/_browser_type.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ async def launch(
5555
handleSIGINT: bool = None,
5656
handleSIGTERM: bool = None,
5757
handleSIGHUP: bool = None,
58-
timeout: int = None,
58+
timeout: float = None,
5959
env: Env = None,
6060
headless: bool = None,
6161
devtools: bool = None,
6262
proxy: ProxySettings = None,
6363
downloadsPath: Union[str, Path] = None,
64-
slowMo: int = None,
64+
slowMo: float = None,
6565
chromiumSandbox: bool = None,
66-
firefoxUserPrefs: Dict[str, Union[str, int, bool]] = None,
66+
firefoxUserPrefs: Dict[str, Union[str, float, bool]] = None,
6767
) -> Browser:
6868
params = locals_to_params(locals())
6969
normalize_launch_params(params)
@@ -83,13 +83,13 @@ async def launchPersistentContext(
8383
handleSIGINT: bool = None,
8484
handleSIGTERM: bool = None,
8585
handleSIGHUP: bool = None,
86-
timeout: int = None,
86+
timeout: float = None,
8787
env: Env = None,
8888
headless: bool = None,
8989
devtools: bool = None,
9090
proxy: ProxySettings = None,
9191
downloadsPath: Union[str, Path] = None,
92-
slowMo: int = None,
92+
slowMo: float = None,
9393
viewport: Union[Tuple[int, int], Literal[0]] = None,
9494
ignoreHTTPSErrors: bool = None,
9595
javaScriptEnabled: bool = None,
@@ -102,7 +102,7 @@ async def launchPersistentContext(
102102
extraHTTPHeaders: Dict[str, str] = None,
103103
offline: bool = None,
104104
httpCredentials: Tuple[str, str] = None,
105-
deviceScaleFactor: int = None,
105+
deviceScaleFactor: float = None,
106106
isMobile: bool = None,
107107
hasTouch: bool = None,
108108
colorScheme: ColorScheme = None,

playwright/_impl/_element_handle.py

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ def __init__(
5656
async def _createSelectorForTest(self, name: str) -> Optional[str]:
5757
return await self._channel.send("createSelectorForTest", dict(name=name))
5858

59-
def toString(self) -> str:
60-
return self._preview
61-
6259
def asElement(self) -> Optional["ElementHandle"]:
6360
return self
6461

@@ -85,14 +82,14 @@ async def dispatchEvent(self, type: str, eventInit: Dict = None) -> None:
8582
"dispatchEvent", dict(type=type, eventInit=serialize_argument(eventInit))
8683
)
8784

88-
async def scrollIntoViewIfNeeded(self, timeout: int = None) -> None:
85+
async def scrollIntoViewIfNeeded(self, timeout: float = None) -> None:
8986
await self._channel.send("scrollIntoViewIfNeeded", locals_to_params(locals()))
9087

9188
async def hover(
9289
self,
9390
modifiers: List[KeyboardModifier] = None,
9491
position: Tuple[float, float] = None,
95-
timeout: int = None,
92+
timeout: float = None,
9693
force: bool = None,
9794
) -> None:
9895
await self._channel.send("hover", locals_to_params(locals()))
@@ -101,10 +98,10 @@ async def click(
10198
self,
10299
modifiers: List[KeyboardModifier] = None,
103100
position: Tuple[float, float] = None,
104-
delay: int = None,
101+
delay: float = None,
105102
button: MouseButton = None,
106103
clickCount: int = None,
107-
timeout: int = None,
104+
timeout: float = None,
108105
force: bool = None,
109106
noWaitAfter: bool = None,
110107
) -> None:
@@ -114,9 +111,9 @@ async def dblclick(
114111
self,
115112
modifiers: List[KeyboardModifier] = None,
116113
position: Tuple[float, float] = None,
117-
delay: int = None,
114+
delay: float = None,
118115
button: MouseButton = None,
119-
timeout: int = None,
116+
timeout: float = None,
120117
force: bool = None,
121118
noWaitAfter: bool = None,
122119
) -> None:
@@ -128,7 +125,7 @@ async def selectOption(
128125
index: Union[int, List[int]] = None,
129126
label: Union[str, List[str]] = None,
130127
element: Union["ElementHandle", List["ElementHandle"]] = None,
131-
timeout: int = None,
128+
timeout: float = None,
132129
noWaitAfter: bool = None,
133130
) -> List[str]:
134131
params = locals_to_params(
@@ -144,24 +141,24 @@ async def tap(
144141
self,
145142
modifiers: List[KeyboardModifier] = None,
146143
position: Tuple[float, float] = None,
147-
timeout: int = None,
144+
timeout: float = None,
148145
force: bool = None,
149146
noWaitAfter: bool = None,
150147
) -> None:
151148
await self._channel.send("tap", locals_to_params(locals()))
152149

153150
async def fill(
154-
self, value: str, timeout: int = None, noWaitAfter: bool = None
151+
self, value: str, timeout: float = None, noWaitAfter: bool = None
155152
) -> None:
156153
await self._channel.send("fill", locals_to_params(locals()))
157154

158-
async def selectText(self, timeout: int = None) -> None:
155+
async def selectText(self, timeout: float = None) -> None:
159156
await self._channel.send("selectText", locals_to_params(locals()))
160157

161158
async def setInputFiles(
162159
self,
163160
files: Union[str, Path, FilePayload, List[str], List[Path], List[FilePayload]],
164-
timeout: int = None,
161+
timeout: float = None,
165162
noWaitAfter: bool = None,
166163
) -> None:
167164
params = locals_to_params(locals())
@@ -174,24 +171,28 @@ async def focus(self) -> None:
174171
async def type(
175172
self,
176173
text: str,
177-
delay: int = None,
178-
timeout: int = None,
174+
delay: float = None,
175+
timeout: float = None,
179176
noWaitAfter: bool = None,
180177
) -> None:
181178
await self._channel.send("type", locals_to_params(locals()))
182179

183180
async def press(
184-
self, key: str, delay: int = None, timeout: int = None, noWaitAfter: bool = None
181+
self,
182+
key: str,
183+
delay: float = None,
184+
timeout: float = None,
185+
noWaitAfter: bool = None,
185186
) -> None:
186187
await self._channel.send("press", locals_to_params(locals()))
187188

188189
async def check(
189-
self, timeout: int = None, force: bool = None, noWaitAfter: bool = None
190+
self, timeout: float = None, force: bool = None, noWaitAfter: bool = None
190191
) -> None:
191192
await self._channel.send("check", locals_to_params(locals()))
192193

193194
async def uncheck(
194-
self, timeout: int = None, force: bool = None, noWaitAfter: bool = None
195+
self, timeout: float = None, force: bool = None, noWaitAfter: bool = None
195196
) -> None:
196197
await self._channel.send("uncheck", locals_to_params(locals()))
197198

@@ -201,7 +202,7 @@ async def boundingBox(self) -> Optional[FloatRect]:
201202

202203
async def screenshot(
203204
self,
204-
timeout: int = None,
205+
timeout: float = None,
205206
type: Literal["jpeg", "png"] = None,
206207
path: Union[str, Path] = None,
207208
quality: int = None,
@@ -271,15 +272,15 @@ async def evalOnSelectorAll(
271272
async def waitForElementState(
272273
self,
273274
state: Literal["disabled", "enabled", "hidden", "stable", "visible"],
274-
timeout: int = None,
275+
timeout: float = None,
275276
) -> None:
276277
await self._channel.send("waitForElementState", locals_to_params(locals()))
277278

278279
async def waitForSelector(
279280
self,
280281
selector: str,
281282
state: Literal["attached", "detached", "hidden", "visible"] = None,
282-
timeout: int = None,
283+
timeout: float = None,
283284
) -> Optional["ElementHandle"]:
284285
return from_nullable_channel(
285286
await self._channel.send("waitForSelector", locals_to_params(locals()))

playwright/_impl/_file_chooser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def isMultiple(self) -> bool:
5050
async def setFiles(
5151
self,
5252
files: Union[str, FilePayload, List[str], List[FilePayload]],
53-
timeout: int = None,
53+
timeout: float = None,
5454
noWaitAfter: bool = None,
5555
) -> None:
5656
await self._element_handle.setInputFiles(files, timeout, noWaitAfter)

0 commit comments

Comments
 (0)