Skip to content

Commit

Permalink
fix: use (new) typing for 'gapic_v1.method.DEFAULT' (googleapis#1032)
Browse files Browse the repository at this point in the history
Relies on merge of googleapis/python-api-core#292,
but falls back to current (unsat) typing on older versions.

Co-authored-by: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com>
  • Loading branch information
tseaver and busunkim96 committed Nov 2, 2021
1 parent a8d2b3a commit d85dfad
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore
from google.auth.exceptions import MutualTLSChannelError # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]
try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
except AttributeError:
OptionalRetry = Union[retries.Retry, object]

{% filter sort_lines %}
{% for method in service.methods.values() %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ from google.api_core import retry as retries # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]
try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
except AttributeError:
OptionalRetry = Union[retries.Retry, object]

{% filter sort_lines %}
{% for method in service.methods.values() %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore
from google.auth.exceptions import MutualTLSChannelError # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]
try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
except AttributeError:
OptionalRetry = Union[retries.Retry, object]

{% filter sort_lines %}
{% for method in service.methods.values() %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ from requests import __version__ as requests_version
from typing import Callable, Dict, Optional, Sequence, Tuple, Union
import warnings

OptionalRetry = Union[retries.Retry, object]
try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
except AttributeError:
OptionalRetry = Union[retries.Retry, object]

{% extends '_base.py.j2' %}

{% block content %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]
try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
except AttributeError:
OptionalRetry = Union[retries.Retry, object]

from google.api_core import operation # type: ignore
from google.api_core import operation_async # type: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
from google.auth.exceptions import MutualTLSChannelError # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]
try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
except AttributeError:
OptionalRetry = Union[retries.Retry, object]

from google.api_core import operation # type: ignore
from google.api_core import operation_async # type: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]
try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
except AttributeError:
OptionalRetry = Union[retries.Retry, object]

from google.iam.credentials_v1.types import common
from google.protobuf import duration_pb2 # type: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
from google.auth.exceptions import MutualTLSChannelError # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]
try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
except AttributeError:
OptionalRetry = Union[retries.Retry, object]

from google.iam.credentials_v1.types import common
from google.protobuf import duration_pb2 # type: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]
try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
except AttributeError:
OptionalRetry = Union[retries.Retry, object]

from google.cloud.logging_v2.services.config_service_v2 import pagers
from google.cloud.logging_v2.types import logging_config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
from google.auth.exceptions import MutualTLSChannelError # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]
try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
except AttributeError:
OptionalRetry = Union[retries.Retry, object]

from google.cloud.logging_v2.services.config_service_v2 import pagers
from google.cloud.logging_v2.types import logging_config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]
try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
except AttributeError:
OptionalRetry = Union[retries.Retry, object]

from google.api import monitored_resource_pb2 # type: ignore
from google.cloud.logging_v2.services.logging_service_v2 import pagers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
from google.auth.exceptions import MutualTLSChannelError # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]
try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
except AttributeError:
OptionalRetry = Union[retries.Retry, object]

from google.api import monitored_resource_pb2 # type: ignore
from google.cloud.logging_v2.services.logging_service_v2 import pagers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]
try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
except AttributeError:
OptionalRetry = Union[retries.Retry, object]

from google.api import distribution_pb2 # type: ignore
from google.api import metric_pb2 # type: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
from google.auth.exceptions import MutualTLSChannelError # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]
try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
except AttributeError:
OptionalRetry = Union[retries.Retry, object]

from google.api import distribution_pb2 # type: ignore
from google.api import metric_pb2 # type: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]
try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
except AttributeError:
OptionalRetry = Union[retries.Retry, object]

from google.api_core import operation # type: ignore
from google.api_core import operation_async # type: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
from google.auth.exceptions import MutualTLSChannelError # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]
try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
except AttributeError:
OptionalRetry = Union[retries.Retry, object]

from google.api_core import operation # type: ignore
from google.api_core import operation_async # type: ignore
Expand Down

0 comments on commit d85dfad

Please sign in to comment.