Skip to content

Commit a315e31

Browse files
authored
Revert "fix(generator): use flat_ref_types in test templates and delete remov…"
This reverts commit 395f764.
1 parent 5b5ece5 commit a315e31

12 files changed

Lines changed: 64 additions & 2 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
description: Remove unused imports
15+
url: https://github.com/googleapis/gapic-generator-python/issues/1833
16+
replacements:
17+
- paths: [
18+
packages/google-cloud-gke-hub/tests/unit/gapic/gkehub_v1/test_gke_hub.py
19+
]
20+
before: |
21+
import google.cloud.gkehub.configmanagement.v1.configmanagement_pb2 as configmanagement_pb2 # type: ignore
22+
import google.cloud.gkehub.multiclusteringress.v1.multiclusteringress_pb2 as multiclusteringress_pb2 # type: ignore
23+
import google.cloud.gkehub.rbacrolebindingactuation.v1.rbacrolebindingactuation_pb2 as rbacrolebindingactuation_pb2 # type: ignore
24+
after: ""
25+
count: 1
26+
- paths: [
27+
packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1/test_validation_helper_v1.py
28+
]
29+
before: |
30+
import grafeas.v1.attestation_pb2 as attestation_pb2 # type: ignore
31+
import grafeas.v1.common_pb2 as common_pb2 # type: ignore
32+
after: ""
33+
count: 1

