Skip to content

Commit bb64a90

Browse files
committed
[py] Add ruff linter/formatter and fix violations
1 parent 13ffbb9 commit bb64a90

18 files changed

+113
-93
lines changed

py/docs/source/conf.py

Lines changed: 78 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -29,100 +29,108 @@
2929
# -- General configuration -----------------------------------------------------
3030

3131
# If your documentation needs a minimal Sphinx version, state it here.
32-
#needs_sphinx = '1.0'
32+
# needs_sphinx = '1.0'
3333

3434
# Add any Sphinx extension module names here, as strings. They can be extensions
3535
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
36-
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx.ext.doctest', 'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.imgmath', 'sphinx.ext.viewcode']
36+
extensions = [
37+
"sphinx.ext.autodoc",
38+
"sphinx.ext.autosummary",
39+
"sphinx.ext.doctest",
40+
"sphinx.ext.todo",
41+
"sphinx.ext.coverage",
42+
"sphinx.ext.imgmath",
43+
"sphinx.ext.viewcode",
44+
]
3745

3846
# Add any paths that contain templates here, relative to this directory.
39-
templates_path = ['_templates']
47+
templates_path = ["_templates"]
4048

4149
# The suffix of source filenames.
42-
source_suffix = '.rst'
50+
source_suffix = ".rst"
4351

4452
# The encoding of source files.
45-
#source_encoding = 'utf-8-sig'
53+
# source_encoding = 'utf-8-sig'
4654

4755
# The master toctree document.
48-
master_doc = 'index'
56+
master_doc = "index"
4957

5058
# General information about the project.
51-
project = 'Selenium'
52-
copyright = '2009-2025 Software Freedom Conservancy'
59+
project = "Selenium"
60+
copyright = "2009-2025 Software Freedom Conservancy"
5361

5462
# The version info for the project you're documenting, acts as replacement for
5563
# |version| and |release|, also used in various other places throughout the
5664
# built documents.
5765
#
5866
# The short X.Y version.
59-
version = '4.33'
67+
version = "4.33"
6068
# The full version, including alpha/beta/rc tags.
61-
release = '4.33.0.202505022255'
69+
release = "4.33.0.202505022255"
6270

6371
# The language for content autogenerated by Sphinx. Refer to documentation
6472
# for a list of supported languages.
65-
#language = None
73+
# language = None
6674

6775
# There are two options for replacing |today|: either, you set today to some
6876
# non-false value, then it is used:
69-
#today = ''
77+
# today = ''
7078
# Else, today_fmt is used as the format for a strftime call.
71-
#today_fmt = '%B %d, %Y'
79+
# today_fmt = '%B %d, %Y'
7280

7381
# List of patterns, relative to source directory, that match files and
7482
# directories to ignore when looking for source files.
7583
exclude_patterns = []
7684

7785
# The reST default role (used for this markup: `text`) to use for all documents.
78-
#default_role = None
86+
# default_role = None
7987

8088
# If true, '()' will be appended to :func: etc. cross-reference text.
81-
#add_function_parentheses = True
89+
# add_function_parentheses = True
8290

8391
# If true, the current module name will be prepended to all description
8492
# unit titles (such as .. function::).
85-
#add_module_names = True
93+
# add_module_names = True
8694

8795
# If true, sectionauthor and moduleauthor directives will be shown in the
8896
# output. They are ignored by default.
89-
#show_authors = False
97+
# show_authors = False
9098

9199
# The name of the Pygments (syntax highlighting) style to use.
92-
pygments_style = 'sphinx'
100+
pygments_style = "sphinx"
93101

94102
# A list of ignored prefixes for module index sorting.
95-
#modindex_common_prefix = []
103+
# modindex_common_prefix = []
96104

97105

98106
# -- Options for HTML output ---------------------------------------------------
99107

100108
# The theme to use for HTML and HTML Help pages
101-
html_theme = 'sphinx_material'
109+
html_theme = "sphinx_material"
102110

103111
# Theme options are theme-specific and customize the look and feel of a theme
104112
# further. For a list of options available for each theme, see the
105113
# documentation.
106-
#html_theme_options = {}
114+
# html_theme_options = {}
107115

108116
# Add any paths that contain custom themes here, relative to this directory.
109-
#html_theme_path = []
117+
# html_theme_path = []
110118

111119
# The name for this set of Sphinx documents. If None, it defaults to
112120
# "<project> v<release> documentation".
113-
#html_title = None
121+
# html_title = None
114122

115123
# A shorter title for the navigation bar. Default is the same as html_title.
116-
#html_short_title = None
124+
# html_short_title = None
117125

118126
# The name of an image file (relative to this directory) to place at the top
119127
# of the sidebar.
120-
#html_logo = ''
128+
# html_logo = ''
121129

122130
# The name of an image file (within the static path) to use as favicon of the
123131
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
124132
# pixels large.
125-
#html_favicon = None
133+
# html_favicon = None
126134

