Skip to content

Commit 6a662e4

Browse files
committed
Satisfy the linter
1 parent c25a11c commit 6a662e4

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

windows-release/merge-and-upload.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from pathlib import Path
99
from urllib.parse import urlparse
10-
from urllib.request import urlopen, Request
10+
from urllib.request import Request, urlopen
1111

1212
UPLOAD_URL_PREFIX = os.getenv("UPLOAD_URL_PREFIX", "https://www.python.org/ftp/")
1313
UPLOAD_PATH_PREFIX = os.getenv("UPLOAD_PATH_PREFIX", "/srv/www.python.org/ftp/")
@@ -22,6 +22,7 @@
2222
NO_UPLOAD = os.getenv("NO_UPLOAD", "no")[:1].lower() in "yt1"
2323
LOCAL_INDEX = os.getenv("LOCAL_INDEX", "no")[:1].lower() in "yt1"
2424

25+
2526
def find_cmd(env, exe):
2627
cmd = os.getenv(env)
2728
if cmd:
@@ -32,7 +33,9 @@ def find_cmd(env, exe):
3233
if cmd.is_file():
3334
return cmd
3435
if UPLOAD_HOST:
35-
raise RuntimeError(f"Could not find {exe} to perform upload. Try setting %{env}% or %PATH%")
36+
raise RuntimeError(
37+
f"Could not find {exe} to perform upload. Try setting %{env}% or %PATH%"
38+
)
3639
print(f"Did not find {exe}, but not uploading anyway.")
3740

3841
PLINK = find_cmd("PLINK", "plink.exe")
@@ -120,7 +123,7 @@ def url2path(url):
120123
if LOCAL_INDEX:
121124
return url
122125
raise ValueError(f"Unexpected URL: {url}")
123-
return UPLOAD_PATH_PREFIX + url[len(UPLOAD_URL_PREFIX):]
126+
return UPLOAD_PATH_PREFIX + url[len(UPLOAD_URL_PREFIX) :]
124127

125128

126129
def get_hashes(src):
@@ -134,8 +137,9 @@ def get_hashes(src):
134137

135138

136139
def trim_install(install):
137-
return {k: v for k, v in install.items()
138-
if k not in ("aliases", "run-for", "shortcuts")}
140+
return {
141+
k: v for k, v in install.items() if k not in ("aliases", "run-for", "shortcuts")
142+
}
139143

140144

141145
def validate_new_installs(installs):
@@ -157,10 +161,12 @@ def purge(url):
157161

158162
def calculate_uploads():
159163
cwd = Path.cwd()
160-
for p in sorted([
161-
*cwd.glob("__install__.*.json"),
162-
*[p / "__install__.json" for p in cwd.iterdir()],
163-
]):
164+
for p in sorted(
165+
[
166+
*cwd.glob("__install__.*.json"),
167+
*[p / "__install__.json" for p in cwd.iterdir()],
168+
]
169+
):
164170
if not p.is_file():
165171
continue
166172
print("Processing", p)
@@ -228,7 +234,7 @@ def install_sortkey(install):
228234
raise
229235
else:
230236
try:
231-
with open(INDEX_FILE, "r", encoding="utf-8") as f:
237+
with open(INDEX_FILE, encoding="utf-8") as f:
232238
index = json.load(f)
233239
except FileNotFoundError:
234240
pass
@@ -250,8 +256,9 @@ def install_sortkey(install):
250256
if MANIFEST_FILE:
251257
# Use the sort-version so that the manifest name includes prerelease marks
252258
MANIFEST_FILE = Path(MANIFEST_FILE).absolute()
253-
MANIFEST_FILE = MANIFEST_FILE.with_name(f"{MANIFEST_FILE.stem}-{new_installs[0]['sort-version']}.json")
254-
MANIFEST_URL = new_installs[0]["url"].rpartition("/")[0] + f"/{MANIFEST_FILE.name}"
259+
name = f"{MANIFEST_FILE.stem}-{new_installs[0]['sort-version']}.json"
260+
MANIFEST_FILE = MANIFEST_FILE.with_name(name)
261+
MANIFEST_URL = new_installs[0]["url"].rpartition("/")[0] + "/" + name
255262
MANIFEST_PATH = url2path(MANIFEST_URL)
256263

257264
with open(MANIFEST_FILE, "w", encoding="utf-8") as f:

0 commit comments

Comments
 (0)