Skip to content

Commit 363512f

Browse files
committed
really drop python<=3.7 support
Filter all python code over `pupgrade --py38-plus`. Signed-off-by: Tomasz Kłoczko <[email protected]>
1 parent 6978ea8 commit 363512f

File tree

7 files changed

+44
-45
lines changed

7 files changed

+44
-45
lines changed

common/devtools/convert_protocol_to_json.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def main(argv):
2121
parser.add_argument("json_file", help="The .json output file write.")
2222
args = parser.parse_args(argv)
2323
file_name = os.path.normpath(args.pdl_file)
24-
input_file = open(file_name, "r")
24+
input_file = open(file_name)
2525
pdl_string = input_file.read()
2626
protocol = pdl.loads(pdl_string, file_name, args.map_binary_to_string)
2727
input_file.close()

common/devtools/pdl.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
44

5-
from __future__ import print_function
65
import collections
76
import json
87
import re
@@ -166,7 +165,7 @@ def parse(data, file_name, map_binary_to_string=False):
166165
enumliterals.append(trimLine)
167166
continue
168167

169-
print('Error in %s:%s, illegal token: \t%s' % (file_name, i, line))
168+
print('Error in {}:{}, illegal token: \t{}'.format(file_name, i, line))
170169
sys.exit(1)
171170
return protocol
172171

javascript/private/gen_file.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def write_atom_literal(out, name, contents, lang, utf8):
3838
else:
3939
line_format = " L\"{}\",\n"
4040
elif "java" == lang:
41-
line_format = " .append\(\"{}\")\n"
41+
line_format = " .append\\(\"{}\")\n"
4242
else:
4343
raise RuntimeError("Unknown language: %s " % lang)
4444

