Skip to content

Commit 38ff810

Browse files
committed
[py] Adjust linting configuration to include /scripts
1 parent 27017a8 commit 38ff810

File tree

5 files changed

+168
-74
lines changed

5 files changed

+168
-74
lines changed

py/tox.ini

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,18 @@ deps =
4444
flake8-typing-imports==1.16.0
4545
docformatter==1.7.5
4646
commands =
47-
isort --check-only --diff selenium/ test/ conftest.py
47+
isort --check-only --diff selenium/ test/ ../scripts conftest.py
4848
black --check --diff selenium/ test/ conftest.py
49+
# run black separately for directories above the current directory
50+
# because it ignores pyproject.toml configuration otrherwise
51+
black --check --diff ../scripts
52+
# not including ../scripts because autofoflake can't handle
53+
# directories above the current directory
4954
autoflake --check-diff selenium/ test/ conftest.py
55+
# not including ../scripts because flake8 can't handle
56+
# directories above the current directory
5057
flake8 selenium/ test/ conftest.py
51-
docformatter --check --diff selenium/ test/ conftest.py
58+
docformatter --check --diff selenium/ test/ ../scripts conftest.py
5259

5360
[testenv:linting]
5461
; A consolidated linting based recipe, responsible for executing linting tools across the code base.
@@ -70,8 +77,15 @@ deps =
7077
flake8-typing-imports==1.16.0
7178
docformatter==1.7.5
7279
commands =
73-
isort selenium/ test/ conftest.py
80+
isort selenium/ test/ ../scripts conftest.py
7481
black selenium/ test/ conftest.py
82+
# run black separately for directories above the current directory
83+
# because it ignores pyproject.toml configuration otrherwise
84+
black ../scripts
85+
# not including ../scripts because autofoflake can't handle
86+
# directories above the current directory
7587
autoflake selenium/ test/ conftest.py
88+
# not including ../scripts because flake8 can't handle
89+
# directories above the current directory
7690
flake8 selenium/ test/ conftest.py
77-
docformatter selenium/ test/ conftest.py
91+
docformatter selenium/ test/ ../scripts conftest.py

scripts/pinned_browsers.py

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,30 @@ def calculate_hash(url):
2828

2929
def get_chrome_milestone():
3030
parser = argparse.ArgumentParser()
31-
parser.add_argument('--chrome_channel', default='Stable', help='Set the Chrome channel')
31+
parser.add_argument(
32+
"--chrome_channel", default="Stable", help="Set the Chrome channel"
33+
)
3234
args = parser.parse_args()
3335
channel = args.chrome_channel
3436

3537
r = http.request(
36-
"GET", f"https://chromiumdash.appspot.com/fetch_releases?channel={channel}&num=1&platform=Mac,Linux"
38+
"GET",
39+
f"https://chromiumdash.appspot.com/fetch_releases?channel={channel}&num=1&platform=Mac,Linux",
3740
)
3841
all_versions = json.loads(r.data)
3942
# use the same milestone for all chrome releases, so pick the lowest
40-
milestone = min([version["milestone"] for version in all_versions if version["milestone"]])
43+
milestone = min(
44+
[version["milestone"] for version in all_versions if version["milestone"]]
45+
)
4146
r = http.request(
42-
"GET", "https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json"
47+
"GET",
48+
"https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json",
4349
)
4450
versions = json.loads(r.data)["versions"]
4551

4652
return sorted(
47-
filter(lambda v: v["version"].split(".")[0] == str(milestone), versions), key=lambda v: parse(v["version"])
53+
filter(lambda v: v["version"].split(".")[0] == str(milestone), versions),
54+
key=lambda v: parse(v["version"]),
4855
)[-1]
4956

5057

@@ -198,7 +205,6 @@ def edge():
198205
linux_hash = None
199206
mac = None
200207
mac_hash = None
201-
version = None
202208

