Skip to content

Commit 8c8488d

Browse files
committed
style: fix lint issues resulting from dropping py38
1 parent d143cbf commit 8c8488d

25 files changed

+107
-99
lines changed

src/taskgraph/actions/registry.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ def is_json(data):
3030
return True
3131

3232

33-
@functools.lru_cache(maxsize=None)
33+
@functools.cache
3434
def read_taskcluster_yml(filename):
3535
"""Load and parse .taskcluster.yml, cached to save some time"""
3636
return yaml.load_yaml(filename)
3737

3838

39-
@functools.lru_cache(maxsize=None)
39+
@functools.cache
4040
def hash_taskcluster_yml(filename):
4141
"""
4242
Generate a hash of the given .taskcluster.yml. This is the first 10 digits

src/taskgraph/config.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import sys
99
from dataclasses import dataclass
1010
from pathlib import Path
11-
from typing import Dict
1211

1312
from voluptuous import ALLOW_EXTRA, All, Any, Extra, Length, Optional, Required
1413

@@ -113,7 +112,7 @@
113112

114113
@dataclass(frozen=True, eq=False)
115114
class GraphConfig:
116-
_config: Dict
115+
_config: dict
117116
root_dir: str
118117

119118
_PATH_MODIFIED = False

src/taskgraph/docker.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
import sys
1212
import tarfile
1313
import tempfile
14+
from collections.abc import Generator
1415
from io import BytesIO
1516
from pathlib import Path
1617
from textwrap import dedent
17-
from typing import Any, Dict, Generator, List, Optional, Union
18+
from typing import Any, Optional, Union
1819

1920
from taskcluster.exceptions import TaskclusterRestFailure
2021

@@ -246,7 +247,7 @@ def build_image(
246247

247248
def load_image(
248249
url: str, imageName: Optional[str] = None, imageTag: Optional[str] = None
249-
) -> Dict[str, str]:
250+
) -> dict[str, str]:
250251
"""Load docker image from URL as imageName:tag.
251252
252253
Downloads a zstd-compressed docker image tarball from the given URL and
@@ -286,7 +287,7 @@ def load_image(
286287
else:
287288
imageTag = "latest"
288289

289-
info: Dict[str, str] = {}
290+
info: dict[str, str] = {}
290291

291292
def download_and_modify_image() -> Generator[bytes, None, None]:
292293
# This function downloads and edits the downloaded tar file on the fly.
@@ -377,14 +378,14 @@ def download_and_modify_image() -> Generator[bytes, None, None]:
377378
return info
378379

379380

380-
def _index(l: List, s: str) -> Optional[int]:
381+
def _index(l: list, s: str) -> Optional[int]:
381382
try:
382383
return l.index(s)
383384
except ValueError:
384385
pass
385386

386387

387-
def _resolve_image(image: Union[str, Dict[str, str]], graph_config: GraphConfig) -> str:
388+
def _resolve_image(image: Union[str, dict[str, str]], graph_config: GraphConfig) -> str:
388389
image_task_id = None
389390

390391
# Standard case, image comes from the task definition.
@@ -419,12 +420,12 @@ def _resolve_image(image: Union[str, Dict[str, str]], graph_config: GraphConfig)
419420

420421
def load_task(
421422
graph_config: GraphConfig,
422-
task: Union[str, Dict[str, Any]],
423+
task: Union[str, dict[str, Any]],
423424
remove: bool = True,
424425
user: Optional[str] = None,
425426
custom_image: Optional[str] = None,
426427
interactive: Optional[bool] = False,
427-
volumes: Optional[Dict[str, str]] = None,
428+
volumes: Optional[dict[str, str]] = None,
428429
) -> int:
429430
"""Load and run a task interactively in a Docker container.
430431

src/taskgraph/generator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
wait,
1515
)
1616
from dataclasses import dataclass
17-
from typing import Callable, Dict, Optional, Union
17+
from typing import Callable, Optional, Union
1818

1919
from . import filter_tasks
2020
from .config import GraphConfig, load_graph_config
@@ -42,7 +42,7 @@ class KindNotFound(Exception):
4242
class Kind:
4343
name: str
4444
path: str
45-
config: Dict
45+
config: dict
4646
graph_config: GraphConfig
4747

4848
def _get_loader(self) -> Callable:

src/taskgraph/graph.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import collections
77
from dataclasses import dataclass
8-
from typing import FrozenSet
98

109

1110
@dataclass(frozen=True)
@@ -24,8 +23,8 @@ class Graph:
2423
node `left` to node `right`..
2524
"""
2625

27-
nodes: FrozenSet
28-
edges: FrozenSet
26+
nodes: frozenset
27+
edges: frozenset
2928

3029
def transitive_closure(self, nodes, reverse=False):
3130
"""Return the transitive closure of <nodes>: the graph containing all

src/taskgraph/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from concurrent.futures import ProcessPoolExecutor, as_completed
1717
from pathlib import Path
1818
from textwrap import dedent
19-
from typing import Any, List
19+
from typing import Any
2020
from urllib.parse import urlparse
2121

2222
import appdirs
@@ -412,7 +412,7 @@ def show_taskgraph(options):
412412
overrides = {
413413
"target-kinds": options.get("target_kinds"),
414414
}
415-
parameters: List[Any[str, Parameters]] = options.pop("parameters")
415+
parameters: list[Any[str, Parameters]] = options.pop("parameters")
416416
if not parameters:
417417
parameters = [
418418
parameters_loader(None, strict=False, overrides=overrides)

src/taskgraph/optimize/base.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import logging
1616
from abc import ABCMeta, abstractmethod
1717
from collections import defaultdict
18-
from typing import Dict, Set
1918

2019
from slugid import nice as slugid
2120

@@ -367,9 +366,9 @@ def replace_tasks(
367366

368367
def get_subgraph(
369368
target_task_graph: TaskGraph,
370-
removed_tasks: Set[str],
371-
replaced_tasks: Set[str],
372-
label_to_taskid: Dict[str, str],
369+
removed_tasks: set[str],
370+
replaced_tasks: set[str],
371+
label_to_taskid: dict[str, str],
373372
decision_task_id: str,
374373
):
375374
"""

src/taskgraph/run-task/fetch-content

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

415415
if args:
416-
with ifh, subprocess.Popen(
417-
args, cwd=str(dest_dir), bufsize=0, stdin=subprocess.PIPE
418-
) as p:
416+
with (
417+
ifh,
418+
subprocess.Popen(
419+
args, cwd=str(dest_dir), bufsize=0, stdin=subprocess.PIPE
420+
) as p,
421+
):
419422
while True:
420423
if not pipe_stdin:
421424
break
@@ -527,10 +530,13 @@ def repack_archive(
527530
with rename_after_close(dest, "wb") as fh:
528531
ctx = ZstdCompressor()
529532
if orig_typ in ("exec", None):
530-
with ctx.stream_writer(fh) as compressor, tarfile.open(
531-
fileobj=compressor,
532-
mode="w:",
533-
) as tar:
533+
with (
534+
ctx.stream_writer(fh) as compressor,
535+
tarfile.open(
536+
fileobj=compressor,
537+
mode="w:",
538+
) as tar,
539+
):
534540
tarinfo = tarfile.TarInfo()
535541
tarinfo.name = filter(orig.name) if filter else orig.name
536542
st = orig.stat()
@@ -543,9 +549,10 @@ def repack_archive(
543549
assert typ == "tar"
544550
zip = zipfile.ZipFile(ifh)
545551
# Convert the zip stream to a tar on the fly.
546-
with ctx.stream_writer(fh) as compressor, tarfile.open(
547-
fileobj=compressor, mode="w:"
548-
) as tar:
552+
with (
553+
ctx.stream_writer(fh) as compressor,
554+
tarfile.open(fileobj=compressor, mode="w:") as tar,
555+
):
549556
for zipinfo in zip.infolist():
550557
if zipinfo.is_dir():
551558
continue
@@ -587,11 +594,14 @@ def repack_archive(
587594
# To apply the filter, we need to open the tar stream and
588595
# tweak it.
589596
origtar = tarfile.open(fileobj=ifh, mode="r|")
590-
with ctx.stream_writer(fh) as compressor, tarfile.open(
591-
fileobj=compressor,
592-
mode="w:",
593-
format=origtar.format,
594-
) as tar:
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+
):
595605
for tarinfo in origtar:
596606
if tarinfo.isdir():
597607
continue

src/taskgraph/task.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

55
from dataclasses import dataclass, field
6-
from typing import Any, Dict, List, Union
6+
from typing import Any, Union
77

88

99
@dataclass
@@ -33,14 +33,14 @@ class Task:
3333

3434
kind: str
3535
label: str
36-
attributes: Dict
37-
task: Dict
36+
attributes: dict
37+
task: dict
3838
description: str = ""
3939
task_id: Union[str, None] = field(default=None, init=False)
40-
optimization: Union[Dict[str, Any], None] = field(default=None)
41-
dependencies: Dict = field(default_factory=dict)
42-
soft_dependencies: List = field(default_factory=list)
43-
if_dependencies: List = field(default_factory=list)
40+
optimization: Union[dict[str, Any], None] = field(default=None)
41+
dependencies: dict = field(default_factory=dict)
42+
soft_dependencies: list = field(default_factory=list)
43+
if_dependencies: list = field(default_factory=list)
4444

4545
def __post_init__(self):
4646
self.attributes["kind"] = self.kind

src/taskgraph/taskgraph.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

55
from dataclasses import dataclass
6-
from typing import Dict
76

87
from .graph import Graph
98
from .task import Task
@@ -21,7 +20,7 @@ class TaskGraph:
2120
tasks are "linked from" their dependents.
2221
"""
2322

24-
tasks: Dict[str, Task]
23+
tasks: dict[str, Task]
2524
graph: Graph
2625

2726
def __post_init__(self):

0 commit comments

Comments
 (0)