Skip to content

Commit 001b95b

Browse files
authored
[py] Lint Python with ruff (#15811)
1 parent 9f938ae commit 001b95b

File tree

13 files changed

+60
-17
lines changed

13 files changed

+60
-17
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ py/selenium/webdriver/remote/getAttribute.js
7575
py/selenium/webdriver/remote/isDisplayed.js
7676
py/docs/build/
7777
py/docs/source/**/*
78+
!py/docs/source/conf.py
7879
py/build/
7980
py/LICENSE
8081
py/pytestdebug.log

MODULE.bazel

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module(name = "selenium")
22

33
bazel_dep(name = "apple_rules_lint", version = "0.4.0")
4-
bazel_dep(name = "aspect_rules_lint", version = "1.4.2")
54
bazel_dep(name = "aspect_bazel_lib", version = "2.13.0")
65
bazel_dep(name = "aspect_rules_esbuild", version = "0.21.0")
76
bazel_dep(name = "aspect_rules_js", version = "2.3.7")
@@ -21,6 +20,7 @@ bazel_dep(name = "rules_cc", version = "0.1.1", dev_dependency = True)
2120
bazel_dep(name = "rules_dotnet", version = "0.17.5")
2221
bazel_dep(name = "rules_java", version = "8.7.1")
2322
bazel_dep(name = "rules_jvm_external", version = "6.6")
23+
bazel_dep(name = "rules_multitool", version = "1.3.0")
2424
bazel_dep(name = "rules_nodejs", version = "6.3.2")
2525
bazel_dep(name = "rules_oci", version = "1.8.0")
2626
bazel_dep(name = "rules_pkg", version = "1.0.1")
@@ -37,6 +37,10 @@ git_override(
3737
remote = "https://github.com/bazel-contrib/rules_jvm_external.git",
3838
)
3939

40+
multitool = use_extension("@rules_multitool//multitool:extension.bzl", "multitool")
41+
multitool.hub(lockfile = "//:multitool.lock.json")
42+
use_repo(multitool, "multitool")
43+
4044
linter = use_extension("@apple_rules_lint//lint:extensions.bzl", "linter")
4145
linter.configure(
4246
name = "java-spotbugs",

javascript/private/gen_file.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ def write_atom_literal(out, name, contents, lang, utf8):
4848
name = get_atom_name(name)
4949

5050
if "cc" == lang or "hh" == lang:
51-
string_type = "std::string" if utf8 else "std::wstring"
5251
char_type = "char" if utf8 else "wchar_t"
5352
out.write("const %s* const %s[] = {\n" % (char_type, name))
5453
elif "java" == lang:

multitool.lock.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/theoremlp/rules_multitool/main/lockfile.schema.json",
3+
"ruff": {
4+
"binaries": [
5+
{
6+
"kind": "archive",
7+
"url": "https://github.com/astral-sh/ruff/releases/download/0.11.11/ruff-aarch64-unknown-linux-musl.tar.gz",
8+
"file": "ruff-aarch64-unknown-linux-musl/ruff",
9+
"sha256": "3ca33d9b68b8b0bc7e3673b7638910ac2f7c5399303b37bec4d13c005481a78a",
10+
"os": "linux",
11+
"cpu": "arm64"
12+
},
13+
{
14+
"kind": "archive",
15+
"url": "https://github.com/astral-sh/ruff/releases/download/0.11.11/ruff-x86_64-unknown-linux-musl.tar.gz",
16+
"file": "ruff-x86_64-unknown-linux-musl/ruff",
17+
"sha256": "bb64b083767a5fd0a62e10e9a35614974ad53025e2878cf14a0c698680e6c30c",
18+
"os": "linux",
19+
"cpu": "x86_64"
20+
},
21+
{
22+
"kind": "archive",
23+
"url": "https://github.com/astral-sh/ruff/releases/download/0.11.11/ruff-aarch64-apple-darwin.tar.gz",
24+
"file": "ruff-aarch64-apple-darwin/ruff",
25+
"sha256": "814ccb26bed9c027bfc20ac88d33494ab0be62721757c73be70e26c23efbb3f7",
26+
"os": "macos",
27+
"cpu": "arm64"
28+
},
29+
{
30+
"kind": "archive",
31+
"url": "https://github.com/astral-sh/ruff/releases/download/0.11.11/ruff-x86_64-apple-darwin.tar.gz",
32+
"file": "ruff-x86_64-apple-darwin/ruff",
33+
"sha256": "8bef00e82bc07ea26b45adcffc3d55b2d0821f3a3e4d5f441f4dd4ad608fc1be",
34+
"os": "macos",
35+
"cpu": "x86_64"
36+
},
37+
{
38+
"kind": "archive",
39+
"url": "https://github.com/astral-sh/ruff/releases/download/0.11.11/ruff-x86_64-pc-windows-msvc.zip",
40+
"file": "ruff-x86_64-pc-windows-msvc/ruff.exe",
41+
"sha256": "b7619ff27098a4d7f37c52fb8fc61ccfe677aaade7722a385b40f8d5273ebddd",
42+
"os": "windows",
43+
"cpu": "x86_64"
44+
}
45+
]
46+
}
47+
}

py/BUILD.bazel

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
load("@aspect_bazel_lib//lib:copy_directory.bzl", "copy_directory")
2-
load("@aspect_rules_lint//format:defs.bzl", "format_multirun")
32
load("@bazel_skylib//rules:select_file.bzl", "select_file")
43
load("@py_dev_requirements//:requirements.bzl", "requirement")
54
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
@@ -12,11 +11,6 @@ load("//py:defs.bzl", "generate_devtools", "py_test_suite")
1211
load("//py/private:browsers.bzl", "BROWSERS")
1312
load("//py/private:import.bzl", "py_import")
1413

15-
format_multirun(
16-
name = "format",
17-
python = "@aspect_rules_lint//format:ruff",
18-
)
19-
2014
py_binary(
2115
name = "selenium-release",
2216
srcs = [

py/docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
# under the License.
1717

1818

19-
import sys
2019
import os
2120
import os.path
21+
import sys
2222

2323
# If extensions (or modules to document with autodoc) are in another directory,
2424
# add these directories to sys.path here. If the directory is relative to the

py/release-selenium.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818

1919
import sys
20+
2021
from twine import cli
2122

2223

py/test/selenium/webdriver/common/bidi_tests.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
import pytest
1918

2019
from selenium.webdriver.common.bidi.log import LogLevel
2120
from selenium.webdriver.common.by import By

py/tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ commands = mypy --install-types {posargs}
3535
[testenv:linting]
3636
skip_install = true
3737
deps =
38-
ruff==0.11.10
38+
ruff==0.11.11
3939
commands =
4040
ruff check --fix --show-fixes --exit-non-zero-on-fix selenium/ test/ conftest.py
4141
ruff format --exit-non-zero-on-format selenium/ test/ conftest.py

scripts/format.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ bazel run @rules_rust//:rustfmt
3333

3434
section "Python"
3535
echo " python - ruff" >&2
36-
bazel run //py:format
36+
bazel run @multitool//tools/ruff:cwd -- check --fix --show-fixes
37+
bazel run @multitool//tools/ruff:cwd -- format
3738

3839
section "Copyright"
3940
bazel run //scripts:update_copyright

scripts/pinned_browsers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ def edge():
205205
linux_hash = None
206206
mac = None
207207
mac_hash = None
208-
version = None
209208

210209
for data in all_data:
211210
if not "Stable" == data.get("product"):

scripts/selenium_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
def get_url():
1616
r = http.request(
1717
"GET",
18-
f"https://github.com/SeleniumHQ/selenium_manager_artifacts/releases/latest",
18+
"https://github.com/SeleniumHQ/selenium_manager_artifacts/releases/latest",
1919
)
2020
return r.url.replace("tag", "download")
2121

2222

2323
def get_sha_json():
2424
r = http.request(
2525
"GET",
26-
f"https://raw.githubusercontent.com/SeleniumHQ/selenium_manager_artifacts/trunk/latest.json",
26+
"https://raw.githubusercontent.com/SeleniumHQ/selenium_manager_artifacts/trunk/latest.json",
2727
)
2828
return json.loads(r.data)
2929

scripts/update_cdp.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
#!/usr/bin/env python
22

33
import argparse
4-
import hashlib
54
import json
65
import os
76
import re
87
import shutil
98
import subprocess
10-
import sys
119
from pathlib import Path
1210

1311
import urllib3

0 commit comments

Comments
 (0)