Skip to content

Commit 81b9850

Browse files
[py] Replaced :param: and :args: from docstrings (#16469)
Co-authored-by: Corey Goldberg <[email protected]>
1 parent 76c303b commit 81b9850

File tree

9 files changed

+136
-131
lines changed

9 files changed

+136
-131
lines changed

py/selenium/webdriver/common/bidi/cdp.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ class CdpConnectionClosed(WsConnectionClosed):
166166
def __init__(self, reason):
167167
"""Constructor.
168168
169-
:param reason:
170-
:type reason: wsproto.frame_protocol.CloseReason
169+
Args:
170+
reason: wsproto.frame_protocol.CloseReason
171171
"""
172172
self.reason = reason
173173

@@ -205,8 +205,11 @@ def __init__(self, ws, session_id, target_id):
205205
async def execute(self, cmd: Generator[dict, T, Any]) -> T:
206206
"""Execute a command on the server and wait for the result.
207207
208-
:param cmd: any CDP command
209-
:returns: a CDP result
208+
Args:
209+
cmd: any CDP command
210+
211+
Returns:
212+
a CDP result
210213
"""
211214
cmd_id = next(self.id_iter)
212215
cmd_event = trio.Event()
@@ -261,18 +264,20 @@ async def wait_for(self, event_type: type[T], buffer_size=10) -> AsyncGenerator[
261264
def _handle_data(self, data):
262265
"""Handle incoming WebSocket data.
263266
264-
:param dict data: a JSON dictionary
267+
Args:
268+
data: a JSON dictionary
265269
"""
266270
if "id" in data:
267271
self._handle_cmd_response(data)
268272
else:
269273
self._handle_event(data)
270274

271-
def _handle_cmd_response(self, data):
275+
def _handle_cmd_response(self, data: dict):
272276
"""Handle a response to a command. This will set an event flag that
273277
will return control to the task that called the command.
274278
275-
:param dict data: response as a JSON dictionary
279+
Args:
280+
data: response as a JSON dictionary
276281
"""
277282
cmd_id = data["id"]
278283
try:
@@ -295,10 +300,11 @@ def _handle_cmd_response(self, data):
295300
self.inflight_result[cmd_id] = return_
296301
event.set()
297302

298-
def _handle_event(self, data):
303+
def _handle_event(self, data: dict):
299304
"""Handle an event.
300305
301-
:param dict data: event as a JSON dictionary
306+
Args:
307+
data: event as a JSON dictionary
302308
"""
303309
global devtools
304310
event = devtools.util.parse_json_event(data)
@@ -325,9 +331,10 @@ class CdpSession(CdpBase):
325331
def __init__(self, ws, session_id, target_id):
326332
"""Constructor.
327333
328-
:param trio_websocket.WebSocketConnection ws:
329-
:param devtools.target.SessionID session_id:
330-
:param devtools.target.TargetID target_id:
334+
Args:
335+
ws: trio_websocket.WebSocketConnection
336+
session_id: devtools.target.SessionID
337+
target_id: devtools.target.TargetID
331338
"""
332339
super().__init__(ws, session_id, target_id)
333340

@@ -394,7 +401,8 @@ class corresponds to the "root" session, i.e. the implicitly created
394401
def __init__(self, ws):
395402
"""Constructor.
396403
397-
:param trio_websocket.WebSocketConnection ws:
404+
Args:
405+
ws: trio_websocket.WebSocketConnection
398406
"""
399407
super().__init__(ws, session_id=None, target_id=None)
400408
self.sessions = {}

py/selenium/webdriver/common/bidi/script.py

Lines changed: 15 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,10 @@ class RealmInfo:
6060
def from_json(cls, json: dict[str, Any]) -> "RealmInfo":
6161
"""Creates a RealmInfo instance from a dictionary.
6262
63-
Parameters:
64-
-----------
63+
Args:
6564
json: A dictionary containing the realm information.
6665
6766
Returns:
68-
-------
6967
RealmInfo: A new instance of RealmInfo.
7068
"""
7169
if "realm" not in json:
@@ -95,12 +93,10 @@ class Source:
9593
def from_json(cls, json: dict[str, Any]) -> "Source":
9694
"""Creates a Source instance from a dictionary.
9795
98-
Parameters:
99-
-----------
96+
Args:
10097
json: A dictionary containing the source information.
10198
10299
Returns:
103-
-------
104100
Source: A new instance of Source.
105101
"""
106102
if "realm" not in json:
@@ -125,12 +121,10 @@ class EvaluateResult:
125121
def from_json(cls, json: dict[str, Any]) -> "EvaluateResult":
126122
"""Creates an EvaluateResult instance from a dictionary.
127123
128-
Parameters:
129-
-----------
124+
Args:
130125
json: A dictionary containing the evaluation result.
131126
132127
Returns:
133-
-------
134128
EvaluateResult: A new instance of EvaluateResult.
135129
"""
136130
if "realm" not in json:
@@ -160,12 +154,10 @@ def __init__(self, channel: str, data: dict, source: Source):
160154
def from_json(cls, json: dict[str, Any]) -> "ScriptMessage":
161155
"""Creates a ScriptMessage instance from a dictionary.
162156
163-
Parameters:
164-
-----------
157+
Args:
165158
json: A dictionary containing the script message.
166159
167160
Returns:
168-
-------
169161
ScriptMessage: A new instance of ScriptMessage.
170162
"""
171163
if "channel" not in json:
@@ -194,12 +186,10 @@ def __init__(self, realm_info: RealmInfo):
194186
def from_json(cls, json: dict[str, Any]) -> "RealmCreated":
195187
"""Creates a RealmCreated instance from a dictionary.
196188
197-
Parameters:
198-
-----------
189+
Args:
199190
json: A dictionary containing the realm created event.
200191
201192
Returns:
202-
-------
203193
RealmCreated: A new instance of RealmCreated.
204194
"""
205195
return cls(realm_info=RealmInfo.from_json(json))
@@ -217,12 +207,10 @@ def __init__(self, realm: str):
217207
def from_json(cls, json: dict[str, Any]) -> "RealmDestroyed":
218208
"""Creates a RealmDestroyed instance from a dictionary.
219209
220-
Parameters:
221-
-----------
210+
Args:
222211
json: A dictionary containing the realm destroyed event.
223212
224213
Returns:
225-
-------
226214
RealmDestroyed: A new instance of RealmDestroyed.
227215
"""
228216
if "realm" not in json:
@@ -266,39 +254,33 @@ def remove_console_message_handler(self, id):
266254
def pin(self, script: str) -> str:
267255
"""Pins a script to the current browsing context.
268256
269-
Parameters:
270-
-----------
257+
Args:
271258
script: The script to pin.
272259
273260
Returns:
274-
-------
275261
str: The ID of the pinned script.
276262
"""
277263
return self._add_preload_script(script)
278264

279265
def unpin(self, script_id: str) -> None:
280266
"""Unpins a script from the current browsing context.
281267
282-
Parameters:
283-
-----------
268+
Args:
284269
script_id: The ID of the pinned script to unpin.
285270
"""
286271
self._remove_preload_script(script_id)
287272

288273
def execute(self, script: str, *args) -> dict:
289274
"""Executes a script in the current browsing context.
290275
291-
Parameters:
292-
-----------
276+
Args:
293277
script: The script function to execute.
294278
*args: Arguments to pass to the script function.
295279
296280
Returns:
297-
-------
298281
dict: The result value from the script execution.
299282
300283
Raises:
301-
------
302284
WebDriverException: If the script execution fails.
303285
"""
304286

@@ -390,20 +372,17 @@ def _add_preload_script(
390372
) -> str:
391373
"""Adds a preload script.
392374
393-
Parameters:
394-
-----------
375+
Args:
395376
function_declaration: The function declaration to preload.
396377
arguments: The arguments to pass to the function.
397378
contexts: The browsing context IDs to apply the script to.
398379
user_contexts: The user context IDs to apply the script to.
399380
sandbox: The sandbox name to apply the script to.
400381
401382
Returns:
402-
-------
403383
str: The preload script ID.
404384
405385
Raises:
406-
------
407386
ValueError: If both contexts and user_contexts are provided.
408387
"""
409388
if contexts is not None and user_contexts is not None:
@@ -426,8 +405,7 @@ def _add_preload_script(
426405
def _remove_preload_script(self, script_id: str) -> None:
427406
"""Removes a preload script.
428407
429-
Parameters:
430-
-----------
408+
Args:
431409
script_id: The preload script ID to remove.
432410
"""
433411
params = {"script": script_id}
@@ -436,8 +414,7 @@ def _remove_preload_script(self, script_id: str) -> None:
436414
def _disown(self, handles: list[str], target: dict) -> None:
437415
"""Disowns the given handles.
438416
439-
Parameters:
440-
-----------
417+
Args:
441418
handles: The handles to disown.
442419
target: The target realm or context.
443420
"""
@@ -460,8 +437,7 @@ def _call_function(
460437
) -> EvaluateResult:
461438
"""Calls a provided function with given arguments in a given realm.
462439
463-
Parameters:
464-
-----------
440+
Args:
465441
function_declaration: The function declaration to call.
466442
await_promise: Whether to await promise resolution.
467443
target: The target realm or context.
@@ -472,7 +448,6 @@ def _call_function(
472448
user_activation: Whether to trigger user activation.
473449
474450
Returns:
475-
-------
476451
EvaluateResult: The result of the function call.
477452
"""
478453
params = {
@@ -505,8 +480,7 @@ def _evaluate(
505480
) -> EvaluateResult:
506481
"""Evaluates a provided script in a given realm.
507482
508-
Parameters:
509-
-----------
483+
Args:
510484
expression: The script expression to evaluate.
511485
target: The target realm or context.
512486
await_promise: Whether to await promise resolution.
@@ -515,7 +489,6 @@ def _evaluate(
515489
user_activation: Whether to trigger user activation.
516490
517491
Returns:
518-
-------
519492
EvaluateResult: The result of the script evaluation.
520493
"""
521494
params = {
@@ -540,13 +513,11 @@ def _get_realms(
540513
) -> list[RealmInfo]:
541514
"""Returns a list of all realms, optionally filtered.
542515
543-
Parameters:
544-
-----------
516+
Args:
545517
context: The browsing context ID to filter by.
546518
type: The realm type to filter by.
547519
548520
Returns:
549-
-------
550521
List[RealmInfo]: A list of realm information.
551522
"""
552523
params = {}

py/selenium/webdriver/common/driver_finder.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ class DriverFinder:
2929
"""A Driver finding class responsible for obtaining the correct driver and
3030
associated browser.
3131
32-
:param service: instance of the driver service class.
33-
:param options: instance of the browser options class.
32+
Args:
33+
service: instance of the driver service class.
34+
options: instance of the browser options class.
3435
"""
3536

3637
def __init__(self, service: Service, options: BaseOptions) -> None:

0 commit comments

Comments
 (0)