From 90b2646b4c975b5c9c07e7ccf3477ae9f7a70263 Mon Sep 17 00:00:00 2001 From: Takashi Matsuo Date: Wed, 13 May 2020 01:07:59 +0000 Subject: [PATCH] chore: some lint fixes --- .../transcribe_streaming_infinite.py | 2 +- storage/api/crud_object_test.py | 4 ++- storage/cloud-client/acl_test.py | 14 +++++----- storage/cloud-client/bucket_lock_test.py | 16 ++++++------ storage/cloud-client/encryption_test.py | 3 ++- storage/cloud-client/hmac_samples_test.py | 2 +- storage/cloud-client/iam_test.py | 12 +++++---- storage/cloud-client/requester_pays_test.py | 2 +- storage/cloud-client/snippets_test.py | 26 +++++++++---------- .../cloud-client/storage_add_bucket_label.py | 7 +++-- .../storage_download_encrypted_file.py | 6 +++-- .../storage_generate_signed_post_policy_v4.py | 7 +++-- .../storage_generate_signed_url_v2.py | 6 +++-- .../storage_generate_signed_url_v4.py | 7 +++-- .../storage_generate_upload_signed_url_v4.py | 7 +++-- .../cloud-client/storage_get_bucket_labels.py | 7 +++-- .../storage_get_bucket_metadata.py | 7 +++-- .../storage_remove_bucket_label.py | 7 +++-- .../storage_rotate_encryption_key.py | 7 +++-- .../storage_upload_encrypted_file.py | 7 +++-- .../uniform_bucket_level_access_test.py | 3 +-- storage/signed_urls/generate_signed_urls.py | 8 +++--- tables/automl/dataset_test.py | 6 ++--- tables/automl/model_test.py | 4 +-- tables/automl/predict_test.py | 3 ++- texttospeech/cloud-client/ssml_addresses.py | 3 ++- .../cloud-client/ssml_addresses_test.py | 5 ++-- trace/cloud-trace-demo-app/app/app.py | 13 +++++----- trace/cloud-trace-demo-app/app/app_test.py | 5 ++-- trace/trace-python-sample/main_test.py | 1 + 30 files changed, 122 insertions(+), 85 deletions(-) diff --git a/speech/microphone/transcribe_streaming_infinite.py b/speech/microphone/transcribe_streaming_infinite.py index f45b82cf90be..759842b476d0 100644 --- a/speech/microphone/transcribe_streaming_infinite.py +++ b/speech/microphone/transcribe_streaming_infinite.py @@ -28,9 +28,9 @@ # [START speech_transcribe_infinite_streaming] -import time import re import sys +import time from google.cloud import speech import pyaudio diff --git a/storage/api/crud_object_test.py b/storage/api/crud_object_test.py index 1c57ed11e544..97d7b849687f 100644 --- a/storage/api/crud_object_test.py +++ b/storage/api/crud_object_test.py @@ -15,9 +15,11 @@ import re import tempfile -from crud_object import main import pytest +from crud_object import main + + BUCKET = os.environ['CLOUD_STORAGE_BUCKET'] diff --git a/storage/cloud-client/acl_test.py b/storage/cloud-client/acl_test.py index 157f399caa6c..469d364ce300 100644 --- a/storage/cloud-client/acl_test.py +++ b/storage/cloud-client/acl_test.py @@ -17,16 +17,16 @@ from google.cloud import storage import pytest -import storage_remove_file_owner -import storage_remove_bucket_owner -import storage_remove_bucket_default_owner -import storage_add_file_owner -import storage_add_bucket_owner import storage_add_bucket_default_owner -import storage_print_bucket_acl_for_user +import storage_add_bucket_owner +import storage_add_file_owner import storage_print_bucket_acl -import storage_print_file_acl_for_user +import storage_print_bucket_acl_for_user import storage_print_file_acl +import storage_print_file_acl_for_user +import storage_remove_bucket_default_owner +import storage_remove_bucket_owner +import storage_remove_file_owner # Typically we'd use a @example.com address, but GCS requires a real Google # account. diff --git a/storage/cloud-client/bucket_lock_test.py b/storage/cloud-client/bucket_lock_test.py index 98a95835cb02..99c5e1e5633d 100644 --- a/storage/cloud-client/bucket_lock_test.py +++ b/storage/cloud-client/bucket_lock_test.py @@ -16,20 +16,20 @@ import uuid from google.cloud import storage - import pytest -import storage_set_retention_policy -import storage_lock_retention_policy -import storage_get_retention_policy -import storage_get_default_event_based_hold -import storage_enable_default_event_based_hold import storage_disable_default_event_based_hold -import storage_set_event_based_hold +import storage_enable_default_event_based_hold +import storage_get_default_event_based_hold +import storage_get_retention_policy +import storage_lock_retention_policy import storage_release_event_based_hold -import storage_set_temporary_hold import storage_release_temporary_hold import storage_remove_retention_policy +import storage_set_event_based_hold +import storage_set_retention_policy +import storage_set_temporary_hold + BLOB_NAME = "storage_snippets_test_sigil" BLOB_CONTENT = "Hello, is it me you're looking for?" diff --git a/storage/cloud-client/encryption_test.py b/storage/cloud-client/encryption_test.py index 3f85867a4d88..5f24bb7eb538 100644 --- a/storage/cloud-client/encryption_test.py +++ b/storage/cloud-client/encryption_test.py @@ -24,8 +24,9 @@ import storage_download_encrypted_file import storage_generate_encryption_key -import storage_upload_encrypted_file import storage_rotate_encryption_key +import storage_upload_encrypted_file + BUCKET = os.environ["CLOUD_STORAGE_BUCKET"] diff --git a/storage/cloud-client/hmac_samples_test.py b/storage/cloud-client/hmac_samples_test.py index 9712ed159443..f9fcb7509931 100644 --- a/storage/cloud-client/hmac_samples_test.py +++ b/storage/cloud-client/hmac_samples_test.py @@ -20,8 +20,8 @@ import os -from google.cloud import storage import google.api_core.exceptions +from google.cloud import storage import pytest import storage_activate_hmac_key diff --git a/storage/cloud-client/iam_test.py b/storage/cloud-client/iam_test.py index ec130da0fe8a..fe7aa72025c6 100644 --- a/storage/cloud-client/iam_test.py +++ b/storage/cloud-client/iam_test.py @@ -12,17 +12,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -from google.cloud import storage -import pytest import re import time import uuid -import storage_remove_bucket_iam_member -import storage_add_bucket_iam_member +from google.cloud import storage +import pytest + import storage_add_bucket_conditional_iam_binding -import storage_view_bucket_iam_members +import storage_add_bucket_iam_member import storage_remove_bucket_conditional_iam_binding +import storage_remove_bucket_iam_member +import storage_view_bucket_iam_members + MEMBER = "group:dpebot@google.com" ROLE = "roles/storage.legacyBucketReader" diff --git a/storage/cloud-client/requester_pays_test.py b/storage/cloud-client/requester_pays_test.py index f034ad028382..7511be739b3f 100644 --- a/storage/cloud-client/requester_pays_test.py +++ b/storage/cloud-client/requester_pays_test.py @@ -19,8 +19,8 @@ import pytest import storage_disable_requester_pays -import storage_enable_requester_pays import storage_download_file_requester_pays +import storage_enable_requester_pays import storage_get_requester_pays_status diff --git a/storage/cloud-client/snippets_test.py b/storage/cloud-client/snippets_test.py index 443f07669589..678b6a6b0b50 100644 --- a/storage/cloud-client/snippets_test.py +++ b/storage/cloud-client/snippets_test.py @@ -22,31 +22,31 @@ import pytest import requests -import storage_copy_file import storage_add_bucket_label +import storage_copy_file import storage_delete_file +import storage_disable_bucket_lifecycle_management +import storage_disable_versioning import storage_download_file +import storage_enable_bucket_lifecycle_management +import storage_enable_versioning +import storage_generate_signed_post_policy_v4 +import storage_generate_signed_url_v2 +import storage_generate_signed_url_v4 +import storage_generate_upload_signed_url_v4 import storage_get_bucket_labels import storage_get_bucket_metadata import storage_get_metadata -import storage_set_metadata import storage_list_buckets -import storage_list_files_with_prefix import storage_list_files +import storage_list_files_with_prefix import storage_make_public -import storage_remove_bucket_label import storage_move_file +import storage_remove_bucket_label +import storage_set_bucket_default_kms_key +import storage_set_metadata import storage_upload_file import storage_upload_with_kms_key -import storage_generate_signed_url_v2 -import storage_generate_signed_url_v4 -import storage_generate_upload_signed_url_v4 -import storage_generate_signed_post_policy_v4 -import storage_set_bucket_default_kms_key -import storage_enable_versioning -import storage_disable_versioning -import storage_enable_bucket_lifecycle_management -import storage_disable_bucket_lifecycle_management KMS_KEY = os.environ["CLOUD_KMS_KEY"] diff --git a/storage/cloud-client/storage_add_bucket_label.py b/storage/cloud-client/storage_add_bucket_label.py index a021036c6a04..8ae8fe1f407b 100644 --- a/storage/cloud-client/storage_add_bucket_label.py +++ b/storage/cloud-client/storage_add_bucket_label.py @@ -14,11 +14,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys # [START storage_add_bucket_label] -from google.cloud import storage import pprint +# [END storage_add_bucket_label] +import sys +# [START storage_add_bucket_label] + +from google.cloud import storage def add_bucket_label(bucket_name): diff --git a/storage/cloud-client/storage_download_encrypted_file.py b/storage/cloud-client/storage_download_encrypted_file.py index c0b3ad560b07..ac7071fbefb5 100644 --- a/storage/cloud-client/storage_download_encrypted_file.py +++ b/storage/cloud-client/storage_download_encrypted_file.py @@ -14,11 +14,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +# [START storage_download_encrypted_file] +import base64 +# [END storage_download_encrypted_file] import sys - # [START storage_download_encrypted_file] + from google.cloud import storage -import base64 def download_encrypted_blob( diff --git a/storage/cloud-client/storage_generate_signed_post_policy_v4.py b/storage/cloud-client/storage_generate_signed_post_policy_v4.py index 8f575745020d..8217714e2ed7 100644 --- a/storage/cloud-client/storage_generate_signed_post_policy_v4.py +++ b/storage/cloud-client/storage_generate_signed_post_policy_v4.py @@ -14,11 +14,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys # [START storage_generate_signed_post_policy_v4] -from google.cloud import storage import datetime +# [END storage_generate_signed_post_policy_v4] +import sys +# [START storage_generate_signed_post_policy_v4] + +from google.cloud import storage def generate_signed_post_policy_v4(bucket_name, blob_name): diff --git a/storage/cloud-client/storage_generate_signed_url_v2.py b/storage/cloud-client/storage_generate_signed_url_v2.py index d594e91adb37..abea3dd540b4 100644 --- a/storage/cloud-client/storage_generate_signed_url_v2.py +++ b/storage/cloud-client/storage_generate_signed_url_v2.py @@ -14,11 +14,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +# [START storage_generate_signed_url_v2] +import datetime +# [END storage_generate_signed_url_v2] import sys - # [START storage_generate_signed_url_v2] + from google.cloud import storage -import datetime def generate_signed_url(bucket_name, blob_name): diff --git a/storage/cloud-client/storage_generate_signed_url_v4.py b/storage/cloud-client/storage_generate_signed_url_v4.py index a6647e73b8f8..2a45b23e9be4 100644 --- a/storage/cloud-client/storage_generate_signed_url_v4.py +++ b/storage/cloud-client/storage_generate_signed_url_v4.py @@ -14,11 +14,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys # [START storage_generate_signed_url_v4] -from google.cloud import storage import datetime +# [END storage_generate_signed_url_v4] +import sys +# [START storage_generate_signed_url_v4] + +from google.cloud import storage def generate_download_signed_url_v4(bucket_name, blob_name): diff --git a/storage/cloud-client/storage_generate_upload_signed_url_v4.py b/storage/cloud-client/storage_generate_upload_signed_url_v4.py index 8dd4a8658895..dc1da88647f4 100644 --- a/storage/cloud-client/storage_generate_upload_signed_url_v4.py +++ b/storage/cloud-client/storage_generate_upload_signed_url_v4.py @@ -14,11 +14,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys # [START storage_generate_upload_signed_url_v4] -from google.cloud import storage import datetime +# [END storage_generate_upload_signed_url_v4] +import sys +# [START storage_generate_upload_signed_url_v4] + +from google.cloud import storage def generate_upload_signed_url_v4(bucket_name, blob_name): diff --git a/storage/cloud-client/storage_get_bucket_labels.py b/storage/cloud-client/storage_get_bucket_labels.py index 531fae22e051..b3bcd6208b8f 100644 --- a/storage/cloud-client/storage_get_bucket_labels.py +++ b/storage/cloud-client/storage_get_bucket_labels.py @@ -14,11 +14,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys # [START storage_get_bucket_labels] -from google.cloud import storage import pprint +# [END storage_get_bucket_labels] +import sys +# [START storage_get_bucket_labels] + +from google.cloud import storage def get_bucket_labels(bucket_name): diff --git a/storage/cloud-client/storage_get_bucket_metadata.py b/storage/cloud-client/storage_get_bucket_metadata.py index de724fc0ab95..0b17ce716de0 100644 --- a/storage/cloud-client/storage_get_bucket_metadata.py +++ b/storage/cloud-client/storage_get_bucket_metadata.py @@ -14,11 +14,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys # [START storage_get_bucket_metadata] -from google.cloud import storage import pprint +# [END storage_get_bucket_metadata] +import sys +# [START storage_get_bucket_metadata] + +from google.cloud import storage def bucket_metadata(bucket_name): diff --git a/storage/cloud-client/storage_remove_bucket_label.py b/storage/cloud-client/storage_remove_bucket_label.py index d39c03f24dec..58bbfef2d510 100644 --- a/storage/cloud-client/storage_remove_bucket_label.py +++ b/storage/cloud-client/storage_remove_bucket_label.py @@ -14,11 +14,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys # [START storage_remove_bucket_label] -from google.cloud import storage import pprint +# [END storage_remove_bucket_label] +import sys +# [START storage_remove_bucket_label] + +from google.cloud import storage def remove_bucket_label(bucket_name): diff --git a/storage/cloud-client/storage_rotate_encryption_key.py b/storage/cloud-client/storage_rotate_encryption_key.py index f66c8f8a0781..663ee47964b5 100644 --- a/storage/cloud-client/storage_rotate_encryption_key.py +++ b/storage/cloud-client/storage_rotate_encryption_key.py @@ -14,11 +14,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys # [START storage_rotate_encryption_key] -from google.cloud import storage import base64 +# [END storage_rotate_encryption_key] +import sys +# [START storage_rotate_encryption_key] + +from google.cloud import storage def rotate_encryption_key( diff --git a/storage/cloud-client/storage_upload_encrypted_file.py b/storage/cloud-client/storage_upload_encrypted_file.py index e016da75976d..e7d02c67b7dd 100644 --- a/storage/cloud-client/storage_upload_encrypted_file.py +++ b/storage/cloud-client/storage_upload_encrypted_file.py @@ -14,11 +14,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys # [START storage_upload_encrypted_file] -from google.cloud import storage import base64 +# [END storage_upload_encrypted_file] +import sys +# [START storage_upload_encrypted_file] + +from google.cloud import storage def upload_encrypted_blob( diff --git a/storage/cloud-client/uniform_bucket_level_access_test.py b/storage/cloud-client/uniform_bucket_level_access_test.py index 7b5fdbf94086..9d1e8e0b4b55 100644 --- a/storage/cloud-client/uniform_bucket_level_access_test.py +++ b/storage/cloud-client/uniform_bucket_level_access_test.py @@ -15,12 +15,11 @@ import time from google.cloud import storage - import pytest -import storage_get_uniform_bucket_level_access import storage_disable_uniform_bucket_level_access import storage_enable_uniform_bucket_level_access +import storage_get_uniform_bucket_level_access @pytest.fixture() diff --git a/storage/signed_urls/generate_signed_urls.py b/storage/signed_urls/generate_signed_urls.py index 732bd8d70b20..224fe762dab8 100644 --- a/storage/signed_urls/generate_signed_urls.py +++ b/storage/signed_urls/generate_signed_urls.py @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import argparse - """This application demonstrates how to construct a Signed URL for objects in Google Cloud Storage. @@ -21,6 +19,7 @@ at https://cloud.google.com/storage/docs/access-control/signing-urls-manually. """ +import argparse # [START storage_signed_url_all] import binascii import collections @@ -28,13 +27,12 @@ import hashlib import sys +# pip install google-auth +from google.oauth2 import service_account # pip install six import six from six.moves.urllib.parse import quote -# pip install google-auth -from google.oauth2 import service_account - def generate_signed_url(service_account_file, bucket_name, object_name, subresource=None, expiration=604800, http_method='GET', diff --git a/tables/automl/dataset_test.py b/tables/automl/dataset_test.py index f25239fb3b5e..9a1e6aa061bc 100644 --- a/tables/automl/dataset_test.py +++ b/tables/automl/dataset_test.py @@ -13,17 +13,17 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - -import pytest +import os import random import string -import os import time from google.api_core import exceptions +import pytest import automl_tables_dataset + PROJECT = os.environ["GCLOUD_PROJECT"] REGION = "us-central1" STATIC_DATASET = "do_not_delete_this_table" diff --git a/tables/automl/model_test.py b/tables/automl/model_test.py index 11afdeadeebb..ccce9632f185 100644 --- a/tables/automl/model_test.py +++ b/tables/automl/model_test.py @@ -13,10 +13,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - +import os import random import string -import os import time from google.api_core import exceptions @@ -24,6 +23,7 @@ import automl_tables_model import dataset_test + PROJECT = os.environ["GCLOUD_PROJECT"] REGION = "us-central1" STATIC_MODEL = "do_not_delete_this_model_0" diff --git a/tables/automl/predict_test.py b/tables/automl/predict_test.py index 4ded386e1c35..e8a6e38b289f 100644 --- a/tables/automl/predict_test.py +++ b/tables/automl/predict_test.py @@ -18,10 +18,11 @@ from google.cloud.automl_v1beta1.gapic import enums -import automl_tables_predict import automl_tables_model +import automl_tables_predict import model_test + PROJECT = os.environ["GCLOUD_PROJECT"] REGION = "us-central1" STATIC_MODEL = model_test.STATIC_MODEL diff --git a/texttospeech/cloud-client/ssml_addresses.py b/texttospeech/cloud-client/ssml_addresses.py index b30cfce004f6..dd9276058a44 100644 --- a/texttospeech/cloud-client/ssml_addresses.py +++ b/texttospeech/cloud-client/ssml_addresses.py @@ -14,9 +14,10 @@ # [START tts_ssml_address_imports] +import html + from google.cloud import texttospeech -import html # [END tts_ssml_address_imports] diff --git a/texttospeech/cloud-client/ssml_addresses_test.py b/texttospeech/cloud-client/ssml_addresses_test.py index fe4da2867597..5f0016085b15 100644 --- a/texttospeech/cloud-client/ssml_addresses_test.py +++ b/texttospeech/cloud-client/ssml_addresses_test.py @@ -11,11 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +import os -from ssml_addresses import text_to_ssml from ssml_addresses import ssml_to_audio - -import os +from ssml_addresses import text_to_ssml def test_text_to_ssml(capsys): diff --git a/trace/cloud-trace-demo-app/app/app.py b/trace/cloud-trace-demo-app/app/app.py index f1aa4884b98d..5f67193ed14a 100644 --- a/trace/cloud-trace-demo-app/app/app.py +++ b/trace/cloud-trace-demo-app/app/app.py @@ -14,19 +14,20 @@ """ A sample app demonstrating Stackdriver Trace """ +import argparse +import random +import time + # [START trace_demo_imports] from flask import Flask +from opencensus.ext.flask.flask_middleware import FlaskMiddleware +from opencensus.ext.stackdriver.trace_exporter import StackdriverExporter from opencensus.trace import execution_context from opencensus.trace.propagation import google_cloud_format from opencensus.trace.samplers import AlwaysOnSampler -from opencensus.ext.stackdriver.trace_exporter import StackdriverExporter -from opencensus.ext.flask.flask_middleware import FlaskMiddleware # [END trace_demo_imports] - import requests -import argparse -import time -import random + app = Flask(__name__) diff --git a/trace/cloud-trace-demo-app/app/app_test.py b/trace/cloud-trace-demo-app/app/app_test.py index c68257519322..ce24e32fc967 100644 --- a/trace/cloud-trace-demo-app/app/app_test.py +++ b/trace/cloud-trace-demo-app/app/app_test.py @@ -15,9 +15,10 @@ A sample app demonstrating Stackdriver Trace """ -import app -import mock import httpretty +import mock + +import app def test_send_response(): diff --git a/trace/trace-python-sample/main_test.py b/trace/trace-python-sample/main_test.py index ee590fdcfe3b..c0f96e2de98c 100644 --- a/trace/trace-python-sample/main_test.py +++ b/trace/trace-python-sample/main_test.py @@ -13,6 +13,7 @@ # limitations under the License. import os + import main