static_checks: Use type annotations

Change-Id: I8afb26ea4e6692526bd94a44f08f6fe7a90bf477
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/181750
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>
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Reviewed-by: Ted Pudlik <tpudlik@google.com>
diff --git a/recipes/static_checks.py b/recipes/static_checks.py
index dc28638..1eb910f 100644
--- a/recipes/static_checks.py
+++ b/recipes/static_checks.py
@@ -15,9 +15,11 @@
 
 import functools
 import re
+from typing import Any, Sequence
 
 from PB.recipes.pigweed.static_checks import InputProperties
-from recipe_engine import post_process
+from recipe_engine import post_process, recipe_api
+from RECIPE_MODULES.pigweed.util import api as util_api
 
 DEPS = [
     'fuchsia/gerrit',
@@ -45,7 +47,13 @@
 
 
 @nest_step
-def _check_docs(api, details, commit_message, comments, doc_file_extensions=()):
+def _check_docs(
+    api: recipe_api.RecipeScriptApi,
+    details: dict[str, Any],
+    commit_message: str,
+    comments: Sequence[str],
+    doc_file_extensions: Sequence[str]=(),
+) -> None:
     """Check that docs are included in the CL.
 
     If doc_file_extensions is set make sure at least one document change is in
@@ -63,7 +71,7 @@
             '"Reply" in the Gerrit UI).'
         )
 
-    match = api.util.find_matching_comment(
+    match: re.Match = api.util.find_matching_comment(
         re.compile(r'No-Docs-Update-Reason: \w.*'), comments,
     )
     if match:
@@ -71,8 +79,10 @@
             return
 
     with api.step.nest('checking changed files') as pres:
-        current_revision = details['revisions'][details['current_revision']]
-        files = tuple(current_revision.get('files', ()))
+        current_revision: str = (
+            details['revisions'][details['current_revision']]
+        )
+        files: tuple[str] = tuple(current_revision.get('files', ()))
         pres.step_summary_text = '\n'.join(files)
         for path in files:
             if path.endswith(tuple(str(x) for x in doc_file_extensions)):
@@ -87,7 +97,7 @@
             with api.step.nest('no non-OWNERS files'):
                 return
 
-    error = (
+    error: str = (
         'No *.rst or *.md changes in CL and no exception applies. Add docs '
         "or explain why they're not needed in a Gerrit comment with "
         '"No-Docs-Update-Reason: <reason>".'
@@ -102,16 +112,22 @@
 
 
 @nest_step
-def _check_requires(api, change, details, dry_run=False, allow_requires=False):
+def _check_requires(
+    api: recipe_api.RecipeScriptApi,
+    change: util_api.ChangeWithComments,
+    details: dict[str, Any],
+    dry_run: bool = False,
+    allow_requires: bool = False,
+) -> None:
     """Check the format of "Requires:" lines and warn for common mistakes."""
-    warnings = []
+    warnings: list[str] = []
 
-    def _warn(warning):
+    def _warn(warning: str) -> None:
         with api.step.nest('warning') as pres:
             pres.step_summary_text = warning
         warnings.append(warning)
 
-    has_requires_line = False
+    has_requires_line: bool = False
     for line in details['message'].split('\n'):
         if line.startswith('Requires:'):
             has_requires_line = True
@@ -123,7 +139,7 @@
             'the new dependent CL process.'.format(line)
         )
 
-    all_warnings = '\n\n'.join(warnings)
+    all_warnings: str = '\n\n'.join(warnings)
 
     if warnings and not dry_run:
         api.gerrit.set_review(
@@ -140,7 +156,13 @@
 
 
 @nest_step
-def _check_regexp(api, change, details, regexp, failure_message):
+def _check_regexp(
+    api: recipe_api.RecipeScriptApi,
+    change: util_api.ChangeWithComments,
+    details: dict[str, Any],
+    regexp: re.Pattern | str,
+    failure_message: str
+) -> None:
     if re.match(regexp, details['message']):
         with api.step.nest('matches') as pres:
             pres.step_summary_text = regexp