Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove duplicate import statement for google.longrunning.operations_pb2 #1726

Merged
merged 18 commits into from
Aug 23, 2023
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

{% filter sort_lines %}
{% set import_ns = namespace(has_operations_mixin=false) %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this may need to be generalized to the other mixins. WDYT?

I don't think we should block on that, but I would add a TODO in the code and reference this PR.

{% for method in service.methods.values() %}
{{ method.input.ident.python_import }}
{% if method.output.ident|string() == "operations_pb2.Operation" %}
{% set import_ns.has_operations_mixin = True %}
{% else %}
{{ method.output.ident.python_import }}
{% endif %}
{% endfor %}
{% if opts.add_iam_methods or api.has_iam_mixin %}
from google.iam.v1 import iam_policy_pb2 # type: ignore
Expand All @@ -30,6 +35,9 @@ from google.iam.v1 import policy_pb2 # type: ignore
from google.cloud.location import locations_pb2 # type: ignore
{% endif %}
{% if api.has_operations_mixin %}
{% set import_ns.has_operations_mixin = True %}
{% endif %}
{% if import_ns.has_operations_mixin %}
from google.longrunning import operations_pb2 # type: ignore
{% endif %}
{% endfilter %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ from google.auth.transport.grpc import SslCredentials # type: ignore
import grpc # type: ignore

{% filter sort_lines %}
{% set import_ns = namespace(has_operations_mixin=false) %}
{% for method in service.methods.values() %}
{{ method.input.ident.python_import }}
{% if method.output.ident|string() == "operations_pb2.Operation" %}
{% set import_ns.has_operations_mixin = True %}
{% else %}
{{ method.output.ident.python_import }}
{% endif %}
{% endfor %}
{% if opts.add_iam_methods or api.has_iam_mixin %}
from google.iam.v1 import iam_policy_pb2 # type: ignore
Expand All @@ -29,6 +34,9 @@ from google.iam.v1 import policy_pb2 # type: ignore
from google.cloud.location import locations_pb2 # type: ignore
{% endif %}
{% if api.has_operations_mixin %}
{% set import_ns.has_operations_mixin = True %}
{% endif %}
{% if import_ns.has_operations_mixin %}
from google.longrunning import operations_pb2 # type: ignore
{% endif %}
{% endfilter %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,11 @@ from google.api_core import path_template
from google.api_core import future
from google.api_core import operation
from google.api_core import operations_v1
from google.longrunning import operations_pb2 # type: ignore
{% endif %}{# lro #}
{% if api.has_location_mixin %}
from google.cloud.location import locations_pb2
{% endif %}
{% if api.has_operations_mixin %}
{% if api.has_operations_mixin or service.has_lro %}
from google.longrunning import operations_pb2 # type: ignore
{% endif %}
from google.api_core import gapic_v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

{% filter sort_lines %}
{% set import_ns = namespace(has_operations_mixin=false) %}
{% for method in service.methods.values() %}
{{ method.input.ident.python_import }}
{% if method.output.ident|string() == "operations_pb2.Operation" %}
{% set import_ns.has_operations_mixin = True %}
{% else %}
{{ method.output.ident.python_import }}
{% endif %}
{% endfor %}
{% if opts.add_iam_methods or api.has_iam_mixin %}
from google.iam.v1 import iam_policy_pb2 # type: ignore
Expand All @@ -32,6 +37,9 @@ from google.iam.v1 import policy_pb2 # type: ignore
from google.cloud.location import locations_pb2 # type: ignore
{% endif %}
{% if api.has_operations_mixin %}
{% set import_ns.has_operations_mixin = True %}
{% endif %}
{% if import_ns.has_operations_mixin %}
from google.longrunning import operations_pb2 # type: ignore
{% endif %}
{% endfilter %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ from google.auth.transport.grpc import SslCredentials # type: ignore
import grpc # type: ignore

{% filter sort_lines %}
{% set import_ns = namespace(has_operations_mixin=false) %}
{% for method in service.methods.values() %}
{{ method.input.ident.python_import }}
{% if method.output.ident|string() == "operations_pb2.Operation" %}
{% set import_ns.has_operations_mixin = True %}
{% else %}
{{ method.output.ident.python_import }}
{% endif %}
{% endfor %}
{% if opts.add_iam_methods or api.has_iam_mixin %}
from google.iam.v1 import iam_policy_pb2 # type: ignore
Expand All @@ -29,6 +34,9 @@ from google.iam.v1 import policy_pb2 # type: ignore
from google.cloud.location import locations_pb2 # type: ignore
{% endif %}
{% if api.has_operations_mixin %}
{% set import_ns.has_operations_mixin = True %}
{% endif %}
{% if import_ns.has_operations_mixin %}
from google.longrunning import operations_pb2 # type: ignore
{% endif %}
{% endfilter %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ import grpc # type: ignore
from grpc.experimental import aio # type: ignore

{% filter sort_lines %}
{% set import_ns = namespace(has_operations_mixin=false) %}
{% for method in service.methods.values() %}
{{ method.input.ident.python_import }}
{% if method.output.ident|string() == "operations_pb2.Operation" %}
{% set import_ns.has_operations_mixin = True %}
{% else %}
{{ method.output.ident.python_import }}
{% endif %}
{% endfor %}
{% if opts.add_iam_methods or api.has_iam_mixin %}
from google.iam.v1 import iam_policy_pb2 # type: ignore
Expand All @@ -29,6 +34,9 @@ from google.iam.v1 import policy_pb2 # type: ignore
from google.cloud.location import locations_pb2 # type: ignore
{% endif %}
{% if api.has_operations_mixin %}
{% set import_ns.has_operations_mixin = True %}
{% endif %}
{% if import_ns.has_operations_mixin %}
from google.longrunning import operations_pb2 # type: ignore
{% endif %}
{% endfilter %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ from google.iam.v1 import policy_pb2 # type: ignore
{% if api.has_location_mixin %}
from google.cloud.location import locations_pb2 # type: ignore
{% endif %}
{% set import_ns = namespace(has_operations_mixin=false) %}
{% if api.has_operations_mixin %}
from google.longrunning import operations_pb2 # type: ignore
{% set import_ns.has_operations_mixin = True %}
{% endif %}
from requests import __version__ as requests_version
import dataclasses
Expand All @@ -45,13 +46,20 @@ except AttributeError: # pragma: NO COVER
{% filter sort_lines %}
{% for method in service.methods.values() %}
{{method.input.ident.python_import}}
{% if method.output.ident|string() == "operations_pb2.Operation" %}
{% set import_ns.has_operations_mixin = True %}
{% else %}
{{method.output.ident.python_import}}
{% endif %}
{% endfor %}
{% if opts.add_iam_methods %}
from google.iam.v1 import iam_policy_pb2 # type: ignore
from google.iam.v1 import policy_pb2 # type: ignore
{% endif %}
{% endfilter %}
{% if import_ns.has_operations_mixin %}
from google.longrunning import operations_pb2 # type: ignore
{% endif %}

from .base import {{service.name}}Transport, DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@ from google.api_core import future
{% if service.has_lro %}
from google.api_core import operation
from google.api_core import operations_v1
from google.longrunning import operations_pb2 # type: ignore
{% endif %}{# lro #}
{% if api.has_location_mixin %}
from google.cloud.location import locations_pb2
{% endif %}
{% if api.has_operations_mixin %}
{% if api.has_operations_mixin or service.has_lro %}
from google.longrunning import operations_pb2 # type: ignore
{% endif %}
from google.api_core import gapic_v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
from google.oauth2 import service_account # type: ignore

from google.cloud.asset_v1.types import asset_service
from google.longrunning import operations_pb2 # type: ignore
from google.longrunning import operations_pb2 # type: ignore
from google.protobuf import empty_pb2 # type: ignore

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import grpc # type: ignore

from google.cloud.asset_v1.types import asset_service
from google.longrunning import operations_pb2 # type: ignore
from google.longrunning import operations_pb2 # type: ignore
from google.protobuf import empty_pb2 # type: ignore
from .base import AssetServiceTransport, DEFAULT_CLIENT_INFO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from grpc.experimental import aio # type: ignore

from google.cloud.asset_v1.types import asset_service
from google.longrunning import operations_pb2 # type: ignore
from google.longrunning import operations_pb2 # type: ignore
from google.protobuf import empty_pb2 # type: ignore
from .base import AssetServiceTransport, DEFAULT_CLIENT_INFO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

from google.protobuf import json_format
from google.api_core import operations_v1
from google.longrunning import operations_pb2 # type: ignore
from requests import __version__ as requests_version
import dataclasses
import re
Expand All @@ -42,8 +41,8 @@


from google.cloud.asset_v1.types import asset_service
from google.longrunning import operations_pb2 # type: ignore
from google.protobuf import empty_pb2 # type: ignore
from google.longrunning import operations_pb2 # type: ignore

from .base import AssetServiceTransport, DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
from google.cloud.location import locations_pb2 # type: ignore
from google.iam.v1 import iam_policy_pb2 # type: ignore
from google.iam.v1 import policy_pb2 # type: ignore
from google.longrunning import operations_pb2 # type: ignore
from google.longrunning import operations_pb2 # type: ignore

DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
from google.cloud.location import locations_pb2 # type: ignore
from google.iam.v1 import iam_policy_pb2 # type: ignore
from google.iam.v1 import policy_pb2 # type: ignore
from google.longrunning import operations_pb2 # type: ignore
from google.longrunning import operations_pb2 # type: ignore
from .base import EventarcTransport, DEFAULT_CLIENT_INFO

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
from google.cloud.location import locations_pb2 # type: ignore
from google.iam.v1 import iam_policy_pb2 # type: ignore
from google.iam.v1 import policy_pb2 # type: ignore
from google.longrunning import operations_pb2 # type: ignore
from google.longrunning import operations_pb2 # type: ignore
from .base import EventarcTransport, DEFAULT_CLIENT_INFO
from .grpc import EventarcGrpcTransport
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
from google.iam.v1 import iam_policy_pb2 # type: ignore
from google.iam.v1 import policy_pb2 # type: ignore
from google.cloud.location import locations_pb2 # type: ignore
from google.longrunning import operations_pb2 # type: ignore
from requests import __version__ as requests_version
import dataclasses
import re
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
from google.oauth2 import service_account # type: ignore

from google.cloud.logging_v2.types import logging_config
from google.longrunning import operations_pb2 # type: ignore
from google.longrunning import operations_pb2 # type: ignore
from google.protobuf import empty_pb2 # type: ignore

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import grpc # type: ignore

from google.cloud.logging_v2.types import logging_config
from google.longrunning import operations_pb2 # type: ignore
from google.longrunning import operations_pb2 # type: ignore
from google.protobuf import empty_pb2 # type: ignore
from .base import ConfigServiceV2Transport, DEFAULT_CLIENT_INFO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from grpc.experimental import aio # type: ignore

from google.cloud.logging_v2.types import logging_config
from google.longrunning import operations_pb2 # type: ignore
from google.longrunning import operations_pb2 # type: ignore
from google.protobuf import empty_pb2 # type: ignore
from .base import ConfigServiceV2Transport, DEFAULT_CLIENT_INFO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

from google.cloud.location import locations_pb2 # type: ignore
from google.cloud.redis_v1.types import cloud_redis
from google.longrunning import operations_pb2 # type: ignore
from google.longrunning import operations_pb2 # type: ignore

DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

from google.cloud.location import locations_pb2 # type: ignore
from google.cloud.redis_v1.types import cloud_redis
from google.longrunning import operations_pb2 # type: ignore
from google.longrunning import operations_pb2 # type: ignore
from .base import CloudRedisTransport, DEFAULT_CLIENT_INFO

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

from google.cloud.location import locations_pb2 # type: ignore
from google.cloud.redis_v1.types import cloud_redis
from google.longrunning import operations_pb2 # type: ignore
from google.longrunning import operations_pb2 # type: ignore
from .base import CloudRedisTransport, DEFAULT_CLIENT_INFO
from .grpc import CloudRedisGrpcTransport
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
from google.protobuf import json_format
from google.api_core import operations_v1
from google.cloud.location import locations_pb2 # type: ignore
from google.longrunning import operations_pb2 # type: ignore
from requests import __version__ as requests_version
import dataclasses
import re
Expand Down
Loading