Skip to content

Commit a14f153

Browse files
committed
refactor: update parameter documentation to use 'Args' format for consistency across multiple classes
1 parent e82648f commit a14f153

File tree

5 files changed

+52
-75
lines changed

5 files changed

+52
-75
lines changed

py/selenium/webdriver/common/bidi/permissions.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,14 @@ def set_permission(
5555
) -> None:
5656
"""Sets a permission state for a given permission descriptor.
5757
58-
Parameters:
59-
-----------
58+
Args:
6059
descriptor: The permission name (str) or PermissionDescriptor object.
61-
Examples: "geolocation", "camera", "microphone"
60+
Examples: "geolocation", "camera", "microphone".
6261
state: The permission state (granted, denied, prompt).
6362
origin: The origin for which the permission is set.
6463
user_context: The user context id (optional).
6564
6665
Raises:
67-
------
6866
ValueError: If the permission state is invalid.
6967
"""
7068
if state not in [PermissionState.GRANTED, PermissionState.DENIED, PermissionState.PROMPT]:

py/selenium/webdriver/common/bidi/session.py

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,16 @@ def __init__(
4444
):
4545
"""Initialize UserPromptHandler.
4646
47-
Parameters:
48-
-----------
49-
alert: Handler type for alert prompts
50-
before_unload: Handler type for beforeUnload prompts
51-
confirm: Handler type for confirm prompts
52-
default: Default handler type for all prompts
53-
file: Handler type for file picker prompts
54-
prompt: Handler type for prompt dialogs
47+
Args:
48+
alert: Handler type for alert prompts.
49+
before_unload: Handler type for beforeUnload prompts.
50+
confirm: Handler type for confirm prompts.
51+
default: Default handler type for all prompts.
52+
file: Handler type for file picker prompts.
53+
prompt: Handler type for prompt dialogs.
5554
5655
Raises:
57-
------
58-
ValueError: If any handler type is not valid
56+
ValueError: If any handler type is not valid.
5957
"""
6058
for field_name, value in [
6159
("alert", alert),
@@ -81,8 +79,7 @@ def to_dict(self) -> dict[str, str]:
8179
"""Convert the UserPromptHandler to a dictionary for BiDi protocol.
8280
8381
Returns:
84-
-------
85-
Dict[str, str]: Dictionary representation suitable for BiDi protocol
82+
Dictionary representation suitable for BiDi protocol.
8683
"""
8784
field_mapping = {
8885
"alert": "alert",
@@ -126,14 +123,13 @@ def unsubscribe(self, *events, browsing_contexts=None):
126123
return command_builder("session.unsubscribe", params)
127124

128125
def status(self):
129-
"""
130-
The session.status command returns information about the remote end's readiness
131-
to create new sessions and may include implementation-specific metadata.
126+
"""The session.status command returns information about the remote end's readiness.
127+
128+
Returns information about the remote end's readiness to create new sessions
129+
and may include implementation-specific metadata.
132130
133-
Returns
134-
-------
135-
dict
136-
Dictionary containing the ready state (bool), message (str) and metadata
131+
Returns:
132+
Dictionary containing the ready state (bool), message (str) and metadata.
137133
"""
138134
cmd = command_builder("session.status", {})
139135
return self.conn.execute(cmd)

py/selenium/webdriver/common/bidi/storage.py

Lines changed: 27 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ def to_dict(self) -> dict:
4343
"""Converts the BytesValue to a dictionary.
4444
4545
Returns:
46-
-------
47-
Dict: A dictionary representation of the BytesValue.
46+
A dictionary representation of the BytesValue.
4847
"""
4948
return {"type": self.type, "value": self.value}
5049

@@ -78,13 +77,11 @@ def __init__(
7877
def from_dict(cls, data: dict) -> "Cookie":
7978
"""Creates a Cookie instance from a dictionary.
8079
81-
Parameters:
82-
-----------
80+
Args:
8381
data: A dictionary containing the cookie information.
8482
8583
Returns:
86-
-------
87-
Cookie: A new instance of Cookie.
84+
A new instance of Cookie.
8885
"""
8986
# Validation for empty strings
9087
name = data.get("name")
@@ -137,8 +134,7 @@ def to_dict(self) -> dict[str, Any]:
137134
"""Converts the CookieFilter to a dictionary.
138135
139136
Returns:
140-
-------
141-
Dict: A dictionary representation of the CookieFilter.
137+
A dictionary representation of the CookieFilter.
142138
"""
143139
result: dict[str, Any] = {}
144140
if self.name is not None:
@@ -173,13 +169,11 @@ def __init__(self, user_context: Optional[str] = None, source_origin: Optional[s
173169
def from_dict(cls, data: dict) -> "PartitionKey":
174170
"""Creates a PartitionKey instance from a dictionary.
175171
176-
Parameters:
177-
-----------
172+
Args:
178173
data: A dictionary containing the partition key information.
179174
180175
Returns:
181-
-------
182-
PartitionKey: A new instance of PartitionKey.
176+
A new instance of PartitionKey.
183177
"""
184178
return cls(
185179
user_context=data.get("userContext"),
@@ -198,7 +192,6 @@ def to_dict(self) -> dict:
198192
"""Converts the BrowsingContextPartitionDescriptor to a dictionary.
199193
200194
Returns:
201-
-------
202195
Dict: A dictionary representation of the BrowsingContextPartitionDescriptor.
203196
"""
204197
return {"type": self.type, "context": self.context}
@@ -216,7 +209,6 @@ def to_dict(self) -> dict:
216209
"""Converts the StorageKeyPartitionDescriptor to a dictionary.
217210
218211
Returns:
219-
-------
220212
Dict: A dictionary representation of the StorageKeyPartitionDescriptor.
221213
"""
222214
result = {"type": self.type}
@@ -286,13 +278,11 @@ def __init__(self, cookies: list[Cookie], partition_key: PartitionKey):
286278
def from_dict(cls, data: dict) -> "GetCookiesResult":
287279
"""Creates a GetCookiesResult instance from a dictionary.
288280
289-
Parameters:
290-
-----------
281+
Args:
291282
data: A dictionary containing the get cookies result information.
292283
293284
Returns:
294-
-------
295-
GetCookiesResult: A new instance of GetCookiesResult.
285+
A new instance of GetCookiesResult.
296286
"""
297287
cookies = [Cookie.from_dict(cookie) for cookie in data.get("cookies", [])]
298288
partition_key = PartitionKey.from_dict(data.get("partitionKey", {}))
@@ -309,13 +299,11 @@ def __init__(self, partition_key: PartitionKey):
309299
def from_dict(cls, data: dict) -> "SetCookieResult":
310300
"""Creates a SetCookieResult instance from a dictionary.
311301
312-
Parameters:
313-
-----------
302+
Args:
314303
data: A dictionary containing the set cookie result information.
315304
316305
Returns:
317-
-------
318-
SetCookieResult: A new instance of SetCookieResult.
306+
A new instance of SetCookieResult.
319307
"""
320308
partition_key = PartitionKey.from_dict(data.get("partitionKey", {}))
321309
return cls(partition_key=partition_key)
@@ -331,13 +319,11 @@ def __init__(self, partition_key: PartitionKey):
331319
def from_dict(cls, data: dict) -> "DeleteCookiesResult":
332320
"""Creates a DeleteCookiesResult instance from a dictionary.
333321
334-
Parameters:
335-
-----------
322+
Args:
336323
data: A dictionary containing the delete cookies result information.
337324
338325
Returns:
339-
-------
340-
DeleteCookiesResult: A new instance of DeleteCookiesResult.
326+
A new instance of DeleteCookiesResult.
341327
"""
342328
partition_key = PartitionKey.from_dict(data.get("partitionKey", {}))
343329
return cls(partition_key=partition_key)
@@ -354,16 +340,20 @@ def get_cookies(
354340
filter: Optional[CookieFilter] = None,
355341
partition: Optional[Union[BrowsingContextPartitionDescriptor, StorageKeyPartitionDescriptor]] = None,
356342
) -> GetCookiesResult:
357-
"""Retrieves cookies that match the given parameters.
343+
"""Gets cookies matching the specified filter.
358344
359-
Parameters:
360-
-----------
361-
filter: Optional filter to match cookies.
362-
partition: Optional partition descriptor.
345+
Args:
346+
filter: Optional filter to specify which cookies to retrieve.
347+
partition: Optional partition key to limit the scope of the operation.
363348
364349
Returns:
365-
-------
366-
GetCookiesResult: The result of the get cookies command.
350+
A GetCookiesResult containing the cookies and partition key.
351+
352+
Example:
353+
result = await storage.get_cookies(
354+
filter=CookieFilter(name="sessionId"),
355+
partition=PartitionKey(...)
356+
)
367357
"""
368358
params = {}
369359
if filter is not None:
@@ -381,14 +371,12 @@ def set_cookie(
381371
) -> SetCookieResult:
382372
"""Sets a cookie in the browser.
383373
384-
Parameters:
385-
-----------
374+
Args:
386375
cookie: The cookie to set.
387376
partition: Optional partition descriptor.
388377
389378
Returns:
390-
-------
391-
SetCookieResult: The result of the set cookie command.
379+
The result of the set cookie command.
392380
"""
393381
params = {"cookie": cookie.to_dict()}
394382
if partition is not None:
@@ -404,14 +392,12 @@ def delete_cookies(
404392
) -> DeleteCookiesResult:
405393
"""Deletes cookies that match the given parameters.
406394
407-
Parameters:
408-
-----------
395+
Args:
409396
filter: Optional filter to match cookies to delete.
410397
partition: Optional partition descriptor.
411398
412399
Returns:
413-
-------
414-
DeleteCookiesResult: The result of the delete cookies command.
400+
The result of the delete cookies command.
415401
"""
416402
params = {}
417403
if filter is not None:

py/selenium/webdriver/common/bidi/webextension.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,13 @@ def install(self, path=None, archive_path=None, base64_value=None) -> dict:
3434
3535
You must provide exactly one of the parameters.
3636
37-
Parameters:
38-
-----------
39-
path: Path to an extension directory
40-
archive_path: Path to an extension archive file
41-
base64_value: Base64 encoded string of the extension archive
37+
Args:
38+
path: Path to an extension directory.
39+
archive_path: Path to an extension archive file.
40+
base64_value: Base64 encoded string of the extension archive.
4241
4342
Returns:
44-
-------
45-
Dict: A dictionary containing the extension ID.
43+
A dictionary containing the extension ID.
4644
"""
4745
if sum(x is not None for x in (path, archive_path, base64_value)) != 1:
4846
raise ValueError("Exactly one of path, archive_path, or base64_value must be provided")
@@ -70,10 +68,9 @@ def install(self, path=None, archive_path=None, base64_value=None) -> dict:
7068
def uninstall(self, extension_id_or_result: Union[str, dict]) -> None:
7169
"""Uninstalls a web extension from the remote end.
7270
73-
Parameters:
74-
-----------
71+
Args:
7572
extension_id_or_result: Either the extension ID as a string or the result dictionary
76-
from a previous install() call containing the extension ID.
73+
from a previous install() call containing the extension ID.
7774
"""
7875
if isinstance(extension_id_or_result, dict):
7976
extension_id = extension_id_or_result.get("extension")

py/selenium/webdriver/common/options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ class BaseOptions(metaclass=ABCMeta):
201201
bool when getting, None when setting.
202202
"""
203203

204-
strict_file_interactability : o = _BaseOptionsDescriptor("strictFileInteractability")
204+
strict_file_interactability = _BaseOptionsDescriptor("strictFileInteractability")
205205
"""Gets and Sets whether session is about file interactability.
206206
207207
Usage:

0 commit comments

Comments
 (0)