203209
for data in all_data:
204210
if not "Stable" == data.get("product"):
@@ -268,7 +274,7 @@ def edge():
268274
)
269275
""" % (
270276
linux,
271-
linux_hash.lower()
277+
linux_hash.lower(),
272278
)
273279

274280
return content
@@ -277,13 +283,18 @@ def edge():
277283
def edgedriver():
278284
r_stable = http.request("GET", "https://msedgedriver.azureedge.net/LATEST_STABLE")
279285
stable_version = r_stable.data.decode("utf-16").strip()
280-
major_version = stable_version.split('.')[0]
281-
r = http.request("GET", f"https://msedgedriver.azureedge.net/LATEST_RELEASE_{major_version}_LINUX")
286+
major_version = stable_version.split(".")[0]
287+
r = http.request(
288+
"GET",
289+
f"https://msedgedriver.azureedge.net/LATEST_RELEASE_{major_version}_LINUX",
290+
)
282291
linux_version = r.data.decode("utf-16").strip()
283292

284293
content = ""
285294

286-
linux = "https://msedgedriver.azureedge.net/%s/edgedriver_linux64.zip" % linux_version
295+
linux = (
296+
"https://msedgedriver.azureedge.net/%s/edgedriver_linux64.zip" % linux_version
297+
)
287298
sha = calculate_hash(linux)
288299
content = (
289300
content
@@ -308,7 +319,10 @@ def edgedriver():
308319
% (linux, sha)
309320
)
310321

311-
r = http.request("GET", f"https://msedgedriver.azureedge.net/LATEST_RELEASE_{major_version}_MACOS")
322+
r = http.request(
323+
"GET",
324+
f"https://msedgedriver.azureedge.net/LATEST_RELEASE_{major_version}_MACOS",
325+
)
312326
macos_version = r.data.decode("utf-16").strip()
313327
mac = "https://msedgedriver.azureedge.net/%s/edgedriver_mac64.zip" % macos_version
314328
sha = calculate_hash(mac)
@@ -340,7 +354,9 @@ def edgedriver():
340354
def geckodriver():
341355
content = ""
342356

343-
r = http.request("GET", "https://api.github.com/repos/mozilla/geckodriver/releases/latest")
357+
r = http.request(
358+
"GET", "https://api.github.com/repos/mozilla/geckodriver/releases/latest"
359+
)
344360
for a in json.loads(r.data)["assets"]:
345361
if a["name"].endswith("-linux64.tar.gz"):
346362
url = a["browser_download_url"]
@@ -411,21 +427,30 @@ def firefox():
411427

412428

413429
def firefox_version_data():
414-
versions = http.request("GET", "https://product-details.mozilla.org/1.0/firefox_versions.json")
430+
versions = http.request(
431+
"GET", "https://product-details.mozilla.org/1.0/firefox_versions.json"
432+
)
415433
return versions.data
416434

417435

418436
def firefox_linux(version):
419437
if int(version.split(".")[0]) < 135:
420-
return "https://ftp.mozilla.org/pub/firefox/releases/%s/linux-x86_64/en-US/firefox-%s.tar.bz2" % (
421-
version, version)
438+
return (
439+
"https://ftp.mozilla.org/pub/firefox/releases/%s/linux-x86_64/en-US/firefox-%s.tar.bz2"
440+
% (version, version)
441+
)
422442
else:
423-
return "https://ftp.mozilla.org/pub/firefox/releases/%s/linux-x86_64/en-US/firefox-%s.tar.xz" % (
424-
version, version)
443+
return (
444+
"https://ftp.mozilla.org/pub/firefox/releases/%s/linux-x86_64/en-US/firefox-%s.tar.xz"
445+
% (version, version)
446+
)
425447

426448

427449
def firefox_mac(version):
428-
return "https://ftp.mozilla.org/pub/firefox/releases/%s/mac/en-US/Firefox%%20%s.dmg" % (version, version)
450+
return (
451+
"https://ftp.mozilla.org/pub/firefox/releases/%s/mac/en-US/Firefox%%20%s.dmg"
452+
% (version, version)
453+
)
429454

430455

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

scripts/selenium_manager.py

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,52 +14,59 @@
1414

1515
def get_url():
1616
r = http.request(
17-
"GET", f"https://github.com/SeleniumHQ/selenium_manager_artifacts/releases/latest"
17+
"GET",
18+
"https://github.com/SeleniumHQ/selenium_manager_artifacts/releases/latest",
1819
)
1920
return r.url.replace("tag", "download")
2021

2122

2223
def get_sha_json():
23-
r = http.request("GET", f"https://raw.githubusercontent.com/SeleniumHQ/selenium_manager_artifacts/trunk/latest.json")
24+
r = http.request(
25+
"GET",
26+
"https://raw.githubusercontent.com/SeleniumHQ/selenium_manager_artifacts/trunk/latest.json",
27+
)
2428
return json.loads(r.data)
2529

2630

2731
def print_linux(base_url, sha):
28-
return (""" http_file(
32+
return """ http_file(
2933
name = "download_sm_linux",
3034
executable = True,
3135
sha256 = "%s",
3236
url = "%s",
3337
)
3438
35-
"""
36-
% (sha, base_url + "/selenium-manager-linux")
37-
)
39+
""" % (
40+
sha,
41+
base_url + "/selenium-manager-linux",
42+
)
3843

3944

4045
def print_macos(base_url, sha):
41-
return (""" http_file(
46+
return """ http_file(
4247
name = "download_sm_macos",
4348
executable = True,
4449
sha256 = "%s",
4550
url = "%s",
4651
)
4752
48-
"""
49-
% (sha, base_url + "/selenium-manager-macos")
50-
)
53+
""" % (
54+
sha,
55+
base_url + "/selenium-manager-macos",
56+
)
5157

5258

5359
def print_windows(base_url, sha):
54-
return (""" http_file(
60+
return """ http_file(
5561
name = "download_sm_windows",
5662
executable = True,
5763
sha256 = "%s",
5864
url = "%s",
5965
)
60-
"""
61-
% (sha, base_url + "/selenium-manager-windows.exe")
62-
)
66+
""" % (
67+
sha,
68+
base_url + "/selenium-manager-windows.exe",
69+
)
6370

6471

6572
if __name__ == "__main__":
@@ -71,9 +78,9 @@ def selenium_manager():
7178
"""
7279
base_url = get_url()
7380
sha_dict = get_sha_json()
74-
content = content + print_linux(base_url, sha_dict['linux'])
75-
content = content + print_macos(base_url, sha_dict['macos'])
76-
content = content + print_windows(base_url, sha_dict['windows'])
81+
content = content + print_linux(base_url, sha_dict["linux"])
82+
content = content + print_macos(base_url, sha_dict["macos"])
83+
content = content + print_windows(base_url, sha_dict["windows"])
7784
content += """
7885
def _selenium_manager_artifacts_impl(_ctx):
7986
selenium_manager()

0 commit comments

Comments
 (0)