Skip to content

Commit c4efb21

Browse files
committed
refactor: update docstrings in ActionBuilder class to use 'Args' format for consistency
1 parent 433f239 commit c4efb21

File tree

1 file changed

+31
-54
lines changed

1 file changed

+31
-54
lines changed

py/selenium/webdriver/common/actions/action_builder.py

Lines changed: 31 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,11 @@ def __init__(
4949
def get_device_with(self, name: str) -> Optional[Union["WheelInput", "PointerInput", "KeyInput"]]:
5050
"""Get the device with the given name.
5151
52-
Parameters:
53-
-----------
54-
name : str
55-
The name of the device to get.
52+
Args:
53+
name: The name of the device to get.
5654
5755
Returns:
58-
--------
59-
Optional[Union[WheelInput, PointerInput, KeyInput]] : The device with the given name.
56+
The device with the given name, or None if not found.
6057
"""
6158
return next(filter(lambda x: x == name, self.devices), None)
6259

@@ -83,19 +80,15 @@ def wheel_action(self) -> WheelActions:
8380
def add_key_input(self, name: str) -> KeyInput:
8481
"""Add a new key input device to the action builder.
8582
86-
Parameters:
87-
-----------
88-
name : str
89-
The name of the key input device.
83+
Args:
84+
name: The name of the key input device.
9085
9186
Returns:
92-
--------
93-
KeyInput : The newly created key input device.
87+
The newly created key input device.
9488
9589
Example:
96-
--------
97-
>>> action_builder = ActionBuilder(driver)
98-
>>> action_builder.add_key_input(name="keyboard2")
90+
>>> action_builder = ActionBuilder(driver)
91+
>>> action_builder.add_key_input(name="keyboard2")
9992
"""
10093
new_input = KeyInput(name)
10194
self._add_input(new_input)
@@ -104,25 +97,17 @@ def add_key_input(self, name: str) -> KeyInput:
10497
def add_pointer_input(self, kind: str, name: str) -> PointerInput:
10598
"""Add a new pointer input device to the action builder.
10699
107-
Parameters:
108-
-----------
109-
kind : str
110-
The kind of pointer input device.
111-
- "mouse"
112-
- "touch"
113-
- "pen"
114-
115-
name : str
116-
The name of the pointer input device.
100+
Args:
101+
kind: The kind of pointer input device. Valid values are "mouse",
102+
"touch", or "pen".
103+
name: The name of the pointer input device.
117104
118105
Returns:
119-
--------
120-
PointerInput : The newly created pointer input device.
106+
The newly created pointer input device.
121107
122108
Example:
123-
--------
124-
>>> action_builder = ActionBuilder(driver)
125-
>>> action_builder.add_pointer_input(kind="mouse", name="mouse")
109+
>>> action_builder = ActionBuilder(driver)
110+
>>> action_builder.add_pointer_input(kind="mouse", name="mouse")
126111
"""
127112
new_input = PointerInput(kind, name)
128113
self._add_input(new_input)
@@ -131,19 +116,15 @@ def add_pointer_input(self, kind: str, name: str) -> PointerInput:
131116
def add_wheel_input(self, name: str) -> WheelInput:
132117
"""Add a new wheel input device to the action builder.
133118
134-
Parameters:
135-
-----------
136-
name : str
137-
The name of the wheel input device.
119+
Args:
120+
name: The name of the wheel input device.
138121
139122
Returns:
140-
--------
141-
WheelInput : The newly created wheel input device.
123+
The newly created wheel input device.
142124
143125
Example:
144-
--------
145-
>>> action_builder = ActionBuilder(driver)
146-
>>> action_builder.add_wheel_input(name="wheel2")
126+
>>> action_builder = ActionBuilder(driver)
127+
>>> action_builder.add_wheel_input(name="wheel2")
147128
"""
148129
new_input = WheelInput(name)
149130
self._add_input(new_input)
@@ -153,11 +134,10 @@ def perform(self) -> None:
153134
"""Performs all stored actions.
154135
155136
Example:
156-
--------
157-
>>> action_builder = ActionBuilder(driver)
158-
>>> keyboard = action_builder.key_input
159-
>>> el = driver.find_element(id: "some_id")
160-
>>> action_builder.click(el).pause(keyboard).pause(keyboard).pause(keyboard).send_keys("keys").perform()
137+
>>> action_builder = ActionBuilder(driver)
138+
>>> keyboard = action_builder.key_input
139+
>>> el = driver.find_element(id: "some_id")
140+
>>> action_builder.click(el).pause(keyboard).pause(keyboard).pause(keyboard).send_keys("keys").perform()
161141
"""
162142
enc: dict[str, list[Any]] = {"actions": []}
163143
for device in self.devices:
@@ -171,21 +151,18 @@ def clear_actions(self) -> None:
171151
"""Clears actions that are already stored on the remote end.
172152
173153
Example:
174-
--------
175-
>>> action_builder = ActionBuilder(driver)
176-
>>> keyboard = action_builder.key_input
177-
>>> el = driver.find_element(By.ID, "some_id")
178-
>>> action_builder.click(el).pause(keyboard).pause(keyboard).pause(keyboard).send_keys("keys")
179-
>>> action_builder.clear_actions()
154+
>>> action_builder = ActionBuilder(driver)
155+
>>> keyboard = action_builder.key_input
156+
>>> el = driver.find_element(By.ID, "some_id")
157+
>>> action_builder.click(el).pause(keyboard).pause(keyboard).pause(keyboard).send_keys("keys")
158+
>>> action_builder.clear_actions()
180159
"""
181160
self.driver.execute(Command.W3C_CLEAR_ACTIONS)
182161

183162
def _add_input(self, new_input: Union[KeyInput, PointerInput, WheelInput]) -> None:
184163
"""Add a new input device to the action builder.
185164
186-
Parameters:
187-
-----------
188-
new_input : Union[KeyInput, PointerInput, WheelInput]
189-
The new input device to add.
165+
Args:
166+
new_input: The new input device to add.
190167
"""
191168
self.devices.append(new_input)

0 commit comments

Comments
 (0)