@@ -47,7 +47,7 @@ def write_atom_literal(out, name, contents, lang, utf8):
4747
if "cc" == lang or "hh" == lang:
4848
string_type = "std::string" if utf8 else "std::wstring"
4949
char_type = "char" if utf8 else "wchar_t"
50-
out.write("const %s* const %s[] = {\n" % (char_type, name))
50+
out.write("const {}* const {}[] = {{\n".format(char_type, name))
5151
elif "java" == lang:
5252
out.write(" %s(new StringBuilder()\n" % name)
5353
else:
@@ -75,43 +75,43 @@ def write_atom_literal(out, name, contents, lang, utf8):
7575
def generate_header(file_name, out, js_map, just_declare, utf8):
7676
define_guard = "WEBDRIVER_%s" % os.path.basename(file_name.upper()).replace(".", "_")
7777
include_stddef = "" if utf8 else "\n#include <stddef.h> // For wchar_t."
78-
out.write("""%s
78+
out.write("""{}
7979
8080
/* AUTO GENERATED - DO NOT EDIT BY HAND */
81-
#ifndef %s
82-
#define %s
83-
%s
81+
#ifndef {}
82+
#define {}
83+
{}
8484
#include <string> // For std::(w)string.
8585
86-
namespace webdriver {
87-
namespace atoms {
86+
namespace webdriver {{
87+
namespace atoms {{
8888
89-
""" % (_copyright, define_guard, define_guard, include_stddef))
89+
""".format(_copyright, define_guard, define_guard, include_stddef))
9090

9191
string_type = "std::string" if utf8 else "std::wstring"
9292
char_type = "char" if utf8 else "wchar_t"
9393

9494
for (name, file) in js_map.items():
9595
if just_declare:
96-
out.write("extern const %s* const %s[];\n" % (char_type, name.upper()))
96+
out.write("extern const {}* const {}[];\n".format(char_type, name.upper()))
9797
else:
98-
contents = open(file, "r").read()
98+
contents = open(file).read()
9999
write_atom_literal(out, name, contents, "hh", utf8)
100100

101101
out.write("""
102-
static inline %s asString(const %s* const atom[]) {
103-
%s source;
104-
for (int i = 0; atom[i] != NULL; i++) {
102+
static inline {} asString(const {}* const atom[]) {{
103+
{} source;
104+
for (int i = 0; atom[i] != NULL; i++) {{
105105
source += atom[i];
106-
}
106+
}}
107107
return source;
108-
}
108+
}}
109109
110-
} // namespace atoms
111-
} // namespace webdriver
110+
}} // namespace atoms
111+
}} // namespace webdriver
112112
113-
#endif // %s
114-
""" % (string_type, char_type, string_type, define_guard))
113+
#endif // {}
114+
""".format(string_type, char_type, string_type, define_guard))
115115

116116
def generate_cc_source(out, js_map, utf8):
117117
out.write("""%s
@@ -127,7 +127,7 @@ def generate_cc_source(out, js_map, utf8):
127127
""" % _copyright)
128128

129129
for (name, file) in js_map.items():
130-
contents = open(file, "r").read()
130+
contents = open(file).read()
131131
write_atom_literal(out, name, contents, "cc", utf8)
132132

133133
out.write("""
@@ -152,7 +152,7 @@ def generate_java_source(file_name, out, preamble, js_map):
152152
""" % class_name)
153153

154154
for (name, file) in js_map.items():
155-
contents = open(file, "r").read()
155+
contents = open(file).read()
156156
write_atom_literal(out, name, contents, "java", True)
157157

158158
out.write("""

py/selenium/webdriver/remote/webelement.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ def find_element(self, by=By.ID, value=None) -> WebElement:
416416

417417
return self._execute(Command.FIND_CHILD_ELEMENT, {"using": by, "value": value})["value"]
418418

419-
def find_elements(self, by=By.ID, value=None) -> List[WebElement]:
419+
def find_elements(self, by=By.ID, value=None) -> list[WebElement]:
420420
"""Find elements given a By strategy and locator.
421421
422422
:Usage:

py/test/selenium/webdriver/remote/remote_downloads_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test_download_file(driver, pages):
3838
driver.download_file(file_name, target_directory)
3939

4040
target_file = os.path.join(target_directory, file_name)
41-
with open(target_file, "r") as file:
41+
with open(target_file) as file:
4242
assert "Hello, World!" in file.read()
4343

4444

scripts/pinned_browsers.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ def chrome(selected_version):
117117
content = """
118118
http_archive(
119119
name = "linux_chrome",
120-
url = "%s",
121-
sha256 = "%s",
120+
url = "{}",
121+
sha256 = "{}",
122122
build_file_content = \"\"\"
123123
load("@aspect_rules_js//js:defs.bzl", "js_library")
124124
package(default_visibility = ["//visibility:public"])
@@ -137,7 +137,7 @@ def chrome(selected_version):
137137
\"\"\",
138138
)
139139
140-
""" % (
140+
""".format(
141141
linux,
142142
sha,
143143
)
@@ -147,8 +147,8 @@ def chrome(selected_version):
147147

148148
content += """ http_archive(
149149
name = "mac_chrome",
150-
url = "%s",
151-
sha256 = "%s",
150+
url = "{}",
151+
sha256 = "{}",
152152
strip_prefix = "chrome-mac-x64",
153153
patch_cmds = [
154154
"mv 'Google Chrome for Testing.app' Chrome.app",
@@ -167,7 +167,7 @@ def chrome(selected_version):
167167
\"\"\",
168168
)
169169
170-
""" % (
170+
""".format(
171171
mac,
172172
sha,
173173
)
@@ -206,11 +206,11 @@ def edge():
206206
content += """
207207
pkg_archive(
208208
name = "mac_edge",
209-
url = "%s",
210-
sha256 = "%s",
211-
move = {
212-
"MicrosoftEdge-%s.pkg/Payload/Microsoft Edge.app": "Edge.app",
213-
},
209+
url = "{}",
210+
sha256 = "{}",
211+
move = {{
212+
"MicrosoftEdge-{}.pkg/Payload/Microsoft Edge.app": "Edge.app",
213+
}},
214214
build_file_content = \"\"\"
215215
load("@aspect_rules_js//js:defs.bzl", "js_library")
216216
package(default_visibility = ["//visibility:public"])
@@ -223,7 +223,7 @@ def edge():
223223
)
224224
\"\"\",
225225
)
226-
""" % (
226+
""".format(
227227
mac,
228228
mac_hash.lower(),
229229
mac_version,
@@ -233,8 +233,8 @@ def edge():
233233
content += """
234234
deb_archive(
235235
name = "linux_edge",
236-
url = "%s",
237-
sha256 = "%s",
236+
url = "{}",
237+
sha256 = "{}",
238238
build_file_content = \"\"\"
239239
load("@aspect_rules_js//js:defs.bzl", "js_library")
240240
package(default_visibility = ["//visibility:public"])
@@ -252,7 +252,7 @@ def edge():
252252
)
253253
\"\"\",
254254
)
255-
""" % (
255+
""".format(
256256
linux,
257257
linux_hash.lower()
258258
)
@@ -397,11 +397,11 @@ def firefox_version_data():
397397

398398

399399
def firefox_linux(version):
400-
return "https://ftp.mozilla.org/pub/firefox/releases/%s/linux-x86_64/en-US/firefox-%s.tar.bz2" % (version, version)
400+
return "https://ftp.mozilla.org/pub/firefox/releases/{}/linux-x86_64/en-US/firefox-{}.tar.bz2".format(version, version)
401401

402402

403403
def firefox_mac(version):
404-
return "https://ftp.mozilla.org/pub/firefox/releases/%s/mac/en-US/Firefox%%20%s.dmg" % (version, version)
404+
return "https://ftp.mozilla.org/pub/firefox/releases/{}/mac/en-US/Firefox%20{}.dmg".format(version, version)
405405

406406

407407
def print_firefox(version, workspace_name, sha_linux, sha_mac):

scripts/update_copyright.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __init__(self, comment_characters='//', prefix=None):
2828

2929
def update(self, files):
3030
for file in files:
31-
with open(file, 'r') as f:
31+
with open(file) as f:
3232
lines = f.readlines()
3333

3434
index = -1

0 commit comments

Comments
 (0)