Skip to content

Commit 9677ecd

Browse files
committed
fix: revert style changes to fetch-content
It turns out there are still some tasks in Gecko that need to run `fetch-content` against Python 3.8. Until we can get those tasks onto a newer version, let's keep fetch-content 3.8 compatible for now.
1 parent 234e8e4 commit 9677ecd

File tree

2 files changed

+18
-25
lines changed

2 files changed

+18
-25
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@ repos:
4141
hooks:
4242
- id: conventional-pre-commit
4343
stages: [commit-msg]
44+
# TODO remove 'fetch-content' once Gecko no longer needs to use it with Python 3.8
45+
# https://bugzilla.mozilla.org/show_bug.cgi?id=1990567#c7
4446
exclude: |
4547
(?x)^(
48+
src/taskgraph/run-task/fetch-content |
4649
src/taskgraph/run-task/robustcheckout.py |
4750
taskcluster/scripts/external_tools
4851
)

src/taskgraph/run-task/fetch-content

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -413,12 +413,9 @@ def extract_archive(path, dest_dir):
413413
raise ValueError(f"unknown archive format: {path}")
414414

415415
if args:
416-
with (
417-
ifh,
418-
subprocess.Popen(
419-
args, cwd=str(dest_dir), bufsize=0, stdin=subprocess.PIPE
420-
) as p,
421-
):
416+
with ifh, subprocess.Popen(
417+
args, cwd=str(dest_dir), bufsize=0, stdin=subprocess.PIPE
418+
) as p:
422419
while True:
423420
if not pipe_stdin:
424421
break
@@ -530,13 +527,10 @@ def repack_archive(
530527
with rename_after_close(dest, "wb") as fh:
531528
ctx = ZstdCompressor()
532529
if orig_typ in ("exec", None):
533-
with (
534-
ctx.stream_writer(fh) as compressor,
535-
tarfile.open(
536-
fileobj=compressor,
537-
mode="w:",
538-
) as tar,
539-
):
530+
with ctx.stream_writer(fh) as compressor, tarfile.open(
531+
fileobj=compressor,
532+
mode="w:",
533+
) as tar:
540534
tarinfo = tarfile.TarInfo()
541535
tarinfo.name = filter(orig.name) if filter else orig.name
542536
st = orig.stat()
@@ -549,10 +543,9 @@ def repack_archive(
549543
assert typ == "tar"
550544
zip = zipfile.ZipFile(ifh)
551545
# Convert the zip stream to a tar on the fly.
552-
with (
553-
ctx.stream_writer(fh) as compressor,
554-
tarfile.open(fileobj=compressor, mode="w:") as tar,
555-
):
546+
with ctx.stream_writer(fh) as compressor, tarfile.open(
547+
fileobj=compressor, mode="w:"
548+
) as tar:
556549
for zipinfo in zip.infolist():
557550
if zipinfo.is_dir():
558551
continue
@@ -594,14 +587,11 @@ def repack_archive(
594587
# To apply the filter, we need to open the tar stream and
595588
# tweak it.
596589
origtar = tarfile.open(fileobj=ifh, mode="r|")
597-
with (
598-
ctx.stream_writer(fh) as compressor,
599-
tarfile.open(
600-
fileobj=compressor,
601-
mode="w:",
602-
format=origtar.format,
603-
) as tar,
604-
):
590+
with ctx.stream_writer(fh) as compressor, tarfile.open(
591+
fileobj=compressor,
592+
mode="w:",
593+
format=origtar.format,
594+
) as tar:
605595
for tarinfo in origtar:
606596
if tarinfo.isdir():
607597
continue

0 commit comments

Comments
 (0)