From b57f09a5f804daca1a96918a29746f24ae7bc4a5 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Wed, 29 Jan 2020 18:55:59 -0800 Subject: [PATCH] fix(translate): add py2 deprecation warning; bump copyright year to 2020; add 3.8 unit tests (via synth) (#9943) --- google/cloud/translate.py | 2 +- google/cloud/translate_v3/__init__.py | 13 ++++++++++++- .../gapic/translation_service_client.py | 16 +++------------- .../translation_service_grpc_transport.py | 2 +- .../proto/translation_service_pb2.py | 4 ++-- google/cloud/translate_v3/types.py | 2 +- google/cloud/translate_v3beta1/__init__.py | 13 ++++++++++++- .../gapic/translation_service_client.py | 16 +++------------- .../translation_service_grpc_transport.py | 2 +- .../proto/translation_service_pb2.py | 8 ++++---- google/cloud/translate_v3beta1/types.py | 2 +- noxfile.py | 2 +- synth.metadata | 6 +++--- .../v3/test_translation_service_client_v3.py | 2 +- .../test_translation_service_client_v3beta1.py | 2 +- tests/unit/v2/test__http.py | 4 ++-- 16 files changed, 49 insertions(+), 47 deletions(-) diff --git a/google/cloud/translate.py b/google/cloud/translate.py index 27d23f13..541da1b5 100644 --- a/google/cloud/translate.py +++ b/google/cloud/translate.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/translate_v3/__init__.py b/google/cloud/translate_v3/__init__.py index f4e61721..dec3a565 100644 --- a/google/cloud/translate_v3/__init__.py +++ b/google/cloud/translate_v3/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,11 +16,22 @@ from __future__ import absolute_import +import sys +import warnings from google.cloud.translate_v3 import types from google.cloud.translate_v3.gapic import translation_service_client +if sys.version_info[:2] == (2, 7): + message = ( + "A future version of this library will drop support for Python 2.7." + "More details about Python 2 support for Google Cloud Client Libraries" + "can be found at https://cloud.google.com/python/docs/python2-sunset/" + ) + warnings.warn(message, DeprecationWarning) + + class TranslationServiceClient(translation_service_client.TranslationServiceClient): __doc__ = translation_service_client.TranslationServiceClient.__doc__ diff --git a/google/cloud/translate_v3/gapic/translation_service_client.py b/google/cloud/translate_v3/gapic/translation_service_client.py index d59c9eaa..1540f9c7 100644 --- a/google/cloud/translate_v3/gapic/translation_service_client.py +++ b/google/cloud/translate_v3/gapic/translation_service_client.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -80,12 +80,7 @@ def from_service_account_file(cls, filename, *args, **kwargs): @classmethod def glossary_path(cls, project, location, glossary): - """DEPRECATED. Return a fully-qualified glossary string.""" - warnings.warn( - "Resource name helper functions are deprecated.", - PendingDeprecationWarning, - stacklevel=1, - ) + """Return a fully-qualified glossary string.""" return google.api_core.path_template.expand( "projects/{project}/locations/{location}/glossaries/{glossary}", project=project, @@ -95,12 +90,7 @@ def glossary_path(cls, project, location, glossary): @classmethod def location_path(cls, project, location): - """DEPRECATED. Return a fully-qualified location string.""" - warnings.warn( - "Resource name helper functions are deprecated.", - PendingDeprecationWarning, - stacklevel=1, - ) + """Return a fully-qualified location string.""" return google.api_core.path_template.expand( "projects/{project}/locations/{location}", project=project, diff --git a/google/cloud/translate_v3/gapic/transports/translation_service_grpc_transport.py b/google/cloud/translate_v3/gapic/transports/translation_service_grpc_transport.py index ed038e37..45c59003 100644 --- a/google/cloud/translate_v3/gapic/transports/translation_service_grpc_transport.py +++ b/google/cloud/translate_v3/gapic/transports/translation_service_grpc_transport.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/translate_v3/proto/translation_service_pb2.py b/google/cloud/translate_v3/proto/translation_service_pb2.py index 7bc7e15d..be22c28c 100644 --- a/google/cloud/translate_v3/proto/translation_service_pb2.py +++ b/google/cloud/translate_v3/proto/translation_service_pb2.py @@ -2796,8 +2796,8 @@ dict( DESCRIPTOR=_TRANSLATETEXTGLOSSARYCONFIG, __module__="google.cloud.translation_v3.proto.translation_service_pb2", - __doc__="""Configures which glossary should be used for a specific target language, - and defines options for applying that glossary. + __doc__="""Configures which glossary should be used for a specific + target language, and defines options for applying that glossary. Attributes: diff --git a/google/cloud/translate_v3/types.py b/google/cloud/translate_v3/types.py index 14c494ad..b1e9aad3 100644 --- a/google/cloud/translate_v3/types.py +++ b/google/cloud/translate_v3/types.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/translate_v3beta1/__init__.py b/google/cloud/translate_v3beta1/__init__.py index 397226dd..7323f3e3 100644 --- a/google/cloud/translate_v3beta1/__init__.py +++ b/google/cloud/translate_v3beta1/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,11 +16,22 @@ from __future__ import absolute_import +import sys +import warnings from google.cloud.translate_v3beta1 import types from google.cloud.translate_v3beta1.gapic import translation_service_client +if sys.version_info[:2] == (2, 7): + message = ( + "A future version of this library will drop support for Python 2.7." + "More details about Python 2 support for Google Cloud Client Libraries" + "can be found at https://cloud.google.com/python/docs/python2-sunset/" + ) + warnings.warn(message, DeprecationWarning) + + class TranslationServiceClient(translation_service_client.TranslationServiceClient): __doc__ = translation_service_client.TranslationServiceClient.__doc__ diff --git a/google/cloud/translate_v3beta1/gapic/translation_service_client.py b/google/cloud/translate_v3beta1/gapic/translation_service_client.py index 2d5ead5c..ed8de5d6 100644 --- a/google/cloud/translate_v3beta1/gapic/translation_service_client.py +++ b/google/cloud/translate_v3beta1/gapic/translation_service_client.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -80,12 +80,7 @@ def from_service_account_file(cls, filename, *args, **kwargs): @classmethod def glossary_path(cls, project, location, glossary): - """DEPRECATED. Return a fully-qualified glossary string.""" - warnings.warn( - "Resource name helper functions are deprecated.", - PendingDeprecationWarning, - stacklevel=1, - ) + """Return a fully-qualified glossary string.""" return google.api_core.path_template.expand( "projects/{project}/locations/{location}/glossaries/{glossary}", project=project, @@ -95,12 +90,7 @@ def glossary_path(cls, project, location, glossary): @classmethod def location_path(cls, project, location): - """DEPRECATED. Return a fully-qualified location string.""" - warnings.warn( - "Resource name helper functions are deprecated.", - PendingDeprecationWarning, - stacklevel=1, - ) + """Return a fully-qualified location string.""" return google.api_core.path_template.expand( "projects/{project}/locations/{location}", project=project, diff --git a/google/cloud/translate_v3beta1/gapic/transports/translation_service_grpc_transport.py b/google/cloud/translate_v3beta1/gapic/transports/translation_service_grpc_transport.py index 46f9c525..d3aeadc9 100644 --- a/google/cloud/translate_v3beta1/gapic/transports/translation_service_grpc_transport.py +++ b/google/cloud/translate_v3beta1/gapic/transports/translation_service_grpc_transport.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/google/cloud/translate_v3beta1/proto/translation_service_pb2.py b/google/cloud/translate_v3beta1/proto/translation_service_pb2.py index 8a423d69..b58cc600 100644 --- a/google/cloud/translate_v3beta1/proto/translation_service_pb2.py +++ b/google/cloud/translate_v3beta1/proto/translation_service_pb2.py @@ -2796,8 +2796,8 @@ dict( DESCRIPTOR=_TRANSLATETEXTGLOSSARYCONFIG, __module__="google.cloud.translation_v3beta1.proto.translation_service_pb2", - __doc__="""Configures which glossary should be used for a specific target language, - and defines options for applying that glossary. + __doc__="""Configures which glossary should be used for a specific + target language, and defines options for applying that glossary. Attributes: @@ -3109,8 +3109,8 @@ dict( DESCRIPTOR=_SUPPORTEDLANGUAGE, __module__="google.cloud.translation_v3beta1.proto.translation_service_pb2", - __doc__="""A single supported language response corresponds to information related - to one supported language. + __doc__="""A single supported language response corresponds to + information related to one supported language. Attributes: diff --git a/google/cloud/translate_v3beta1/types.py b/google/cloud/translate_v3beta1/types.py index 41868ccf..335149a6 100644 --- a/google/cloud/translate_v3beta1/types.py +++ b/google/cloud/translate_v3beta1/types.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/noxfile.py b/noxfile.py index a2eefbb6..7949a4e3 100644 --- a/noxfile.py +++ b/noxfile.py @@ -86,7 +86,7 @@ def default(session): ) -@nox.session(python=["2.7", "3.5", "3.6", "3.7"]) +@nox.session(python=["2.7", "3.5", "3.6", "3.7", "3.8"]) def unit(session): """Run the unit test suite.""" default(session) diff --git a/synth.metadata b/synth.metadata index 8cc62e79..e9630fe8 100644 --- a/synth.metadata +++ b/synth.metadata @@ -1,5 +1,5 @@ { - "updateTime": "2019-11-19T13:38:48.307240Z", + "updateTime": "2019-12-07T13:29:54.673468Z", "sources": [ { "generator": { @@ -12,8 +12,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "d8dd7fe8d5304f7bd1c52207703d7f27d5328c5a", - "internalRef": "281088257" + "sha": "a4adac3a12aca6e3a792c9c35ee850435fe7cf7e", + "internalRef": "284277770" } }, { diff --git a/tests/unit/gapic/v3/test_translation_service_client_v3.py b/tests/unit/gapic/v3/test_translation_service_client_v3.py index 16180aac..65b0d020 100644 --- a/tests/unit/gapic/v3/test_translation_service_client_v3.py +++ b/tests/unit/gapic/v3/test_translation_service_client_v3.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/unit/gapic/v3beta1/test_translation_service_client_v3beta1.py b/tests/unit/gapic/v3beta1/test_translation_service_client_v3beta1.py index 6bd32d82..fa2bccc2 100644 --- a/tests/unit/gapic/v3beta1/test_translation_service_client_v3beta1.py +++ b/tests/unit/gapic/v3beta1/test_translation_service_client_v3beta1.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2019 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests/unit/v2/test__http.py b/tests/unit/v2/test__http.py index b696207e..d2c3b9b6 100644 --- a/tests/unit/v2/test__http.py +++ b/tests/unit/v2/test__http.py @@ -80,9 +80,9 @@ def test_extra_headers(self): self.assertEqual(result, data) expected_headers = { - "Accept-Encoding": "gzip", base_http.CLIENT_INFO_HEADER: conn.user_agent, "User-Agent": conn.user_agent, + "Accept-Encoding": "gzip", } expected_uri = conn.build_api_url("/rainbow") http.request.assert_called_once_with( @@ -90,5 +90,5 @@ def test_extra_headers(self): headers=expected_headers, method="GET", url=expected_uri, - timeout=None, + timeout=60, )