diff --git a/src/taskgraph/generator.py b/src/taskgraph/generator.py index 36491bba7..901f03171 100644 --- a/src/taskgraph/generator.py +++ b/src/taskgraph/generator.py @@ -374,7 +374,7 @@ def _run(self): if parameters["enable_always_target"]: always_target_tasks = { t.label - for t in full_task_graph.tasks.values() # type: ignore + for t in full_task_graph.tasks.values() if t.attributes.get("always_target") if parameters["enable_always_target"] is True or t.kind in parameters["enable_always_target"] @@ -388,7 +388,7 @@ def _run(self): target_graph = full_task_graph.graph.transitive_closure(requested_tasks) target_task_graph = TaskGraph( {l: all_tasks[l] for l in target_graph.nodes}, - target_graph, # type: ignore + target_graph, ) yield self.verify( "target_task_graph", target_task_graph, graph_config, parameters diff --git a/src/taskgraph/taskgraph.py b/src/taskgraph/taskgraph.py index 11ba2f698..10466d849 100644 --- a/src/taskgraph/taskgraph.py +++ b/src/taskgraph/taskgraph.py @@ -41,7 +41,7 @@ def __contains__(self, label): def __iter__(self): "Iterate over tasks in undefined order" - return iter(self.tasks.values()) # type: ignore + return iter(self.tasks.values()) def to_json(self): "Return a JSON-able object representing the task graph, as documented" diff --git a/src/taskgraph/util/cached_tasks.py b/src/taskgraph/util/cached_tasks.py index 2f94bc3f9..e24afc179 100644 --- a/src/taskgraph/util/cached_tasks.py +++ b/src/taskgraph/util/cached_tasks.py @@ -37,8 +37,8 @@ def add_optimization( """ if (digest is None) == (digest_data is None): raise Exception("Must pass exactly one of `digest` and `digest_data`.") - if digest is None: - digest = hashlib.sha256("\n".join(digest_data).encode("utf-8")).hexdigest() # type: ignore + elif digest is None and digest_data is not None: + digest = hashlib.sha256("\n".join(digest_data).encode("utf-8")).hexdigest() if "cached-task-prefix" in config.graph_config["taskgraph"]: cache_prefix = config.graph_config["taskgraph"]["cached-task-prefix"] diff --git a/src/taskgraph/util/schema.py b/src/taskgraph/util/schema.py index ba72ff079..3c5f4c955 100644 --- a/src/taskgraph/util/schema.py +++ b/src/taskgraph/util/schema.py @@ -3,9 +3,9 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. -import collections import pprint import re +from collections.abc import Mapping import voluptuous @@ -184,7 +184,7 @@ def check_identifier(path, k): f"Unexpected type in YAML schema: {type(k).__name__} @ {path}" ) - if isinstance(sch, collections.abc.Mapping): # type: ignore + if isinstance(sch, Mapping): for k, v in sch.items(): child = f"{path}[{k!r}]" check_identifier(child, k) diff --git a/src/taskgraph/util/taskcluster.py b/src/taskgraph/util/taskcluster.py index fe275662f..9d545360b 100644 --- a/src/taskgraph/util/taskcluster.py +++ b/src/taskgraph/util/taskcluster.py @@ -197,7 +197,7 @@ def find_task_id(index_path, use_proxy=False): try: response = _do_request(get_index_url(index_path, use_proxy)) except requests.exceptions.HTTPError as e: - if e.response.status_code == 404: # type: ignore + if e.response.status_code == 404: raise KeyError(f"index path {index_path} not found") raise return response.json()["taskId"] @@ -306,7 +306,7 @@ def cancel_task(task_id, use_proxy=False): def status_task(task_id, use_proxy=False): """Gets the status of a task given a task_id. - In testing mode, just logs that it would have retrieved status. + In testing mode, just logs that it would have retrieved status and return an empty dict. Args: task_id (str): A task id. @@ -318,6 +318,7 @@ def status_task(task_id, use_proxy=False): """ if testing: logger.info(f"Would have gotten status for {task_id}.") + return {} else: resp = _do_request(get_task_url(task_id, use_proxy) + "/status") status = resp.json().get("status", {}) @@ -385,7 +386,7 @@ def state_task(task_id, use_proxy=False): if testing: logger.info(f"Would have gotten state for {task_id}.") else: - status = status_task(task_id, use_proxy=use_proxy).get("state") or "unknown" # type: ignore + status = status_task(task_id, use_proxy=use_proxy).get("state") or "unknown" return status