cq_deps: Add/update annotations
Change-Id: I675918fb35930029949f4bc77ef993fbaf1398b9
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/195094
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Reviewed-by: Ted Pudlik <tpudlik@google.com>
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed-service-accounts.iam.gserviceaccount.com>
diff --git a/recipe_modules/cq_deps/api.py b/recipe_modules/cq_deps/api.py
index 9582af1..9cd25dd 100644
--- a/recipe_modules/cq_deps/api.py
+++ b/recipe_modules/cq_deps/api.py
@@ -16,7 +16,7 @@
import base64
import json
import re
-from typing import Any, Literal, Optional, Sequence
+from typing import Any, Generator, Literal, Sequence
import attrs
from PB.recipe_modules.pigweed.cq_deps.properties import InputProperties
@@ -36,10 +36,10 @@
gerrit_name: str
change: int = attrs.field(converter=int)
- project: Optional[str] = None
- patchset: Optional[str] = None
- status: Optional[str] = None
- commit: Optional[str] = None
+ project: str | None = None
+ patchset: str | None = None
+ status: str | None = None
+ commit: str | None = None
@property
def host(self) -> str:
@@ -82,7 +82,7 @@
def _lookup_cl(
self, gerrit_name: str, commit: str
- ) -> Optional[list[dict[str, Any]]]:
+ ) -> list[dict[str, Any]] | None:
query_results = self.m.gerrit.change_query(
f'number {commit}',
f'commit:{commit}',
@@ -176,7 +176,7 @@
return deps.values(), unresolved
- def _parse_deps(self, change: Change) -> Sequence[Change]:
+ def _parse_deps(self, change: Change) -> Generator[Change, None, None]:
"""Parse dependencies from patches.json in a change.
For a change with the following patches.json file,
@@ -237,7 +237,7 @@
for dep in deps:
yield Change(dep['gerrit_name'], dep['number'])
- def _resolve(self, change):
+ def _resolve(self, change: Change) -> list[Change]:
"""Resolve dependencies of the given change.
Retrieve and parse the patches.json file of the given change. Does not