packages/gapic-generator/gapic/ads-templates/tests/unit/gapic/%name_%version/%sub/test_%service.py.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ from google.longrunning import operations_pb2 # type: ignore
5757
{% endif %}
5858
from google.api_core import gapic_v1
5959
{% for method in service.methods.values() %}
60-
{% for ref_type in method.flat_ref_types
60+
{% for ref_type in method.ref_types
6161
if not ((ref_type.ident.python_import.package == ('google', 'api_core') and ref_type.ident.python_import.module == 'operation')
6262
or ref_type.ident.python_import.package == ('google', 'protobuf') and ref_type.ident.python_import.module == 'empty_pb2') %}
6363
{{ ref_type.ident.python_import }}

packages/gapic-generator/gapic/templates/tests/unit/gapic/%name_%version/%sub/test_%service.py.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ from google.longrunning import operations_pb2 # type: ignore
8686
{% endif %}
8787
from google.api_core import gapic_v1
8888
{% for method in service.methods.values() %}
89-
{% for ref_type in method.flat_ref_types
89+
{% for ref_type in method.ref_types
9090
if not (ref_type.ident.python_import.package == ('google', 'api_core') and ref_type.ident.python_import.module == 'operation') %}
9191
{{ ref_type.ident.python_import }}
9292
{% endfor %}

packages/gapic-generator/tests/integration/goldens/asset/tests/unit/gapic/asset_v1/test_asset_service.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
from google.oauth2 import service_account
6363
import google.api_core.operation_async as operation_async # type: ignore
6464
import google.auth
65+
import google.protobuf.duration_pb2 as duration_pb2 # type: ignore
6566
import google.protobuf.field_mask_pb2 as field_mask_pb2 # type: ignore
6667
import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore
6768
import google.rpc.status_pb2 as status_pb2 # type: ignore

packages/gapic-generator/tests/integration/goldens/eventarc/tests/unit/gapic/eventarc_v1/test_eventarc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
from google.cloud.eventarc_v1.types import logging_config
7272
from google.cloud.eventarc_v1.types import message_bus
7373
from google.cloud.eventarc_v1.types import message_bus as gce_message_bus
74+
from google.cloud.eventarc_v1.types import network_config
7475
from google.cloud.eventarc_v1.types import pipeline
7576
from google.cloud.eventarc_v1.types import pipeline as gce_pipeline
7677
from google.cloud.eventarc_v1.types import trigger
@@ -83,8 +84,10 @@
8384
from google.oauth2 import service_account
8485
import google.api_core.operation_async as operation_async # type: ignore
8586
import google.auth
87+
import google.protobuf.duration_pb2 as duration_pb2 # type: ignore
8688
import google.protobuf.field_mask_pb2 as field_mask_pb2 # type: ignore
8789
import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore
90+
import google.rpc.code_pb2 as code_pb2 # type: ignore
8891

8992

9093

packages/gapic-generator/tests/integration/goldens/logging/tests/unit/gapic/logging_v2/test_logging_service_v2.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@
5353
from google.oauth2 import service_account
5454
import google.api.monitored_resource_pb2 as monitored_resource_pb2 # type: ignore
5555
import google.auth
56+
import google.logging.type.http_request_pb2 as http_request_pb2 # type: ignore
57+
import google.logging.type.log_severity_pb2 as log_severity_pb2 # type: ignore
58+
import google.protobuf.any_pb2 as any_pb2 # type: ignore
59+
import google.protobuf.duration_pb2 as duration_pb2 # type: ignore
60+
import google.protobuf.struct_pb2 as struct_pb2 # type: ignore
61+
import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore
5662

5763

5864

packages/gapic-generator/tests/integration/goldens/logging/tests/unit/gapic/logging_v2/test_metrics_service_v2.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@
5151
from google.longrunning import operations_pb2 # type: ignore
5252
from google.oauth2 import service_account
5353
import google.api.distribution_pb2 as distribution_pb2 # type: ignore
54+
import google.api.label_pb2 as label_pb2 # type: ignore
55+
import google.api.launch_stage_pb2 as launch_stage_pb2 # type: ignore
5456
import google.api.metric_pb2 as metric_pb2 # type: ignore
5557
import google.auth
58+
import google.protobuf.duration_pb2 as duration_pb2 # type: ignore
5659
import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore
5760

5861

packages/gapic-generator/tests/integration/goldens/logging_internal/tests/unit/gapic/logging_v2/test_logging_service_v2.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@
5353
from google.oauth2 import service_account
5454
import google.api.monitored_resource_pb2 as monitored_resource_pb2 # type: ignore
5555
import google.auth
56+
import google.logging.type.http_request_pb2 as http_request_pb2 # type: ignore
57+
import google.logging.type.log_severity_pb2 as log_severity_pb2 # type: ignore
58+
import google.protobuf.any_pb2 as any_pb2 # type: ignore
59+
import google.protobuf.duration_pb2 as duration_pb2 # type: ignore
60+
import google.protobuf.struct_pb2 as struct_pb2 # type: ignore
61+
import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore
5662

5763

5864

packages/gapic-generator/tests/integration/goldens/logging_internal/tests/unit/gapic/logging_v2/test_metrics_service_v2.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@
5151
from google.longrunning import operations_pb2 # type: ignore
5252
from google.oauth2 import service_account
5353
import google.api.distribution_pb2 as distribution_pb2 # type: ignore
54+
import google.api.label_pb2 as label_pb2 # type: ignore
55+
import google.api.launch_stage_pb2 as launch_stage_pb2 # type: ignore
5456
import google.api.metric_pb2 as metric_pb2 # type: ignore
5557
import google.auth
58+
import google.protobuf.duration_pb2 as duration_pb2 # type: ignore
5659
import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore
5760

5861

packages/gapic-generator/tests/integration/goldens/redis/tests/unit/gapic/redis_v1/test_cloud_redis.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,12 @@
6969
from google.oauth2 import service_account
7070
import google.api_core.operation_async as operation_async # type: ignore
7171
import google.auth
72+
import google.protobuf.duration_pb2 as duration_pb2 # type: ignore
7273
import google.protobuf.empty_pb2 as empty_pb2 # type: ignore
7374
import google.protobuf.field_mask_pb2 as field_mask_pb2 # type: ignore
7475
import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore
76+
import google.type.dayofweek_pb2 as dayofweek_pb2 # type: ignore
77+
import google.type.timeofday_pb2 as timeofday_pb2 # type: ignore
7578

7679

7780

0 commit comments

Comments
 (0)