diff --git a/describe.py b/describe.py
index 506e251dd04..4807774d711 100755
--- a/describe.py
+++ b/describe.py
@@ -307,7 +307,6 @@ def document_collection(resource, path, root_discovery, discovery, css=CSS):
"""
collections = []
methods = []
- resource_name = path.split(".")[-2]
html = [
"
",
css,
@@ -347,7 +346,6 @@ def document_collection(resource, path, root_discovery, discovery, css=CSS):
if methods:
html.append("Method Details
")
for name in methods:
- dname = name.rsplit("_")[0]
html.append(method(name, getattr(resource, name).__doc__))
html.append("")
diff --git a/googleapiclient/discovery.py b/googleapiclient/discovery.py
index c4d0eadb719..f8f866e38fe 100644
--- a/googleapiclient/discovery.py
+++ b/googleapiclient/discovery.py
@@ -427,8 +427,8 @@ def _retrieve_discovery_doc(
pass
try:
- service = json.loads(content)
- except ValueError as e:
+ json.loads(content)
+ except ValueError:
logger.error("Failed to parse as JSON: " + content)
raise InvalidJsonError()
if cache_discovery and cache:
diff --git a/samples/coordinate/coordinate.py b/samples/coordinate/coordinate.py
index e569e3f00bf..75cc072dfa1 100644
--- a/samples/coordinate/coordinate.py
+++ b/samples/coordinate/coordinate.py
@@ -94,7 +94,7 @@ def main(argv):
pprint.pprint(update_result)
- except client.AccessTokenRefreshError as e:
+ except client.AccessTokenRefreshError:
print ('The credentials have been revoked or expired, please re-run'
'the application to re-authorize')
diff --git a/tests/test__auth.py b/tests/test__auth.py
index 6809647b785..bda822b87e3 100644
--- a/tests/test__auth.py
+++ b/tests/test__auth.py
@@ -128,13 +128,11 @@ def test_default_credentials(self):
def test_credentials_from_file(self):
with self.assertRaises(EnvironmentError):
- credentials = _auth.credentials_from_file("credentials.json")
+ _auth.credentials_from_file("credentials.json")
def test_default_credentials_with_scopes_and_quota_project(self):
with self.assertRaises(EnvironmentError):
- credentials = _auth.default_credentials(
- scopes=["1", "2"], quota_project_id="my-project"
- )
+ _auth.default_credentials(scopes=["1", "2"], quota_project_id="my-project")
def test_with_scopes_non_scoped(self):
credentials = mock.Mock(spec=oauth2client.client.Credentials)
diff --git a/tests/test_discovery.py b/tests/test_discovery.py
index 63d1a71b0c0..2484efdd3b2 100644
--- a/tests/test_discovery.py
+++ b/tests/test_discovery.py
@@ -243,7 +243,7 @@ def test_fix_up_parameters_optional_body(self):
dummy_schema = {"Request": {"properties": {}}}
method_desc = {"request": {"$ref": "Request"}}
- parameters = _fix_up_parameters(method_desc, {}, "POST", dummy_schema)
+ _fix_up_parameters(method_desc, {}, "POST", dummy_schema)
def _base_fix_up_method_description_test(
self,
@@ -440,14 +440,14 @@ def test_ResourceMethodParameters_zoo_animals_patch(self):
class Discovery(unittest.TestCase):
def test_discovery_http_is_closed(self):
http = HttpMock(datafile("malformed.json"), {"status": "200"})
- service = build("plus", "v1", credentials=mock.sentinel.credentials)
+ build("plus", "v1", credentials=mock.sentinel.credentials)
http.close.assert_called_once()
class DiscoveryErrors(unittest.TestCase):
def test_tests_should_be_run_with_strict_positional_enforcement(self):
try:
- plus = build("plus", "v1", None, static_discovery=False)
+ build("plus", "v1", None, static_discovery=False)
self.fail("should have raised a TypeError exception over missing http=.")
except TypeError:
pass
@@ -455,7 +455,7 @@ def test_tests_should_be_run_with_strict_positional_enforcement(self):
def test_failed_to_parse_discovery_json(self):
self.http = HttpMock(datafile("malformed.json"), {"status": "200"})
try:
- plus = build(
+ build(
"plus",
"v1",
http=self.http,
@@ -474,7 +474,7 @@ def test_unknown_api_name_or_version(self):
]
)
with self.assertRaises(UnknownApiNameOrVersion):
- plus = build("plus", "v1", http=http, cache_discovery=False)
+ build("plus", "v1", http=http, cache_discovery=False)
def test_credentials_and_http_mutually_exclusive(self):
http = HttpMock(datafile("plus.json"), {"status": "200"})
@@ -595,7 +595,7 @@ def test_building_with_developer_key_skips_adc(self):
def test_building_with_context_manager(self):
discovery = read_datafile("plus.json")
- with mock.patch("httplib2.Http") as http:
+ with mock.patch("httplib2.Http"):
with build_from_document(
discovery,
base="https://www.googleapis.com/",
@@ -668,7 +668,7 @@ def test_scopes_from_client_options(self):
discovery = read_datafile("plus.json")
with mock.patch("googleapiclient._auth.default_credentials") as default:
- plus = build_from_document(
+ build_from_document(
discovery,
client_options={"scopes": ["1", "2"]},
)
@@ -679,7 +679,7 @@ def test_quota_project_from_client_options(self):
discovery = read_datafile("plus.json")
with mock.patch("googleapiclient._auth.default_credentials") as default:
- plus = build_from_document(
+ build_from_document(
discovery,
client_options=google.api_core.client_options.ClientOptions(
quota_project_id="my-project"
@@ -692,7 +692,7 @@ def test_credentials_file_from_client_options(self):
discovery = read_datafile("plus.json")
with mock.patch("googleapiclient._auth.credentials_from_file") as default:
- plus = build_from_document(
+ build_from_document(
discovery,
client_options=google.api_core.client_options.ClientOptions(
credentials_file="credentials.json"
@@ -977,7 +977,7 @@ def test_userip_is_added_to_discovery_uri(self):
http = HttpMockSequence(
[({"status": "400"}, read_datafile("zoo.json", "rb"))]
)
- zoo = build(
+ build(
"zoo",
"v1",
http=http,
@@ -995,7 +995,7 @@ def test_userip_missing_is_not_added_to_discovery_uri(self):
http = HttpMockSequence(
[({"status": "400"}, read_datafile("zoo.json", "rb"))]
)
- zoo = build(
+ build(
"zoo",
"v1",
http=http,
@@ -1013,7 +1013,7 @@ def test_key_is_added_to_discovery_uri(self):
http = HttpMockSequence(
[({"status": "400"}, read_datafile("zoo.json", "rb"))]
)
- zoo = build(
+ build(
"zoo",
"v1",
http=http,
@@ -1232,7 +1232,7 @@ def import_mock(name, *args, **kwargs):
self.mocked_api.memcache.get.return_value = None
- plus = build("plus", "v1", http=self.http, static_discovery=False)
+ build("plus", "v1", http=self.http, static_discovery=False)
# memcache.get is called once
url = "https://www.googleapis.com/discovery/v1/apis/plus/v1/rest"
@@ -1253,7 +1253,7 @@ def import_mock(name, *args, **kwargs):
# (Otherwise it should through an error)
self.http = HttpMock(None, {"status": "200"})
- plus = build("plus", "v1", http=self.http, static_discovery=False)
+ build("plus", "v1", http=self.http, static_discovery=False)
# memcache.get is called twice
self.mocked_api.memcache.get.assert_has_calls(
@@ -1312,7 +1312,7 @@ def test_file_based_cache(self):
):
self.http = HttpMock(datafile("plus.json"), {"status": "200"})
- plus = build("plus", "v1", http=self.http, static_discovery=False)
+ build("plus", "v1", http=self.http, static_discovery=False)
# cache.get is called once
url = "https://www.googleapis.com/discovery/v1/apis/plus/v1/rest"
@@ -1329,7 +1329,7 @@ def test_file_based_cache(self):
# (Otherwise it should through an error)
self.http = HttpMock(None, {"status": "200"})
- plus = build("plus", "v1", http=self.http, static_discovery=False)
+ build("plus", "v1", http=self.http, static_discovery=False)
# cache.get is called twice
cache.get.assert_has_calls([mock.call(url), mock.call(url)])
@@ -1951,7 +1951,7 @@ def test_media_io_base_stream_chunksize_resume(self):
)
try:
- body = request.execute(http=http)
+ request.execute(http=http)
except HttpError as e:
self.assertEqual(b"01234", e.content)
diff --git a/tests/test_http.py b/tests/test_http.py
index 3233f668ce7..194238843e3 100644
--- a/tests/test_http.py
+++ b/tests/test_http.py
@@ -323,7 +323,7 @@ def test_media_io_base_upload_serializable(self):
upload = MediaIoBaseUpload(fd=f, mimetype="image/png")
try:
- json = upload.to_json()
+ upload.to_json()
self.fail("MediaIoBaseUpload should not be serializable.")
except NotImplementedError:
pass
@@ -960,7 +960,7 @@ def test_no_retry_connection_errors(self):
request._sleep = lambda _x: 0 # do nothing
request._rand = lambda: 10
with self.assertRaises(OSError):
- response = request.execute(num_retries=3)
+ request.execute(num_retries=3)
def test_retry_connection_errors_non_resumable(self):
model = JsonModel()
@@ -1238,7 +1238,7 @@ def test_serialize_request_media_body(self):
resumable=None,
)
# Just testing it shouldn't raise an exception.
- s = batch._serialize_request(request).splitlines()
+ batch._serialize_request(request).splitlines()
def test_serialize_request_no_body(self):
batch = BatchHttpRequest()
diff --git a/tests/test_mocks.py b/tests/test_mocks.py
index 1f542b594c4..29c9db75ea4 100644
--- a/tests/test_mocks.py
+++ b/tests/test_mocks.py
@@ -203,9 +203,7 @@ def test_errors(self):
)
try:
- activity = (
- plus.activities().list(collection="public", userId="me").execute()
- )
+ plus.activities().list(collection="public", userId="me").execute()
self.fail("An exception should have been thrown")
except HttpError as e:
self.assertEqual(b"{}", e.content)