Description
Unused imports should be removed from generated test code. This may be fixed automatically if we add static analysis (mypy) checks on the tests directory.
Currently we're only running mypy on the client code and not the test code.
https://github.com/googleapis/gapic-generator-python/blob/ecf4bb0bae89c87afa5bb3c6dd307793a4e7e80b/tests/integration/goldens/credentials/noxfile.py#L94-L98
In addition, some of the code has # type: ignore directives which bypass static analysis.
from google.cloud.gkehub.configmanagement.v1 import configmanagement_pb2 # type: ignore
from google.cloud.gkehub.multiclusteringress.v1 import multiclusteringress_pb2 # type: ignore
In order for the issue to be caught by static analysis we need to remove the # type: ignore which is bypassing checks.
As an example, see the code in test_gke_hub.py for google/cloud/gkehub/v1 where configmanagement_pb2 and multiclusteringress_pb2 are unused.
Activity
parthea commentedon Mar 26, 2026
Transferring to google-cloud-python as the code for gapic-generator will be migrated there.
daniel-sanche commentedon May 27, 2026
This issue is being closed as part of a bulk review (Filter #1). Please reopen if you believe this is still relevant and requires action.
fix(generator): use flat_ref_types in test templates and delete remov…