127135
# Add any paths that contain custom static files (such as style sheets) here,
128136
# relative to this directory. They are copied after the builtin static files,
@@ -131,18 +139,18 @@
131139

132140
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
133141
# using the given strftime format.
134-
#html_last_updated_fmt = '%b %d, %Y'
142+
# html_last_updated_fmt = '%b %d, %Y'
135143

136144
# If true, SmartyPants will be used to convert quotes and dashes to
137145
# typographically correct entities.
138-
#html_use_smartypants = True
146+
# html_use_smartypants = True
139147

140148
# Custom sidebar templates, maps document names to template names.
141-
#html_sidebars = {}
149+
# html_sidebars = {}
142150

143151
# Additional templates that should be rendered to pages, maps page names to
144152
# template names.
145-
#html_additional_pages = {}
153+
# html_additional_pages = {}
146154

147155
# If false, no module index is generated.
148156
html_domain_indices = True
@@ -160,122 +168,126 @@
160168
html_show_sphinx = False
161169

162170
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
163-
#html_show_copyright = True
171+
# html_show_copyright = True
164172

165173
# If true, an OpenSearch description file will be output, and all pages will
166174
# contain a <link> tag referring to it. The value of this option must be the
167175
# base URL from which the finished HTML is served.
168-
#html_use_opensearch = ''
176+
# html_use_opensearch = ''
169177

170178
# This is the file name suffix for HTML files (e.g. ".xhtml").
171-
#html_file_suffix = None
179+
# html_file_suffix = None
172180

173181
# Output file base name for HTML help builder.
174-
htmlhelp_basename = 'Seleniumdoc'
182+
htmlhelp_basename = "Seleniumdoc"
175183

176184

177185
# -- Options for LaTeX output --------------------------------------------------
178186

179187
# The paper size ('letter' or 'a4').
180-
#latex_paper_size = 'letter'
188+
# latex_paper_size = 'letter'
181189

182190
# The font size ('10pt', '11pt' or '12pt').
183-
#latex_font_size = '10pt'
191+
# latex_font_size = '10pt'
184192

185193
# Grouping the document tree into LaTeX files. List of tuples
186194
# (source start file, target name, title, author, documentclass [howto/manual]).
187195
latex_documents = [
188-
('index', 'Selenium.tex', 'Selenium Documentation',
189-
'plightbo, simon.m.stewart, hbchai, jrhuggins, et al.', 'manual'),
196+
(
197+
"index",
198+
"Selenium.tex",
199+
"Selenium Documentation",
200+
"plightbo, simon.m.stewart, hbchai, jrhuggins, et al.",
201+
"manual",
202+
),
190203
]
191204

192205
# The name of an image file (relative to this directory) to place at the top of
193206
# the title page.
194-
#latex_logo = None
207+
# latex_logo = None
195208

196209
# For "manual" documents, if this is true, then toplevel headings are parts,
197210
# not chapters.
198-
#latex_use_parts = False
211+
# latex_use_parts = False
199212

200213
# If true, show page references after internal links.
201-
#latex_show_pagerefs = False
214+
# latex_show_pagerefs = False
202215

203216
# If true, show URL addresses after external links.
204-
#latex_show_urls = False
217+
# latex_show_urls = False
205218

206219
# Additional stuff for the LaTeX preamble.
207-
#latex_preamble = ''
220+
# latex_preamble = ''
208221

209222
# Documents to append as an appendix to all manuals.
210-
#latex_appendices = []
223+
# latex_appendices = []
211224

212225
# If false, no module index is generated.
213-
#latex_domain_indices = True
226+
# latex_domain_indices = True
214227

215228

216229
# -- Options for manual page output --------------------------------------------
217230

218231
# One entry per manual page. List of tuples
219232
# (source start file, name, description, authors, manual section).
220233
man_pages = [
221-
('index', 'selenium', 'Selenium Documentation',
222-
['plightbo, simon.m.stewart, hbchai, jrhuggins, et al.'], 1)
234+
("index", "selenium", "Selenium Documentation", ["plightbo, simon.m.stewart, hbchai, jrhuggins, et al."], 1)
223235
]
224236

225237

226238
# -- Options for Epub output ---------------------------------------------------
227239

228240
# Bibliographic Dublin Core info.
229-
epub_title = 'Selenium'
230-
epub_author = 'The Selenium Project'
231-
epub_publisher = 'The Selenium Project'
232-
epub_copyright = '2009-2024 Software Freedom Conservancy'
241+
epub_title = "Selenium"
242+
epub_author = "The Selenium Project"
243+
epub_publisher = "The Selenium Project"
244+
epub_copyright = "2009-2024 Software Freedom Conservancy"
233245

234246
# The language of the text. It defaults to the language option
235247
# or en if the language is not set.
236-
#epub_language = ''
248+
# epub_language = ''
237249

238250
# The scheme of the identifier. Typical schemes are ISBN or URL.
239-
#epub_scheme = ''
251+
# epub_scheme = ''
240252

