Skip to content

Commit

Permalink
fix(translate): add py2 deprecation warning; bump copyright year to 2…
Browse files Browse the repository at this point in the history
…020; add 3.8 unit tests (via synth) (#9943)
  • Loading branch information
yoshi-automation committed Jan 30, 2020
1 parent ca7f003 commit 79d8e00
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 47 deletions.
2 changes: 1 addition & 1 deletion translate/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.
Expand Down
13 changes: 12 additions & 1 deletion translate/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.
Expand All @@ -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__

Expand Down
@@ -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.
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
@@ -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.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion translate/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.
Expand Down
13 changes: 12 additions & 1 deletion translate/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.
Expand All @@ -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__

Expand Down
@@ -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.
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
@@ -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.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion translate/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.
Expand Down
2 changes: 1 addition & 1 deletion translate/noxfile.py
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions translate/synth.metadata
@@ -1,5 +1,5 @@
{
"updateTime": "2019-11-19T13:38:48.307240Z",
"updateTime": "2019-12-07T13:29:54.673468Z",
"sources": [
{
"generator": {
Expand All @@ -12,8 +12,8 @@
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "d8dd7fe8d5304f7bd1c52207703d7f27d5328c5a",
"internalRef": "281088257"
"sha": "a4adac3a12aca6e3a792c9c35ee850435fe7cf7e",
"internalRef": "284277770"
}
},
{
Expand Down
@@ -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.
Expand Down
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions translate/tests/unit/v2/test__http.py
Expand Up @@ -80,15 +80,15 @@ 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(
data=req_data,
headers=expected_headers,
method="GET",
url=expected_uri,
timeout=None,
timeout=60,
)

0 comments on commit 79d8e00

Please sign in to comment.