*: Conditionally import annotations
Conditionally import annotations in most cases. In some cases this
doesn't actually affect anything, like with a subsequent import from the
typing module, but it still leaves an obvious place to put future
annotation-only imports.
Change-Id: I6b678e2923729affa37c06f3dceba9397e25f5ec
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/229321
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed-service-accounts.iam.gserviceaccount.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
diff --git a/recipe_modules/bazel/api.py b/recipe_modules/bazel/api.py
index ace6fda..f3faf9e 100644
--- a/recipe_modules/bazel/api.py
+++ b/recipe_modules/bazel/api.py
@@ -18,12 +18,13 @@
import dataclasses
import shlex
import re
-from typing import Any, Sequence, TYPE_CHECKING
+from typing import TYPE_CHECKING
from PB.recipe_modules.pigweed.bazel.options import Options
from recipe_engine import recipe_api
if TYPE_CHECKING: # pragma: no cover
+ from typing import Any, Sequence
from recipe_engine import config_types
from RECIPE_MODULES.pigweed.checkout import api as checkout_api
diff --git a/recipe_modules/bazel/tests/full.py b/recipe_modules/bazel/tests/full.py
index b226f1d..e784b83 100644
--- a/recipe_modules/bazel/tests/full.py
+++ b/recipe_modules/bazel/tests/full.py
@@ -17,12 +17,13 @@
import dataclasses
import re
-from typing import Generator, TYPE_CHECKING
+from typing import TYPE_CHECKING
from PB.recipe_modules.pigweed.bazel.tests.full import InputProperties
from recipe_engine import post_process
if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
from recipe_engine import config_types, recipe_test_api
DEPS = [
diff --git a/recipe_modules/bazel/tests/retrieve_git_repository_attributes.py b/recipe_modules/bazel/tests/retrieve_git_repository_attributes.py
index 004407a..fdc71b7 100644
--- a/recipe_modules/bazel/tests/retrieve_git_repository_attributes.py
+++ b/recipe_modules/bazel/tests/retrieve_git_repository_attributes.py
@@ -16,7 +16,7 @@
from __future__ import annotations
import dataclasses
-from typing import Generator, TYPE_CHECKING
+from typing import TYPE_CHECKING
from PB.recipe_modules.pigweed.bazel.tests.update_commit_hash import (
UpdateCommitHashProperties,
@@ -25,6 +25,7 @@
from recipe_engine import post_process
if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
from recipe_engine import config_types, recipe_test_api
DEPS = [
diff --git a/recipe_modules/bazel/tests/update_commit_hash.py b/recipe_modules/bazel/tests/update_commit_hash.py
index 715ddb1..80ec58b 100644
--- a/recipe_modules/bazel/tests/update_commit_hash.py
+++ b/recipe_modules/bazel/tests/update_commit_hash.py
@@ -16,7 +16,7 @@
from __future__ import annotations
import dataclasses
-from typing import Generator, TYPE_CHECKING
+from typing import TYPE_CHECKING
from PB.recipe_modules.pigweed.bazel.tests.update_commit_hash import (
UpdateCommitHashProperties,
@@ -25,6 +25,7 @@
from recipe_engine import post_process
if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
from recipe_engine import config_types, recipe_test_api
DEPS = [
diff --git a/recipe_modules/build/tests/full.py b/recipe_modules/build/tests/full.py
index 1f71e42..d0dd4ea 100644
--- a/recipe_modules/build/tests/full.py
+++ b/recipe_modules/build/tests/full.py
@@ -15,10 +15,13 @@
from __future__ import annotations
-from typing import Generator
+from typing import TYPE_CHECKING
from PB.recipe_modules.pigweed.build.tests.full import InputProperties
-from recipe_engine import recipe_test_api
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_test_api
DEPS = [
'pigweed/build',
diff --git a/recipe_modules/checkout/api.py b/recipe_modules/checkout/api.py
index 2d57cf3..5a45f01 100644
--- a/recipe_modules/checkout/api.py
+++ b/recipe_modules/checkout/api.py
@@ -22,7 +22,7 @@
import collections
import contextlib
import re
-from typing import Any, Sequence, TYPE_CHECKING
+from typing import TYPE_CHECKING
import urllib
import xml.etree.ElementTree
@@ -38,6 +38,7 @@
from recipe_engine import recipe_api
if TYPE_CHECKING: # pragma: no cover
+ from typing import Any, Sequence
from recipe_engine import config_types
PIGWEED_REMOTE = 'https://pigweed.googlesource.com/pigweed/pigweed'
diff --git a/recipe_modules/checkout/tests/git.py b/recipe_modules/checkout/tests/git.py
index fe38ddd..c54de47 100644
--- a/recipe_modules/checkout/tests/git.py
+++ b/recipe_modules/checkout/tests/git.py
@@ -15,13 +15,16 @@
from __future__ import annotations
-from typing import Generator
+from typing import TYPE_CHECKING
from PB.go.chromium.org.luci.scheduler.api.scheduler.v1 import (
triggers as triggers_pb2,
)
from PB.recipe_modules.pigweed.checkout.tests.properties import InputProperties
-from recipe_engine import recipe_test_api
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_test_api
DEPS = [
'pigweed/checkout',
diff --git a/recipe_modules/checkout/tests/repo.py b/recipe_modules/checkout/tests/repo.py
index 5f6ae50..53e29a5 100644
--- a/recipe_modules/checkout/tests/repo.py
+++ b/recipe_modules/checkout/tests/repo.py
@@ -15,10 +15,14 @@
from __future__ import annotations
-from typing import Generator
+from typing import TYPE_CHECKING
from PB.recipe_modules.pigweed.checkout.tests.properties import InputProperties
-from recipe_engine import post_process, recipe_test_api
+from recipe_engine import post_process
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_test_api
DEPS = [
'pigweed/checkout',
diff --git a/recipe_modules/checkout/tests/submodule.py b/recipe_modules/checkout/tests/submodule.py
index 16ab598..79c5621 100644
--- a/recipe_modules/checkout/tests/submodule.py
+++ b/recipe_modules/checkout/tests/submodule.py
@@ -15,10 +15,13 @@
from __future__ import annotations
-from typing import Generator
+from typing import TYPE_CHECKING
from PB.recipe_modules.pigweed.checkout.tests.properties import InputProperties
-from recipe_engine import recipe_test_api
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_test_api
DEPS = [
'pigweed/checkout',
diff --git a/recipe_modules/checkout/tests/workspace.py b/recipe_modules/checkout/tests/workspace.py
index 181e3dd..8d4615c 100644
--- a/recipe_modules/checkout/tests/workspace.py
+++ b/recipe_modules/checkout/tests/workspace.py
@@ -15,13 +15,13 @@
from __future__ import annotations
-from typing import Generator
+from typing import TYPE_CHECKING
-from PB.go.chromium.org.luci.scheduler.api.scheduler.v1 import (
- triggers as triggers_pb2,
-)
from PB.recipe_modules.pigweed.checkout.tests.properties import InputProperties
-from recipe_engine import recipe_test_api
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_test_api
DEPS = [
'pigweed/checkout',
diff --git a/recipe_modules/ci_status/api.py b/recipe_modules/ci_status/api.py
index 46a409f..ee0808a 100644
--- a/recipe_modules/ci_status/api.py
+++ b/recipe_modules/ci_status/api.py
@@ -16,12 +16,15 @@
from __future__ import annotations
import re
-from typing import Sequence
+from typing import TYPE_CHECKING
from recipe_engine import recipe_api
from PB.go.chromium.org.luci.buildbucket.proto import common
from PB.recipe_engine import result
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Sequence
+
class CiStatusApi(recipe_api.RecipeApi):
"""Calls to build code."""
diff --git a/recipe_modules/ci_status/tests/exit_early_in_recipe_testing_if_failing.py b/recipe_modules/ci_status/tests/exit_early_in_recipe_testing_if_failing.py
index 77d31e8..64d5813 100644
--- a/recipe_modules/ci_status/tests/exit_early_in_recipe_testing_if_failing.py
+++ b/recipe_modules/ci_status/tests/exit_early_in_recipe_testing_if_failing.py
@@ -15,9 +15,13 @@
from __future__ import annotations
-from typing import Generator
+from typing import TYPE_CHECKING
-from recipe_engine import post_process, recipe_test_api
+from recipe_engine import post_process
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_test_api
DEPS = [
'fuchsia/builder_status',
diff --git a/recipe_modules/ci_status/tests/transform_bucket_name.py b/recipe_modules/ci_status/tests/transform_bucket_name.py
index fcff274..240b808 100644
--- a/recipe_modules/ci_status/tests/transform_bucket_name.py
+++ b/recipe_modules/ci_status/tests/transform_bucket_name.py
@@ -15,12 +15,16 @@
from __future__ import annotations
-from typing import Generator
+from typing import TYPE_CHECKING
from PB.recipe_modules.pigweed.ci_status.tests.transform_bucket_name import (
InputProperties,
)
-from recipe_engine import post_process, recipe_test_api
+from recipe_engine import post_process
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_test_api
DEPS = [
'pigweed/ci_status',
diff --git a/recipe_modules/cipd_roll/api.py b/recipe_modules/cipd_roll/api.py
index 7c49f44..1a76314 100644
--- a/recipe_modules/cipd_roll/api.py
+++ b/recipe_modules/cipd_roll/api.py
@@ -19,7 +19,7 @@
import dataclasses
import json
import re
-from typing import Sequence, TYPE_CHECKING
+from typing import TYPE_CHECKING
from PB.recipe_modules.fuchsia.cipd_util.upload_manifest import (
CIPDUploadManifest,
@@ -28,6 +28,7 @@
from recipe_engine import recipe_api
if TYPE_CHECKING: # pragma: no cover
+ from typing import Sequence
from recipe_engine import config_types
from RECIPE_MODULES.pigweed.checkout import api as checkout_api
diff --git a/recipe_modules/cipd_roll/tests/full.py b/recipe_modules/cipd_roll/tests/full.py
index 28af363..60de76c 100644
--- a/recipe_modules/cipd_roll/tests/full.py
+++ b/recipe_modules/cipd_roll/tests/full.py
@@ -18,12 +18,15 @@
import collections
import dataclasses
import re
-from typing import Generator, List
+from typing import TYPE_CHECKING
from PB.recipe_engine import result as result_pb2
from PB.go.chromium.org.luci.buildbucket.proto import common as common_pb2
from PB.recipe_modules.pigweed.cipd_roll.tests.full import InputProperties
-from recipe_engine import recipe_test_api
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator, List
+ from recipe_engine import recipe_test_api
DEPS = [
'pigweed/cipd_roll',
diff --git a/recipe_modules/cipd_upload/api.py b/recipe_modules/cipd_upload/api.py
index 42b7736..fa362eb 100644
--- a/recipe_modules/cipd_upload/api.py
+++ b/recipe_modules/cipd_upload/api.py
@@ -15,7 +15,7 @@
from __future__ import annotations
-from typing import Sequence, TYPE_CHECKING
+from typing import TYPE_CHECKING
from PB.recipe_modules.fuchsia.cipd_util.upload_manifest import (
CIPDUploadManifest,
@@ -24,6 +24,7 @@
from recipe_engine import recipe_api
if TYPE_CHECKING: # pragma: no cover
+ from typing import Sequence
from recipe_engine import config_types
from RECIPE_MODULES.pigweed.checkout import api as checkout_api
diff --git a/recipe_modules/cipd_upload/tests/full.py b/recipe_modules/cipd_upload/tests/full.py
index cb91641..73c7ecd 100644
--- a/recipe_modules/cipd_upload/tests/full.py
+++ b/recipe_modules/cipd_upload/tests/full.py
@@ -15,9 +15,13 @@
from __future__ import annotations
-from typing import Generator
+from typing import TYPE_CHECKING
-from recipe_engine import config, recipe_api, recipe_test_api
+from recipe_engine import config, recipe_api
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_test_api
DEPS = [
'pigweed/cipd_upload',
diff --git a/recipe_modules/cipd_upload/tests/manifest.py b/recipe_modules/cipd_upload/tests/manifest.py
index 912367d..5d485ec 100644
--- a/recipe_modules/cipd_upload/tests/manifest.py
+++ b/recipe_modules/cipd_upload/tests/manifest.py
@@ -15,7 +15,7 @@
from __future__ import annotations
-from typing import Generator
+from typing import TYPE_CHECKING
from PB.recipe_modules.fuchsia.cipd_util.upload_manifest import (
CIPDUploadManifest,
@@ -23,7 +23,10 @@
from PB.recipe_modules.pigweed.checkout.options import (
Options as CheckoutOptions,
)
-from recipe_engine import config, recipe_api, recipe_test_api
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_api, recipe_test_api
DEPS = [
'pigweed/checkout',
diff --git a/recipe_modules/cq_deps/api.py b/recipe_modules/cq_deps/api.py
index 830b176..f97f51e 100644
--- a/recipe_modules/cq_deps/api.py
+++ b/recipe_modules/cq_deps/api.py
@@ -18,12 +18,15 @@
import base64
import json
import re
-from typing import Any, Generator, Literal, Sequence
+from typing import TYPE_CHECKING
import attrs
from PB.recipe_modules.pigweed.cq_deps.properties import InputProperties
from recipe_engine import recipe_api
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Any, Generator, Literal, Sequence
+
_PATCHES_FILE = 'patches.json'
@@ -75,13 +78,15 @@
unresolved: tuple[Change]
-ChangeState = Literal['NEW', 'MERGED', 'ABANDONED']
+if TYPE_CHECKING: # pragma: no cover
+ ChangeState = Literal['NEW', 'MERGED', 'ABANDONED']
class CqDepsApi(recipe_api.RecipeApi):
"""Find dependencies on pending CLs."""
- ChangeState = ChangeState
+ if TYPE_CHECKING: # pragma: no cover
+ ChangeState = ChangeState
Change = Change
Result = CqDepsResult
diff --git a/recipe_modules/cq_deps/test_api.py b/recipe_modules/cq_deps/test_api.py
index 459c87a..3f61fac 100644
--- a/recipe_modules/cq_deps/test_api.py
+++ b/recipe_modules/cq_deps/test_api.py
@@ -17,11 +17,14 @@
import base64
import json
-from typing import Sequence
+from typing import TYPE_CHECKING
from PB.recipe_modules.pigweed.cq_deps.properties import InputProperties
from recipe_engine import post_process, recipe_test_api
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Sequence
+
class CqDepsTestApi(recipe_test_api.RecipeTestApi):
def properties(self, **kwargs):
diff --git a/recipe_modules/cq_deps/tests/full.py b/recipe_modules/cq_deps/tests/full.py
index 832669e..7b25065 100644
--- a/recipe_modules/cq_deps/tests/full.py
+++ b/recipe_modules/cq_deps/tests/full.py
@@ -15,9 +15,13 @@
from __future__ import annotations
-from typing import Generator
+from typing import TYPE_CHECKING
-from recipe_engine import config, recipe_api, recipe_test_api
+from recipe_engine import recipe_api
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_test_api
DEPS = [
'pigweed/cq_deps',
diff --git a/recipe_modules/default_timeout/api.py b/recipe_modules/default_timeout/api.py
index 70cb612..c9a6564 100644
--- a/recipe_modules/default_timeout/api.py
+++ b/recipe_modules/default_timeout/api.py
@@ -17,11 +17,14 @@
import contextlib
import dataclasses
-from typing import Generator, TYPE_CHECKING
+from typing import TYPE_CHECKING
from recipe_engine import recipe_api
from RECIPE_MODULES.fuchsia.utils import nice_duration
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+
class TimeoutApi(recipe_api.RecipeApi):
"""Ensure the given call completes before swarming kills the build."""
diff --git a/recipe_modules/default_timeout/tests/full.py b/recipe_modules/default_timeout/tests/full.py
index f5edcf4..ebdef21 100644
--- a/recipe_modules/default_timeout/tests/full.py
+++ b/recipe_modules/default_timeout/tests/full.py
@@ -15,12 +15,15 @@
from __future__ import annotations
-from typing import Generator
-
import datetime
+from typing import TYPE_CHECKING
from PB.recipe_modules.pigweed.pw_presubmit.tests.full import InputProperties
-from recipe_engine import post_process, recipe_test_api
+from recipe_engine import post_process
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_test_api
DEPS = [
'pigweed/checkout',
diff --git a/recipe_modules/environment/tests/full.py b/recipe_modules/environment/tests/full.py
index ab1ed69..1b88880 100644
--- a/recipe_modules/environment/tests/full.py
+++ b/recipe_modules/environment/tests/full.py
@@ -16,11 +16,12 @@
from __future__ import annotations
import dataclasses
-from typing import Generator, Optional, TYPE_CHECKING
+from typing import TYPE_CHECKING
from PB.recipe_modules.pigweed.environment.tests.full import InputProperties
if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator, Optional
from recipe_engine import config_types, recipe_test_api
DEPS = [
diff --git a/recipe_modules/gerrit_comment/tests/full.py b/recipe_modules/gerrit_comment/tests/full.py
index d42acfa..dab4edb 100644
--- a/recipe_modules/gerrit_comment/tests/full.py
+++ b/recipe_modules/gerrit_comment/tests/full.py
@@ -16,13 +16,16 @@
from __future__ import annotations
import datetime
-from typing import Generator
+from typing import TYPE_CHECKING
from PB.recipe_modules.pigweed.gerrit_comment.options import (
CommentBehavior,
Options,
)
-from recipe_engine import recipe_api, recipe_test_api
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_api, recipe_test_api
DEPS = [
'pigweed/checkout',
diff --git a/recipe_modules/pipeline/api.py b/recipe_modules/pipeline/api.py
index 773f75f..6d1fbf1 100644
--- a/recipe_modules/pipeline/api.py
+++ b/recipe_modules/pipeline/api.py
@@ -15,9 +15,12 @@
from __future__ import annotations
+from typing import TYPE_CHECKING
+
from recipe_engine import recipe_api
-from PB.recipe_modules.pigweed.pipeline import properties as properties_pb2
+if TYPE_CHECKING: # pragma: no cover
+ from PB.recipe_modules.pigweed.pipeline import properties as properties_pb2
class PipelineApi(recipe_api.RecipeApi):
diff --git a/recipe_modules/pipeline/tests/full.py b/recipe_modules/pipeline/tests/full.py
index 9657e54..e660acd 100644
--- a/recipe_modules/pipeline/tests/full.py
+++ b/recipe_modules/pipeline/tests/full.py
@@ -15,9 +15,13 @@
from __future__ import annotations
-from typing import Generator
+from typing import TYPE_CHECKING
-from recipe_engine import post_process, recipe_test_api
+from recipe_engine import post_process
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_test_api
DEPS = [
'pigweed/pipeline',
diff --git a/recipe_modules/pw_presubmit/api.py b/recipe_modules/pw_presubmit/api.py
index 92d5829..e4984e7 100644
--- a/recipe_modules/pw_presubmit/api.py
+++ b/recipe_modules/pw_presubmit/api.py
@@ -18,12 +18,13 @@
import collections
import dataclasses
import shlex
-from typing import Sequence, TYPE_CHECKING
+from typing import TYPE_CHECKING
from PB.recipe_modules.pigweed.pw_presubmit import options as options_pb2
from recipe_engine import recipe_api
if TYPE_CHECKING: # pragma: no cover
+ from typing import Sequence
from RECIPE_MODULES.pigweed.checkout import api as checkout_api
from recipe_engine import config_types, step_data
diff --git a/recipe_modules/pw_presubmit/tests/full.py b/recipe_modules/pw_presubmit/tests/full.py
index 2c6008e..2089163 100644
--- a/recipe_modules/pw_presubmit/tests/full.py
+++ b/recipe_modules/pw_presubmit/tests/full.py
@@ -17,14 +17,15 @@
import collections
import datetime
-
-from typing import Generator
-
-from recipe_engine import recipe_test_api
+from typing import TYPE_CHECKING
from PB.recipe_modules.pigweed.gerrit_comment.options import CommentBehavior
from PB.recipe_modules.pigweed.pw_presubmit.tests.full import InputProperties
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_test_api
+
DEPS = [
'pigweed/checkout',
'pigweed/pw_presubmit',
diff --git a/recipe_modules/roll_util/api.py b/recipe_modules/roll_util/api.py
index 13d4b11..636949f 100644
--- a/recipe_modules/roll_util/api.py
+++ b/recipe_modules/roll_util/api.py
@@ -18,7 +18,7 @@
import collections
import enum
import re
-from typing import Any, Optional, Sequence, TYPE_CHECKING
+from typing import TYPE_CHECKING
import urllib
import attrs
@@ -29,6 +29,7 @@
from recipe_engine import recipe_api
if TYPE_CHECKING: # pragma: no cover
+ from typing import Any, Optional, Sequence
from recipe_engine import config_types
# If we're embedding the original commit message, prepend 'Original-' to lines
diff --git a/recipe_modules/roll_util/tests/labels.py b/recipe_modules/roll_util/tests/labels.py
index 6833d2c..672c51a 100644
--- a/recipe_modules/roll_util/tests/labels.py
+++ b/recipe_modules/roll_util/tests/labels.py
@@ -15,9 +15,11 @@
from __future__ import annotations
-from typing import Generator
+from typing import TYPE_CHECKING
-from recipe_engine import recipe_test_api
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_test_api
DEPS = [
'pigweed/roll_util',
diff --git a/recipe_modules/roll_util/tests/multiple_rolls.py b/recipe_modules/roll_util/tests/multiple_rolls.py
index a7db8af..6ef0967 100644
--- a/recipe_modules/roll_util/tests/multiple_rolls.py
+++ b/recipe_modules/roll_util/tests/multiple_rolls.py
@@ -15,9 +15,11 @@
from __future__ import annotations
-from typing import Generator
+from typing import TYPE_CHECKING
-from recipe_engine import recipe_test_api
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_test_api
DEPS = [
'pigweed/roll_util',
diff --git a/recipe_modules/roll_util/tests/single_roll.py b/recipe_modules/roll_util/tests/single_roll.py
index a0dc63a..9e375f4 100644
--- a/recipe_modules/roll_util/tests/single_roll.py
+++ b/recipe_modules/roll_util/tests/single_roll.py
@@ -15,11 +15,15 @@
from __future__ import annotations
-from typing import Generator
+from typing import TYPE_CHECKING
-from recipe_engine import config, recipe_api, recipe_test_api
from PB.recipes.pigweed.submodule_roller import InputProperties
from PB.recipe_modules.fuchsia.auto_roller.options import Options
+from recipe_engine import config, recipe_api
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_test_api
DEPS = [
'pigweed/roll_util',
diff --git a/recipe_modules/save_logs/tests/full.py b/recipe_modules/save_logs/tests/full.py
index 2ffcb25..5aa36f1 100644
--- a/recipe_modules/save_logs/tests/full.py
+++ b/recipe_modules/save_logs/tests/full.py
@@ -15,9 +15,11 @@
from __future__ import annotations
-from typing import Generator
+from typing import TYPE_CHECKING
-from recipe_engine import recipe_test_api
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_test_api
DEPS = [
'pigweed/save_logs',
diff --git a/recipe_modules/util/api.py b/recipe_modules/util/api.py
index 8c09ccc..0f88aa4 100644
--- a/recipe_modules/util/api.py
+++ b/recipe_modules/util/api.py
@@ -17,16 +17,19 @@
import json
import re
-from typing import Any, Sequence
+from typing import TYPE_CHECKING
import attrs
from google.protobuf import json_format
-from PB.go.chromium.org.luci.buildbucket.proto import (
- build as build_pb2,
- common as common_pb2,
-)
from recipe_engine import recipe_api
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Any, Sequence
+ from PB.go.chromium.org.luci.buildbucket.proto import (
+ build as build_pb2,
+ common as common_pb2,
+ )
+
@attrs.define
class ChangeWithComments:
diff --git a/recipe_modules/util/tests/full.py b/recipe_modules/util/tests/full.py
index c87ed79..31e63af 100644
--- a/recipe_modules/util/tests/full.py
+++ b/recipe_modules/util/tests/full.py
@@ -16,9 +16,13 @@
from __future__ import annotations
import re
-from typing import Generator
+from typing import TYPE_CHECKING
-from recipe_engine import config, recipe_api, recipe_test_api
+from recipe_engine import config, recipe_api
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_test_api
DEPS = [
'pigweed/util',
diff --git a/recipes/bazel.py b/recipes/bazel.py
index e11b203..44220ad 100644
--- a/recipes/bazel.py
+++ b/recipes/bazel.py
@@ -16,10 +16,14 @@
from __future__ import annotations
import re
-from typing import Generator
+from typing import TYPE_CHECKING
from PB.recipes.pigweed.bazel import InputProperties
-from recipe_engine import post_process, recipe_api, recipe_test_api
+from recipe_engine import post_process
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_api, recipe_test_api
DEPS = [
'pigweed/bazel',
diff --git a/recipes/bazel_roller.py b/recipes/bazel_roller.py
index 25f90a7..5dacd47 100644
--- a/recipes/bazel_roller.py
+++ b/recipes/bazel_roller.py
@@ -35,7 +35,7 @@
import itertools
import re
-from typing import Generator, Sequence, TypeVar
+from typing import TYPE_CHECKING
import attrs
from PB.go.chromium.org.luci.buildbucket.proto import common as common_pb2
@@ -43,7 +43,11 @@
from PB.recipe_modules.pigweed.checkout.options import (
Options as CheckoutOptions,
)
-from recipe_engine import post_process, recipe_api, recipe_test_api
+from recipe_engine import post_process
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator, Sequence, TypeVar
+ from recipe_engine import recipe_api, recipe_test_api
DEPS = [
'fuchsia/auto_roller',
diff --git a/recipes/build.py b/recipes/build.py
index 2dbfbfe..139df63 100644
--- a/recipes/build.py
+++ b/recipes/build.py
@@ -15,10 +15,13 @@
from __future__ import annotations
-from typing import Generator
+from typing import TYPE_CHECKING
from PB.recipes.pigweed.build import InputProperties
-from recipe_engine import recipe_test_api
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_test_api
DEPS = [
'pigweed/build',
diff --git a/recipes/cipd_roller.py b/recipes/cipd_roller.py
index c43faea..3148c91 100644
--- a/recipes/cipd_roller.py
+++ b/recipes/cipd_roller.py
@@ -18,12 +18,15 @@
import collections
import dataclasses
import re
-from typing import Generator, List
+from typing import TYPE_CHECKING
from PB.recipe_engine import result as result_pb2
from PB.go.chromium.org.luci.buildbucket.proto import common as common_pb2
from PB.recipes.pigweed.cipd_roller import InputProperties
-from recipe_engine import recipe_test_api
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator, List
+ from recipe_engine import recipe_test_api
DEPS = [
'fuchsia/auto_roller',
diff --git a/recipes/copy_roller.py b/recipes/copy_roller.py
index be74e54..103bc8a 100644
--- a/recipes/copy_roller.py
+++ b/recipes/copy_roller.py
@@ -16,7 +16,7 @@
from __future__ import annotations
import re
-from typing import Generator
+from typing import TYPE_CHECKING
import attrs
from PB.go.chromium.org.luci.buildbucket.proto import common as common_pb2
@@ -24,7 +24,11 @@
from PB.recipe_modules.pigweed.checkout.options import (
Options as CheckoutOptions,
)
-from recipe_engine import post_process, recipe_api, recipe_test_api
+from recipe_engine import post_process
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_api, recipe_test_api
DEPS = [
'fuchsia/auto_roller',
diff --git a/recipes/dev_status.py b/recipes/dev_status.py
index 191d89a..9e6b694 100644
--- a/recipes/dev_status.py
+++ b/recipes/dev_status.py
@@ -21,7 +21,7 @@
import collections
import datetime
-from typing import Generator, Sequence, Tuple
+from typing import TYPE_CHECKING
from PB.recipe_engine import result as result_pb2
from PB.go.chromium.org.luci.buildbucket.proto import (
@@ -30,8 +30,11 @@
)
from PB.recipes.pigweed.dev_status import InputProperties
from PB.recipe_engine import result
-from recipe_engine import post_process, recipe_api, recipe_test_api
+from recipe_engine import post_process
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator, Sequence, Tuple
+ from recipe_engine import recipe_api, recipe_test_api
DEPS = [
'fuchsia/builder_status',
diff --git a/recipes/docs_builder.py b/recipes/docs_builder.py
index d2a1e73..56586c4 100644
--- a/recipes/docs_builder.py
+++ b/recipes/docs_builder.py
@@ -15,17 +15,16 @@
from __future__ import annotations
-from typing import Any, Generator, Sequence
+from typing import TYPE_CHECKING
from PB.go.chromium.org.luci.buildbucket.proto import common
from PB.recipes.pigweed.docs_builder import InputProperties
from PB.recipe_engine import result
-from recipe_engine import (
- config_types,
- post_process,
- recipe_api,
- recipe_test_api,
-)
+from recipe_engine import post_process
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Any, Generator, Sequence
+ from recipe_engine import config_types, recipe_api, recipe_test_api
DEPS = [
'fuchsia/buildbucket_util',
diff --git a/recipes/envtest.py b/recipes/envtest.py
index 16785cb..213017f 100644
--- a/recipes/envtest.py
+++ b/recipes/envtest.py
@@ -16,11 +16,12 @@
from __future__ import annotations
import re
-from typing import Generator, TYPE_CHECKING
+from typing import TYPE_CHECKING
from PB.recipes.pigweed.envtest import InputProperties
if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
from recipe_engine import config_types, recipe_api, recipe_test_api
DEPS = [
diff --git a/recipes/gerrit_auto_submit.py b/recipes/gerrit_auto_submit.py
index a32dd2a..0d24aea 100644
--- a/recipes/gerrit_auto_submit.py
+++ b/recipes/gerrit_auto_submit.py
@@ -15,10 +15,14 @@
from __future__ import annotations
-from typing import Generator
+from typing import TYPE_CHECKING
from PB.recipes.pigweed.gerrit_auto_submit import InputProperties
-from recipe_engine import post_process, recipe_test_api
+from recipe_engine import post_process
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_test_api
DEPS = [
'fuchsia/gerrit_auto_submit',
diff --git a/recipes/git_archive.py b/recipes/git_archive.py
index 40c764a..b9a07ee 100644
--- a/recipes/git_archive.py
+++ b/recipes/git_archive.py
@@ -15,11 +15,15 @@
from __future__ import annotations
-from typing import Generator
+from typing import TYPE_CHECKING
from PB.recipes.pigweed.git_archive import InputProperties
-from recipe_engine import post_process, recipe_api, recipe_test_api
+from recipe_engine import post_process
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_api, recipe_test_api
DEPS = [
'fuchsia/buildbucket_util',
diff --git a/recipes/luci_config.py b/recipes/luci_config.py
index 892eaca..11c41cd 100644
--- a/recipes/luci_config.py
+++ b/recipes/luci_config.py
@@ -15,10 +15,14 @@
from __future__ import annotations
-from typing import Generator
+from typing import TYPE_CHECKING
from PB.recipes.pigweed.luci_config import InputProperties
-from recipe_engine import post_process, recipe_test_api
+from recipe_engine import post_process
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_test_api
DEPS = [
'fuchsia/validate_lucicfg',
diff --git a/recipes/multi_roller.py b/recipes/multi_roller.py
index 7e5060a..87efa4a 100644
--- a/recipes/multi_roller.py
+++ b/recipes/multi_roller.py
@@ -15,7 +15,7 @@
from __future__ import annotations
import itertools
-from typing import Any
+from typing import TYPE_CHECKING
import attrs
from google.protobuf import json_format
@@ -25,6 +25,9 @@
)
from PB.recipes.pigweed.multi_roller import Builder, InputProperties
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Any
+
DEPS = [
"fuchsia/buildbucket_util",
"fuchsia/gerrit",
diff --git a/recipes/pigweed.py b/recipes/pigweed.py
index 22e875b..4ad7b3f 100644
--- a/recipes/pigweed.py
+++ b/recipes/pigweed.py
@@ -15,11 +15,14 @@
from __future__ import annotations
-from typing import Generator
+from typing import TYPE_CHECKING
from PB.go.chromium.org.luci.buildbucket.proto import common as common_pb2
from PB.recipes.pigweed.pigweed import Pigweed
-from recipe_engine import recipe_test_api
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_test_api
DEPS = [
'fuchsia/buildbucket_util',
diff --git a/recipes/pipeline.py b/recipes/pipeline.py
index a4665e7..84d95c2 100644
--- a/recipes/pipeline.py
+++ b/recipes/pipeline.py
@@ -16,17 +16,16 @@
from __future__ import annotations
import re
-from typing import Any, Generator
+from typing import TYPE_CHECKING
from PB.go.chromium.org.luci.buildbucket.proto import common as common_pb2
import PB.recipes.pigweed.pipeline as pipeline_pb2
from PB.recipe_engine import result
-from recipe_engine import (
- config_types,
- post_process,
- recipe_api,
- recipe_test_api,
-)
+from recipe_engine import post_process
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Any, Generator
+ from recipe_engine import config_types, recipe_api, recipe_test_api
DEPS = [
'fuchsia/subbuild',
diff --git a/recipes/pw_presubmit.py b/recipes/pw_presubmit.py
index 62fb7f3..7c999d0 100644
--- a/recipes/pw_presubmit.py
+++ b/recipes/pw_presubmit.py
@@ -17,18 +17,16 @@
import datetime
import re
-from typing import Generator
+from typing import TYPE_CHECKING
from PB.go.chromium.org.luci.buildbucket.proto import common
from PB.recipes.pigweed.pw_presubmit import InputProperties, StepName
from PB.recipe_engine import result
+from recipe_engine import post_process
-from recipe_engine import (
- config_types,
- post_process,
- recipe_api,
- recipe_test_api,
-)
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Any, Generator
+ from recipe_engine import config_types, recipe_api, recipe_test_api
DEPS = [
'fuchsia/gsutil',
diff --git a/recipes/recipes.py b/recipes/recipes.py
index 34e1bfd..e7248bc 100644
--- a/recipes/recipes.py
+++ b/recipes/recipes.py
@@ -15,10 +15,13 @@
from __future__ import annotations
-from typing import Generator
+from typing import TYPE_CHECKING
from PB.recipes.pigweed.recipes import InputProperties
-from recipe_engine import recipe_test_api
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_test_api
DEPS = [
'fuchsia/recipe_testing',
diff --git a/recipes/repo_roller.py b/recipes/repo_roller.py
index 9c9b8b2..0540256 100644
--- a/recipes/repo_roller.py
+++ b/recipes/repo_roller.py
@@ -18,7 +18,7 @@
import collections
import dataclasses
import re
-from typing import Generator, TYPE_CHECKING
+from typing import TYPE_CHECKING
import urllib
import xml.etree.ElementTree
@@ -27,8 +27,11 @@
from PB.recipe_modules.pigweed.checkout.options import (
Options as CheckoutOptions,
)
-from recipe_engine import config_types, recipe_test_api
-from RECIPE_MODULES.pigweed.roll_util import api as roll_util_api
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import config_types, recipe_test_api
+ from RECIPE_MODULES.pigweed.roll_util import api as roll_util_api
DEPS = [
'fuchsia/auto_roller',
diff --git a/recipes/rerunner.py b/recipes/rerunner.py
index 874cb9d..4276c19 100644
--- a/recipes/rerunner.py
+++ b/recipes/rerunner.py
@@ -36,7 +36,7 @@
import collections
import fnmatch
import json
-from typing import Generator, Sequence, Tuple
+from typing import TYPE_CHECKING
from PB.recipe_engine import result as result_pb2
from PB.go.chromium.org.luci.buildbucket.proto import (
@@ -50,7 +50,11 @@
)
from PB.recipes.pigweed.rerunner import InputProperties
from PB.recipe_engine import result
-from recipe_engine import post_process, recipe_api, recipe_test_api
+from recipe_engine import post_process
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator, Sequence, Tuple
+ from recipe_engine import recipe_api, recipe_test_api
DEPS = [
'fuchsia/builder_status',
diff --git a/recipes/run_script.py b/recipes/run_script.py
index be3f146..1c91dea 100644
--- a/recipes/run_script.py
+++ b/recipes/run_script.py
@@ -16,13 +16,13 @@
from __future__ import annotations
import re
-from typing import Callable, Generator, TYPE_CHECKING
+from typing import TYPE_CHECKING
from PB.recipes.pigweed.run_script import InputProperties
-from recipe_engine import config_types
if TYPE_CHECKING: # pragma: no cover
- from recipe_engine import recipe_api, recipe_test_api
+ from typing import Callable, Generator
+ from recipe_engine import config_types, recipe_api, recipe_test_api
DEPS = [
'pigweed/checkout',
@@ -34,8 +34,6 @@
PROPERTIES = InputProperties
-_Command = list[str | config_types.Path]
-
def RunSteps(api: recipe_api.RecipeScriptApi, props: InputProperties) -> None:
checkout: api.checkout.CheckoutContext = api.checkout(
@@ -45,7 +43,7 @@
checkout, props.environment_options
)
- cmd: _Command = [checkout.root / props.script]
+ cmd: list[str | config_types.Path] = [checkout.root / props.script]
with env():
for arg in props.arguments:
diff --git a/recipes/static_checks.py b/recipes/static_checks.py
index 2af01d6..7e0e15f 100644
--- a/recipes/static_checks.py
+++ b/recipes/static_checks.py
@@ -17,12 +17,13 @@
import functools
import re
-from typing import Any, Generator, Sequence, TYPE_CHECKING
+from typing import TYPE_CHECKING
from PB.recipes.pigweed.static_checks import InputProperties
from recipe_engine import post_process
if TYPE_CHECKING: # pragma: no cover
+ from typing import Any, Generator, Sequence
from recipe_engine import recipe_api, recipe_test_api
from RECIPE_MODULES.pigweed.util import api as util_api
diff --git a/recipes/submodule_roller.py b/recipes/submodule_roller.py
index 1fb2d59..95340bd 100644
--- a/recipes/submodule_roller.py
+++ b/recipes/submodule_roller.py
@@ -19,13 +19,15 @@
import dataclasses
import io
import re
-from typing import Generator, TYPE_CHECKING
+from typing import TYPE_CHECKING
import attrs
from PB.recipes.pigweed.submodule_roller import InputProperties, Submodule
+from recipe_engine import post_process
if TYPE_CHECKING: # pragma: no cover
- from recipe_engine import config_types, post_process, recipe_test_api
+ from typing import Generator
+ from recipe_engine import config_types, recipe_test_api
DEPS = [
'fuchsia/auto_roller',
diff --git a/recipes/target_to_cipd.py b/recipes/target_to_cipd.py
index 9f91eeb..1dfa7ed 100644
--- a/recipes/target_to_cipd.py
+++ b/recipes/target_to_cipd.py
@@ -14,11 +14,13 @@
"""Build a GN target and upload to CIPD."""
from __future__ import annotations
-
-from typing import Generator
+from typing import TYPE_CHECKING
from PB.recipes.pigweed.target_to_cipd import InputProperties
-from recipe_engine import recipe_test_api
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_test_api
DEPS = [
'fuchsia/buildbucket_util',
diff --git a/recipes/tokendb_check.py b/recipes/tokendb_check.py
index 7ad9721..f973ede 100644
--- a/recipes/tokendb_check.py
+++ b/recipes/tokendb_check.py
@@ -16,10 +16,14 @@
from __future__ import annotations
import re
-from typing import Generator
+from typing import TYPE_CHECKING
from PB.recipes.pigweed.tokendb_check import InputProperties
-from recipe_engine import post_process, recipe_test_api
+from recipe_engine import post_process
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_test_api
DEPS = [
'fuchsia/git',
diff --git a/recipes/tokendb_updater.py b/recipes/tokendb_updater.py
index 81d1294..2b8de25 100644
--- a/recipes/tokendb_updater.py
+++ b/recipes/tokendb_updater.py
@@ -23,11 +23,14 @@
from __future__ import annotations
-from typing import Generator
+from typing import TYPE_CHECKING
from PB.recipe_engine import result
from PB.recipes.pigweed.tokendb_updater import InputProperties, TokenPath
-from recipe_engine import recipe_api, recipe_test_api
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_api, recipe_test_api
DEPS = [
'fuchsia/auto_roller',
diff --git a/recipes/txt_roller.py b/recipes/txt_roller.py
index 0f15b09..90ea53d 100644
--- a/recipes/txt_roller.py
+++ b/recipes/txt_roller.py
@@ -16,7 +16,7 @@
from __future__ import annotations
import re
-from typing import Generator
+from typing import TYPE_CHECKING
import attrs
from PB.go.chromium.org.luci.buildbucket.proto import common as common_pb2
@@ -24,7 +24,11 @@
from PB.recipe_modules.pigweed.checkout.options import (
Options as CheckoutOptions,
)
-from recipe_engine import post_process, recipe_api, recipe_test_api
+from recipe_engine import post_process
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_api, recipe_test_api
DEPS = [
'fuchsia/auto_roller',
diff --git a/recipes/update_python_versions.py b/recipes/update_python_versions.py
index 2d2d1c5..b12a0b8 100644
--- a/recipes/update_python_versions.py
+++ b/recipes/update_python_versions.py
@@ -16,11 +16,14 @@
from __future__ import annotations
import re
-from typing import Generator
+from typing import TYPE_CHECKING
import attr
from PB.recipes.pigweed.update_python_versions import InputProperties
-from recipe_engine import recipe_test_api
+
+if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
+ from recipe_engine import recipe_test_api
DEPS = [
'fuchsia/auto_roller',
diff --git a/recipes/xrefs.py b/recipes/xrefs.py
index 439ed02..20d07f8 100644
--- a/recipes/xrefs.py
+++ b/recipes/xrefs.py
@@ -15,12 +15,13 @@
from __future__ import annotations
-from typing import Generator, TYPE_CHECKING
+from typing import TYPE_CHECKING
import urllib
from PB.recipes.pigweed.xrefs import InputProperties
if TYPE_CHECKING: # pragma: no cover
+ from typing import Generator
from recipe_engine import config_types, recipe_api, recipe_test_api
DEPS = [