bazel: Add type annotations

Change-Id: I30e08f7ec5e511ffc965a566e6ed2c86b5df4a04
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/181730
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Reviewed-by: Ted Pudlik <tpudlik@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed-service-accounts.iam.gserviceaccount.com>
diff --git a/recipe_modules/bazel/api.py b/recipe_modules/bazel/api.py
index 10617f0..4f21521 100644
--- a/recipe_modules/bazel/api.py
+++ b/recipe_modules/bazel/api.py
@@ -58,11 +58,11 @@
             return self.bazel
 
         # read_json in a few lines requires absolute, normalized paths.
-        json_path = self.api.path.abspath(
+        json_path: config_types.Path = self.api.path.abspath(
             self.checkout_root / self.options.cipd_json_path
         )
 
-        ensure_file = self.api.cipd.EnsureFile()
+        ensure_file: self.api.cipd.EnsureFile = self.api.cipd.EnsureFile()
         for package in self.api.file.read_json(
             f'read {self.api.path.basename(json_path)}',
             json_path,
@@ -70,23 +70,25 @@
         )["packages"]:
             ensure_file.add_package(package['path'], package['tags'][0])
 
-        root = self.api.path.mkdtemp()
+        root: config_types.Path = self.api.path.mkdtemp()
         self.api.cipd.ensure(root, ensure_file, name='ensure bazel')
         self.bazel = root / 'bazel'
         return self.bazel
 
-    def run(self, **kwargs):
-        name = ' '.join(['bazel'] + list(self.options.args))
+    def run(self, **kwargs) -> None:
+        name: str = ' '.join(['bazel'] + list(self.options.args))
         with self.api.context(cwd=self.checkout_root):
             self.api.step(name, [self.ensure(), *self.options.args], **kwargs)
 
             for invocation in self.options.invocations:
-                name = ' '.join(['bazel'] + list(invocation.args))
+                name: str = ' '.join(['bazel'] + list(invocation.args))
                 self.api.step(name, [self.ensure(), *invocation.args], **kwargs)
 
 
 class BazelApi(recipe_api.RecipeApi):
     """Bazel utilities."""
 
+    BazelRunner = BazelRunner
+
     def new_runner(self, checkout: Any, options: Options) -> BazelRunner:
         return BazelRunner(self.m, checkout.root, options)
diff --git a/recipes/bazel.py b/recipes/bazel.py
index 4fd07fe..69188c7 100644
--- a/recipes/bazel.py
+++ b/recipes/bazel.py
@@ -16,6 +16,7 @@
 import re
 
 from PB.recipes.pigweed.bazel import InputProperties
+from recipe_engine import recipe_api
 
 DEPS = [
     'pigweed/bazel',
@@ -27,10 +28,14 @@
 PROPERTIES = InputProperties
 
 
-def RunSteps(api, props):
-    checkout = api.checkout(props.checkout_options)
-    env = api.environment.init(checkout)
-    runner = api.bazel.new_runner(checkout, props.bazel_options)
+def RunSteps(api: recipe_api.RecipeScriptApi, props: InputProperties):
+    checkout: api.checkout.CheckoutContext = api.checkout(
+        props.checkout_options
+    )
+    env: api.environment.Environment = api.environment.init(checkout)
+    runner: api.bazel.BazelRunner = api.bazel.new_runner(
+        checkout, props.bazel_options
+    )
     with env():
         runner.run()