Skip to content

Commit 3718fe7

Browse files
authored
Merge branch 'trunk' into timezone
2 parents 03173c2 + 878317f commit 3718fe7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+125
-111
lines changed

py/generate_api_module_listing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
file containing a listing of all modules in separate sections.
2222
The `api.rst` file is later used by `sphinx-autogen` to generate
2323
sphinx autodoc stub pages used in the Python API documentation.
24-
See `py/tox.ini` for how it is invoked."""
24+
See `py/tox.ini` for how it is invoked.
25+
"""
2526

2627
import os
2728
import site

py/pyproject.toml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,26 @@ respect-gitignore = true
144144
target-version = "py39"
145145

146146
[tool.ruff.lint]
147-
extend-select = ["E4", "E7", "E9", "F", "I", "E501", "RUF022", "TID252"]
147+
extend-select = ["D", "E4", "E7", "E9", "F", "I", "E501", "RUF022", "TID252"]
148148
fixable = ["ALL"]
149+
# remove these as we cleanup docstrings
150+
extend-ignore = [
151+
"D100", # Missing docstring in public module
152+
"D101", # Missing docstring in public class
153+
"D102", # Missing docstring in public method
154+
"D103", # Missing docstring in public function
155+
"D104", # Missing docstring in public package
156+
"D105", # Missing docstring in magic method
157+
"D107", # Missing docstring in `__init__`
158+
"D205", # 1 blank line required between summary line and description
159+
"D212", # Multi-line docstring summary should start at the first line
160+
"D415", # First line should end with a period, question mark, or exclamation point
161+
"D417", # Missing argument descriptions in the docstring for `__init__`
162+
]
149163

150164
[tool.ruff.format]
151165
docstring-code-format = true
152166
docstring-code-line-length = 120
167+
168+
[tool.ruff.lint.pydocstyle]
169+
convention = "google"

py/selenium/common/exceptions.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ class NoSuchAttributeException(WebDriverException):
9292

9393
class NoSuchShadowRootException(WebDriverException):
9494
"""Thrown when trying to access the shadow root of an element when it does
95-
not have a shadow root attached."""
95+
not have a shadow root attached.
96+
"""
9697

9798

9899
class StaleElementReferenceException(WebDriverException):
@@ -175,7 +176,8 @@ def __init__(
175176

176177
class ElementNotInteractableException(InvalidElementStateException):
177178
"""Thrown when an element is present in the DOM but interactions with that
178-
element will hit another element due to paint order."""
179+
element will hit another element due to paint order.
180+
"""
179181