241253
# The unique identifier of the text. This can be a ISBN number
242254
# or the project homepage.
243-
#epub_identifier = ''
255+
# epub_identifier = ''
244256

245257
# A unique identification for the text.
246-
#epub_uid = ''
258+
# epub_uid = ''
247259

248260
# HTML files that should be inserted before the pages created by sphinx.
249261
# The format is a list of tuples containing the path and title.
250-
#epub_pre_files = []
262+
# epub_pre_files = []
251263

252264
# HTML files that should be inserted after the pages created by sphinx.
253265
# The format is a list of tuples containing the path and title.
254-
#epub_post_files = []
266+
# epub_post_files = []
255267

256268
# A list of files that should not be packed into the epub file.
257-
#epub_exclude_files = []
269+
# epub_exclude_files = []
258270

259271
# The depth of the table of contents in toc.ncx.
260-
#epub_tocdepth = 3
272+
# epub_tocdepth = 3
261273

262274
# Allow duplicate toc entries.
263-
#epub_tocdup = True
275+
# epub_tocdup = True
264276

265277

266278
# Example configuration for intersphinx: refer to the Python standard library.
267-
intersphinx_mapping = {'http://docs.python.org/': None}
279+
intersphinx_mapping = {"http://docs.python.org/": None}
268280

269281
# 'members' includes anything that has a docstring, 'undoc-members' includes
270282
# functions without docstrings.
271-
autodoc_default_flags = ['members', 'undoc-members']
283+
autodoc_default_flags = ["members", "undoc-members"]
272284

273285
# configuration for keeping the methods that can be invoked on said classes
274286
autodoc_default_options = {
275-
'members': True,
276-
'member-order': 'bysource',
277-
'undoc-members': True,
278-
'inherited-members': True,
287+
"members": True,
288+
"member-order": "bysource",
289+
"undoc-members": True,
290+
"inherited-members": True,
279291
}
280292

281293
# Include __init__ comments

py/pyproject.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,18 @@ extend-ignore = ["E501", "E203"]
166166
max-line-length = 120
167167
min-python-version = "3.9"
168168

169+
[tool.ruff]
170+
exclude = [
171+
"selenium/webdriver/common/devtools/",
172+
"private/",
173+
"generate.py",
174+
]
175+
line-length = 120
176+
177+
[tool.ruff.lint]
178+
extend-select = ["E501"]
179+
fixable = ["ALL"]
180+
169181
[tool.docformatter]
170182
exclude = "selenium/webdriver/common/devtools"
171183
in-place = true

py/release-selenium.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
import sys
2020
from twine import cli
2121

22+
2223
def main():
2324
cli.configure_output()
2425
return cli.dispatch(sys.argv[1:])
2526

27+
2628
if __name__ == "__main__":
2729
sys.exit(main())

py/selenium/webdriver/common/action_chains.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
"""The ActionChains implementation."""
18+
1819
from __future__ import annotations
1920

2021
from typing import TYPE_CHECKING

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020

2121
class Session:
22-
2322
def __init__(self, conn):
2423
self.conn = conn
2524

py/selenium/webdriver/common/driver_finder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ def _binary_paths(self) -> dict:
6868
if Path(output["driver_path"]).is_file():
6969
self._paths["driver_path"] = output["driver_path"]
7070
else:
71-
raise ValueError(f'The driver path is not a valid file: {output["driver_path"]}')
71+
raise ValueError(f"The driver path is not a valid file: {output['driver_path']}")
7272
if Path(output["browser_path"]).is_file():
7373
self._paths["browser_path"] = output["browser_path"]
7474
else:
75-
raise ValueError(f'The browser path is not a valid file: {output["browser_path"]}')
75+
raise ValueError(f"The browser path is not a valid file: {output['browser_path']}")
7676
except Exception as err:
7777
msg = f"Unable to obtain driver for {browser}"
7878
raise NoSuchDriverException(msg) from err

py/selenium/webdriver/common/log.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ async def mutation_events(self) -> AsyncGenerator[Dict[str, Any], None]:
9090
yield event
9191

9292
payload = json.loads(evnt.value.payload)
93-
elements: list = self.driver.find_elements(By.CSS_SELECTOR, f"*[data-__webdriver_id=\"{payload['target']}\"]")
93+
elements: list = self.driver.find_elements(By.CSS_SELECTOR, f'*[data-__webdriver_id="{payload["target"]}"]')
9494
if not elements:
9595
elements.append(None)
9696
event["element"] = elements[0]

py/selenium/webdriver/support/expected_conditions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ def any_of_condition(driver: D):
945945

946946

947947
def all_of(
948-
*expected_conditions: Callable[[D], Union[T, Literal[False]]]
948+
*expected_conditions: Callable[[D], Union[T, Literal[False]]],
949949
) -> Callable[[D], Union[List[T], Literal[False]]]:
950950
"""An expectation that all of multiple expected conditions is true.
951951

0 commit comments

Comments
 (0)