diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index bc893c9..7c454ab 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:8a5d3f6a2e43ed8293f34e06a2f56931d1e88a2694c3bb11b15df4eb256ad163 -# created: 2022-04-06T10:30:21.687684602Z + digest: sha256:00c9d764fd1cd56265f12a5ef4b99a0c9e87cf261018099141e2ca5158890416 +# created: 2022-04-20T23:42:53.970438194Z diff --git a/docs/conf.py b/docs/conf.py index d0098f3..a4b6149 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -24,9 +24,9 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys import os import shlex +import sys # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the diff --git a/google/cloud/functions/__init__.py b/google/cloud/functions/__init__.py index f9343d7..e17aeb3 100644 --- a/google/cloud/functions/__init__.py +++ b/google/cloud/functions/__init__.py @@ -14,35 +14,38 @@ # limitations under the License. # +from google.cloud.functions_v1.services.cloud_functions_service.async_client import ( + CloudFunctionsServiceAsyncClient, +) from google.cloud.functions_v1.services.cloud_functions_service.client import ( CloudFunctionsServiceClient, ) -from google.cloud.functions_v1.services.cloud_functions_service.async_client import ( - CloudFunctionsServiceAsyncClient, +from google.cloud.functions_v1.types.functions import ( + CallFunctionRequest, + CallFunctionResponse, + CloudFunction, + CloudFunctionStatus, + CreateFunctionRequest, + DeleteFunctionRequest, + EventTrigger, + FailurePolicy, + GenerateDownloadUrlRequest, + GenerateDownloadUrlResponse, + GenerateUploadUrlRequest, + GenerateUploadUrlResponse, + GetFunctionRequest, + HttpsTrigger, + ListFunctionsRequest, + ListFunctionsResponse, + SecretEnvVar, + SecretVolume, + SourceRepository, + UpdateFunctionRequest, +) +from google.cloud.functions_v1.types.operations import ( + OperationMetadataV1, + OperationType, ) - -from google.cloud.functions_v1.types.functions import CallFunctionRequest -from google.cloud.functions_v1.types.functions import CallFunctionResponse -from google.cloud.functions_v1.types.functions import CloudFunction -from google.cloud.functions_v1.types.functions import CreateFunctionRequest -from google.cloud.functions_v1.types.functions import DeleteFunctionRequest -from google.cloud.functions_v1.types.functions import EventTrigger -from google.cloud.functions_v1.types.functions import FailurePolicy -from google.cloud.functions_v1.types.functions import GenerateDownloadUrlRequest -from google.cloud.functions_v1.types.functions import GenerateDownloadUrlResponse -from google.cloud.functions_v1.types.functions import GenerateUploadUrlRequest -from google.cloud.functions_v1.types.functions import GenerateUploadUrlResponse -from google.cloud.functions_v1.types.functions import GetFunctionRequest -from google.cloud.functions_v1.types.functions import HttpsTrigger -from google.cloud.functions_v1.types.functions import ListFunctionsRequest -from google.cloud.functions_v1.types.functions import ListFunctionsResponse -from google.cloud.functions_v1.types.functions import SecretEnvVar -from google.cloud.functions_v1.types.functions import SecretVolume -from google.cloud.functions_v1.types.functions import SourceRepository -from google.cloud.functions_v1.types.functions import UpdateFunctionRequest -from google.cloud.functions_v1.types.functions import CloudFunctionStatus -from google.cloud.functions_v1.types.operations import OperationMetadataV1 -from google.cloud.functions_v1.types.operations import OperationType __all__ = ( "CloudFunctionsServiceClient", diff --git a/google/cloud/functions_v1/__init__.py b/google/cloud/functions_v1/__init__.py index c1a4284..902ef58 100644 --- a/google/cloud/functions_v1/__init__.py +++ b/google/cloud/functions_v1/__init__.py @@ -14,31 +14,33 @@ # limitations under the License. # -from .services.cloud_functions_service import CloudFunctionsServiceClient -from .services.cloud_functions_service import CloudFunctionsServiceAsyncClient - -from .types.functions import CallFunctionRequest -from .types.functions import CallFunctionResponse -from .types.functions import CloudFunction -from .types.functions import CreateFunctionRequest -from .types.functions import DeleteFunctionRequest -from .types.functions import EventTrigger -from .types.functions import FailurePolicy -from .types.functions import GenerateDownloadUrlRequest -from .types.functions import GenerateDownloadUrlResponse -from .types.functions import GenerateUploadUrlRequest -from .types.functions import GenerateUploadUrlResponse -from .types.functions import GetFunctionRequest -from .types.functions import HttpsTrigger -from .types.functions import ListFunctionsRequest -from .types.functions import ListFunctionsResponse -from .types.functions import SecretEnvVar -from .types.functions import SecretVolume -from .types.functions import SourceRepository -from .types.functions import UpdateFunctionRequest -from .types.functions import CloudFunctionStatus -from .types.operations import OperationMetadataV1 -from .types.operations import OperationType +from .services.cloud_functions_service import ( + CloudFunctionsServiceAsyncClient, + CloudFunctionsServiceClient, +) +from .types.functions import ( + CallFunctionRequest, + CallFunctionResponse, + CloudFunction, + CloudFunctionStatus, + CreateFunctionRequest, + DeleteFunctionRequest, + EventTrigger, + FailurePolicy, + GenerateDownloadUrlRequest, + GenerateDownloadUrlResponse, + GenerateUploadUrlRequest, + GenerateUploadUrlResponse, + GetFunctionRequest, + HttpsTrigger, + ListFunctionsRequest, + ListFunctionsResponse, + SecretEnvVar, + SecretVolume, + SourceRepository, + UpdateFunctionRequest, +) +from .types.operations import OperationMetadataV1, OperationType __all__ = ( "CloudFunctionsServiceAsyncClient", diff --git a/google/cloud/functions_v1/services/cloud_functions_service/__init__.py b/google/cloud/functions_v1/services/cloud_functions_service/__init__.py index 371f3d6..3bba6d0 100644 --- a/google/cloud/functions_v1/services/cloud_functions_service/__init__.py +++ b/google/cloud/functions_v1/services/cloud_functions_service/__init__.py @@ -13,8 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .client import CloudFunctionsServiceClient from .async_client import CloudFunctionsServiceAsyncClient +from .client import CloudFunctionsServiceClient __all__ = ( "CloudFunctionsServiceClient", diff --git a/google/cloud/functions_v1/services/cloud_functions_service/async_client.py b/google/cloud/functions_v1/services/cloud_functions_service/async_client.py index 3045479..80255e8 100644 --- a/google/cloud/functions_v1/services/cloud_functions_service/async_client.py +++ b/google/cloud/functions_v1/services/cloud_functions_service/async_client.py @@ -17,14 +17,14 @@ import functools import re from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -import pkg_resources -from google.api_core.client_options import ClientOptions from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries +from google.api_core.client_options import ClientOptions from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +import pkg_resources try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] @@ -33,17 +33,18 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore -from google.cloud.functions_v1.services.cloud_functions_service import pagers -from google.cloud.functions_v1.types import functions -from google.cloud.functions_v1.types import operations from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import duration_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import CloudFunctionsServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import CloudFunctionsServiceGrpcAsyncIOTransport + +from google.cloud.functions_v1.services.cloud_functions_service import pagers +from google.cloud.functions_v1.types import functions, operations + from .client import CloudFunctionsServiceClient +from .transports.base import DEFAULT_CLIENT_INFO, CloudFunctionsServiceTransport +from .transports.grpc_asyncio import CloudFunctionsServiceGrpcAsyncIOTransport class CloudFunctionsServiceAsyncClient: diff --git a/google/cloud/functions_v1/services/cloud_functions_service/client.py b/google/cloud/functions_v1/services/cloud_functions_service/client.py index 5ed39bf..03ea8a3 100644 --- a/google/cloud/functions_v1/services/cloud_functions_service/client.py +++ b/google/cloud/functions_v1/services/cloud_functions_service/client.py @@ -17,17 +17,17 @@ import os import re from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -import pkg_resources from google.api_core import client_options as client_options_lib from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.auth.transport import mtls # type: ignore 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 +import pkg_resources try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] @@ -36,15 +36,16 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore -from google.cloud.functions_v1.services.cloud_functions_service import pagers -from google.cloud.functions_v1.types import functions -from google.cloud.functions_v1.types import operations from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import duration_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import CloudFunctionsServiceTransport, DEFAULT_CLIENT_INFO + +from google.cloud.functions_v1.services.cloud_functions_service import pagers +from google.cloud.functions_v1.types import functions, operations + +from .transports.base import DEFAULT_CLIENT_INFO, CloudFunctionsServiceTransport from .transports.grpc import CloudFunctionsServiceGrpcTransport from .transports.grpc_asyncio import CloudFunctionsServiceGrpcAsyncIOTransport diff --git a/google/cloud/functions_v1/services/cloud_functions_service/pagers.py b/google/cloud/functions_v1/services/cloud_functions_service/pagers.py index 0344a58..e64aea2 100644 --- a/google/cloud/functions_v1/services/cloud_functions_service/pagers.py +++ b/google/cloud/functions_v1/services/cloud_functions_service/pagers.py @@ -18,10 +18,10 @@ AsyncIterator, Awaitable, Callable, + Iterator, + Optional, Sequence, Tuple, - Optional, - Iterator, ) from google.cloud.functions_v1.types import functions diff --git a/google/cloud/functions_v1/services/cloud_functions_service/transports/__init__.py b/google/cloud/functions_v1/services/cloud_functions_service/transports/__init__.py index b928625..dfeeaf8 100644 --- a/google/cloud/functions_v1/services/cloud_functions_service/transports/__init__.py +++ b/google/cloud/functions_v1/services/cloud_functions_service/transports/__init__.py @@ -20,7 +20,6 @@ from .grpc import CloudFunctionsServiceGrpcTransport from .grpc_asyncio import CloudFunctionsServiceGrpcAsyncIOTransport - # Compile a registry of transports. _transport_registry = ( OrderedDict() diff --git a/google/cloud/functions_v1/services/cloud_functions_service/transports/base.py b/google/cloud/functions_v1/services/cloud_functions_service/transports/base.py index 223c087..7d8f267 100644 --- a/google/cloud/functions_v1/services/cloud_functions_service/transports/base.py +++ b/google/cloud/functions_v1/services/cloud_functions_service/transports/base.py @@ -15,21 +15,20 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import pkg_resources -import google.auth # type: ignore import google.api_core from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 +from google.api_core import gapic_v1, operations_v1 from google.api_core import retry as retries -from google.api_core import operations_v1 +import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.functions_v1.types import functions 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.oauth2 import service_account # type: ignore +import pkg_resources + +from google.cloud.functions_v1.types import functions try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/functions_v1/services/cloud_functions_service/transports/grpc.py b/google/cloud/functions_v1/services/cloud_functions_service/transports/grpc.py index 405123c..787b6e7 100644 --- a/google/cloud/functions_v1/services/cloud_functions_service/transports/grpc.py +++ b/google/cloud/functions_v1/services/cloud_functions_service/transports/grpc.py @@ -13,23 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import warnings from typing import Callable, Dict, Optional, Sequence, Tuple, Union +import warnings -from google.api_core import grpc_helpers -from google.api_core import operations_v1 -from google.api_core import gapic_v1 +from google.api_core import gapic_v1, grpc_helpers, operations_v1 import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore - -from google.cloud.functions_v1.types import functions 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 .base import CloudFunctionsServiceTransport, DEFAULT_CLIENT_INFO +import grpc # type: ignore + +from google.cloud.functions_v1.types import functions + +from .base import DEFAULT_CLIENT_INFO, CloudFunctionsServiceTransport class CloudFunctionsServiceGrpcTransport(CloudFunctionsServiceTransport): diff --git a/google/cloud/functions_v1/services/cloud_functions_service/transports/grpc_asyncio.py b/google/cloud/functions_v1/services/cloud_functions_service/transports/grpc_asyncio.py index 49cef15..96fdade 100644 --- a/google/cloud/functions_v1/services/cloud_functions_service/transports/grpc_asyncio.py +++ b/google/cloud/functions_v1/services/cloud_functions_service/transports/grpc_asyncio.py @@ -13,23 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import warnings from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union +import warnings -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async -from google.api_core import operations_v1 +from google.api_core import gapic_v1, grpc_helpers_async, operations_v1 from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # 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 import grpc # type: ignore from grpc.experimental import aio # type: ignore from google.cloud.functions_v1.types import functions -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 .base import CloudFunctionsServiceTransport, DEFAULT_CLIENT_INFO + +from .base import DEFAULT_CLIENT_INFO, CloudFunctionsServiceTransport from .grpc import CloudFunctionsServiceGrpcTransport diff --git a/google/cloud/functions_v1/types/__init__.py b/google/cloud/functions_v1/types/__init__.py index e6ddf63..ffcff26 100644 --- a/google/cloud/functions_v1/types/__init__.py +++ b/google/cloud/functions_v1/types/__init__.py @@ -17,6 +17,7 @@ CallFunctionRequest, CallFunctionResponse, CloudFunction, + CloudFunctionStatus, CreateFunctionRequest, DeleteFunctionRequest, EventTrigger, @@ -33,12 +34,8 @@ SecretVolume, SourceRepository, UpdateFunctionRequest, - CloudFunctionStatus, -) -from .operations import ( - OperationMetadataV1, - OperationType, ) +from .operations import OperationMetadataV1, OperationType __all__ = ( "CallFunctionRequest", diff --git a/google/cloud/functions_v1/types/functions.py b/google/cloud/functions_v1/types/functions.py index a2173b1..d31c3a3 100644 --- a/google/cloud/functions_v1/types/functions.py +++ b/google/cloud/functions_v1/types/functions.py @@ -13,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import proto # type: ignore - from google.protobuf import duration_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore - +import proto # type: ignore __protobuf__ = proto.module( package="google.cloud.functions.v1", diff --git a/google/cloud/functions_v1/types/operations.py b/google/cloud/functions_v1/types/operations.py index 221279b..5fa15fa 100644 --- a/google/cloud/functions_v1/types/operations.py +++ b/google/cloud/functions_v1/types/operations.py @@ -13,11 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import proto # type: ignore - from google.protobuf import any_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore - +import proto # type: ignore __protobuf__ = proto.module( package="google.cloud.functions.v1", diff --git a/noxfile.py b/noxfile.py index 6ee5e8a..7c1742d 100644 --- a/noxfile.py +++ b/noxfile.py @@ -17,6 +17,7 @@ # Generated by synthtool. DO NOT EDIT! from __future__ import absolute_import + import os import pathlib import shutil @@ -25,7 +26,8 @@ import nox BLACK_VERSION = "black==22.3.0" -BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] +ISORT_VERSION = "isort==5.10.1" +LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] DEFAULT_PYTHON_VERSION = "3.8" @@ -83,7 +85,7 @@ def lint(session): session.run( "black", "--check", - *BLACK_PATHS, + *LINT_PATHS, ) session.run("flake8", "google", "tests") @@ -94,7 +96,27 @@ def blacken(session): session.install(BLACK_VERSION) session.run( "black", - *BLACK_PATHS, + *LINT_PATHS, + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def format(session): + """ + Run isort to sort imports. Then run black + to format code to uniform standard. + """ + session.install(BLACK_VERSION, ISORT_VERSION) + # Use the --fss option to sort imports using strict alphabetical order. + # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections + session.run( + "isort", + "--fss", + *LINT_PATHS, + ) + session.run( + "black", + *LINT_PATHS, ) diff --git a/setup.py b/setup.py index b97cda3..510a998 100644 --- a/setup.py +++ b/setup.py @@ -17,6 +17,7 @@ import io import os + import setuptools # type: ignore version = "1.6.0" diff --git a/tests/unit/gapic/functions_v1/test_cloud_functions_service.py b/tests/unit/gapic/functions_v1/test_cloud_functions_service.py index 45a6930..d4606a4 100644 --- a/tests/unit/gapic/functions_v1/test_cloud_functions_service.py +++ b/tests/unit/gapic/functions_v1/test_cloud_functions_service.py @@ -13,38 +13,24 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import os -import mock - -import grpc -from grpc.experimental import aio import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule - +import os +from google.api_core import ( + future, + gapic_v1, + grpc_helpers, + grpc_helpers_async, + operation, + operations_v1, + path_template, +) from google.api_core import client_options from google.api_core import exceptions as core_exceptions -from google.api_core import future -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import operation from google.api_core import operation_async # type: ignore -from google.api_core import operations_v1 -from google.api_core import path_template +import google.auth from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError -from google.cloud.functions_v1.services.cloud_functions_service import ( - CloudFunctionsServiceAsyncClient, -) -from google.cloud.functions_v1.services.cloud_functions_service import ( - CloudFunctionsServiceClient, -) -from google.cloud.functions_v1.services.cloud_functions_service import pagers -from google.cloud.functions_v1.services.cloud_functions_service import transports -from google.cloud.functions_v1.types import functions -from google.cloud.functions_v1.types import operations from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import options_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore @@ -54,7 +40,19 @@ from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore from google.type import expr_pb2 # type: ignore -import google.auth +import grpc +from grpc.experimental import aio +import mock +from proto.marshal.rules.dates import DurationRule, TimestampRule +import pytest + +from google.cloud.functions_v1.services.cloud_functions_service import ( + CloudFunctionsServiceAsyncClient, + CloudFunctionsServiceClient, + pagers, + transports, +) +from google.cloud.functions_v1.types import functions, operations def client_cert_source_callback():