180182
def __init__(
181183
self, msg: Optional[Any] = None, screen: Optional[str] = None, stacktrace: Optional[Sequence[str]] = None
@@ -194,7 +196,8 @@ class ElementNotSelectableException(InvalidElementStateException):
194196

195197
class InvalidCookieDomainException(WebDriverException):
196198
"""Thrown when attempting to add a cookie under a different domain than the
197-
current URL."""
199+
current URL.
200+
"""
198201

199202

200203
class UnableToSetCookieException(WebDriverException):
@@ -207,7 +210,8 @@ class TimeoutException(WebDriverException):
207210

208211
class MoveTargetOutOfBoundsException(WebDriverException):
209212
"""Thrown when the target provided to the `ActionsChains` move() method is
210-
invalid, i.e. out of document."""
213+
invalid, i.e. out of document.
214+
"""
211215

212216

213217
class UnexpectedTagNameException(WebDriverException):
@@ -254,7 +258,8 @@ class JavascriptException(WebDriverException):
254258

255259
class NoSuchCookieException(WebDriverException):
256260
"""No cookie matching the given path name was found amongst the associated
257-
cookies of the current browsing context's active document."""
261+
cookies of the current browsing context's active document.
262+
"""
258263

259264

260265
class ScreenshotException(WebDriverException):
@@ -264,7 +269,8 @@ class ScreenshotException(WebDriverException):
264269
class ElementClickInterceptedException(WebDriverException):
265270
"""The Element Click command could not be completed because the element
266271
receiving the events is obscuring the element that was requested to be
267-
clicked."""
272+
clicked.
273+
"""
268274

269275
def __init__(
270276
self, msg: Optional[Any] = None, screen: Optional[str] = None, stacktrace: Optional[Sequence[str]] = None
@@ -276,7 +282,8 @@ def __init__(
276282

277283
class InsecureCertificateException(WebDriverException):
278284
"""Navigation caused the user agent to hit a certificate warning, which is
279-
usually the result of an expired or invalid TLS certificate."""
285+
usually the result of an expired or invalid TLS certificate.
286+
"""
280287

281288

282289
class InvalidCoordinatesException(WebDriverException):
@@ -285,7 +292,8 @@ class InvalidCoordinatesException(WebDriverException):
285292

286293
class InvalidSessionIdException(WebDriverException):
287294
"""Occurs if the given session id is not in the list of active sessions,
288-
meaning the session either does not exist or that it's not active."""
295+
meaning the session either does not exist or that it's not active.
296+
"""
289297

290298
def __init__(
291299
self, msg: Optional[Any] = None, screen: Optional[str] = None, stacktrace: Optional[Sequence[str]] = None
@@ -308,7 +316,8 @@ def __init__(
308316

309317
class UnknownMethodException(WebDriverException):
310318
"""The requested command matched a known URL but did not match any methods
311-
for that URL."""
319+
for that URL.
320+
"""
312321

313322

314323
class NoSuchDriverException(WebDriverException):

py/selenium/webdriver/chromium/options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def add_extension(self, extension: str) -> None:
100100
extract it to the ChromeDriver.
101101
102102
Args:
103-
extension: Path to the \\*.crx file.
103+
extension: Path to the *.crx file.
104104
"""
105105
if extension:
106106
extension_to_add = os.path.abspath(os.path.expanduser(extension))

py/selenium/webdriver/chromium/webdriver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727

2828
class ChromiumDriver(RemoteWebDriver):
2929
"""Controls the WebDriver instance of ChromiumDriver and allows you to
30-
drive the browser."""
30+
drive the browser.
31+
"""
3132

3233
def __init__(
3334
self,
@@ -47,7 +48,6 @@ def __init__(
4748
service: Service object for handling the browser driver if you need to pass extra details.
4849
keep_alive: Whether to configure ChromiumRemoteConnection to use HTTP keep-alive.
4950
"""
50-
5151
self.service = service if service else ChromiumService()
5252
options = options if options else ChromiumOptions()
5353

py/selenium/webdriver/common/action_chains.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ def perform(self) -> None:
9393

9494
def reset_actions(self) -> None:
9595
"""Clears actions that are already stored locally and on the remote
96-
end."""
96+
end.
97+
"""
9798
self.w3c_actions.clear_actions()
9899
for device in self.w3c_actions.devices:
99100
device.clear_actions()
@@ -235,7 +236,6 @@ def move_by_offset(self, xoffset: int, yoffset: int) -> ActionChains:
235236
xoffset: X offset to move to, as a positive or negative integer.
236237
yoffset: Y offset to move to, as a positive or negative integer.
237238
"""
238-
239239
self.w3c_actions.pointer_action.move_by(xoffset, yoffset)
240240
self.w3c_actions.key_action.pause()
241241

@@ -247,7 +247,6 @@ def move_to_element(self, to_element: WebElement) -> ActionChains:
247247
Args:
248248
to_element: The WebElement to move to.
249249
"""
250-
251250
self.w3c_actions.pointer_action.move_to(to_element)
252251
self.w3c_actions.key_action.pause()
253252

@@ -262,15 +261,13 @@ def move_to_element_with_offset(self, to_element: WebElement, xoffset: int, yoff
262261
xoffset: X offset to move to, as a positive or negative integer.
263262
yoffset: Y offset to move to, as a positive or negative integer.
264263
"""
265-
266264
self.w3c_actions.pointer_action.move_to(to_element, int(xoffset), int(yoffset))
267265
self.w3c_actions.key_action.pause()
268266

269267
return self
270268

271269
def pause(self, seconds: float | int) -> ActionChains:
272270
"""Pause all inputs for the specified duration in seconds."""
273-
274271
self.w3c_actions.pointer_action.pause(seconds)
275272
self.w3c_actions.key_action.pause(int(seconds))
276273

@@ -325,7 +322,6 @@ def scroll_to_element(self, element: WebElement) -> ActionChains:
325322
Args:
326323
element: Which element to scroll into the viewport.
327324
"""
328-
329325
self.w3c_actions.wheel_action.scroll(origin=element)
330326
return self
331327

@@ -337,7 +333,6 @@ def scroll_by_amount(self, delta_x: int, delta_y: int) -> ActionChains:
337333
delta_x: Distance along X axis to scroll using the wheel. A negative value scrolls left.
338334
delta_y: Distance along Y axis to scroll using the wheel. A negative value scrolls up.
339335
"""
340-
341336
self.w3c_actions.wheel_action.scroll(delta_x=delta_x, delta_y=delta_y)
342337
return self
343338

@@ -356,7 +351,6 @@ def scroll_from_origin(self, scroll_origin: ScrollOrigin, delta_x: int, delta_y:
356351
Raises:
357352
MoveTargetOutOfBoundsException: If the origin with offset is outside the viewport.
358353
"""
359-
360354
if not isinstance(scroll_origin, ScrollOrigin):
361355
raise TypeError(f"Expected object of type ScrollOrigin, got: {type(scroll_origin)}")
362356

py/selenium/webdriver/common/actions/input_device.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ def __init__(self, name: Optional[str] = None):
2727
self.actions: list[Any] = []
2828

2929
def add_action(self, action: Any) -> None:
30-
""""""
3130
self.actions.append(action)
3231

3332
def clear_actions(self) -> None:

py/selenium/webdriver/common/bidi/browser.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,7 @@ def from_dict(cls, data: dict) -> "ClientWindowInfo":
169169

170170

171171
class Browser:
172-
"""
173-
BiDi implementation of the browser module.
174-
"""
172+
"""BiDi implementation of the browser module."""
175173

176174
def __init__(self, conn):
177175
self.conn = conn

py/selenium/webdriver/common/bidi/input.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,7 @@ def from_json(cls, json):
378378

379379

380380
class Input:
381-
"""
382-
BiDi implementation of the input module.
383-
"""
381+
"""BiDi implementation of the input module."""
384382

385383
def __init__(self, conn):
386384
self.conn = conn

py/selenium/webdriver/common/bidi/network.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ def _on_request(self, event_name, callback):
116116
Returns:
117117
int: callback id
118118
"""
119-
120119
event = NetworkEvent(event_name)
121120

122121
def _callback(event_data):
@@ -155,7 +154,6 @@ def add_request_handler(self, event, callback, url_patterns=None, contexts=None)
155154
Returns:
156155
int: callback id
157156
"""
158-
159157
try:
160158
event_name = self.EVENTS[event]
161159
phase_name = self.PHASES[event]
@@ -202,7 +200,6 @@ def remove_request_handler(self, event, callback_id):
202200

203201
def clear_request_handlers(self):
204202
"""Clear all request handlers from the network."""
205-
206203
for event_name in self.subscriptions:
207204
net_event = NetworkEvent(event_name)
208205
for callback_id in self.subscriptions[event_name]:
@@ -270,7 +267,6 @@ def __init__(
270267

271268
def fail_request(self):
272269
"""Fail this request."""
273-
274270
if not self.request_id:
275271
raise ValueError("Request not found.")
276272

@@ -279,7 +275,6 @@ def fail_request(self):
279275

280276
def continue_request(self, body=None, method=None, headers=None, cookies=None, url=None):
281277
"""Continue after intercepting this request."""
282-
283278
if not self.request_id:
284279
raise ValueError("Request not found.")
285280

@@ -307,7 +302,6 @@ def _continue_with_auth(self, username=None, password=None):
307302
Note:
308303
If username or password is None, it attempts auth with no credentials.
309304
"""
310-
311305
params = {}
312306
params["request"] = self.request_id
313307

0 commit comments

Comments
 (0)