Skip to content

Commit 0117082

Browse files
committed
chore: remove unused variables
1 parent ca654c4 commit 0117082

File tree

7 files changed

+27
-30
lines changed

7 files changed

+27
-30
lines changed

describe.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def document_collection(resource, path, root_discovery, discovery, css=CSS):
307307
"""
308308
collections = []
309309
methods = []
310-
resource_name = path.split(".")[-2]
310+
path.split(".")[-2]
311311
html = [
312312
"<html><body>",
313313
css,
@@ -347,7 +347,6 @@ def document_collection(resource, path, root_discovery, discovery, css=CSS):
347347
if methods:
348348
html.append("<h3>Method Details</h3>")
349349
for name in methods:
350-
dname = name.rsplit("_")[0]
351350
html.append(method(name, getattr(resource, name).__doc__))
352351

353352
html.append("</body></html>")

googleapiclient/discovery.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,8 @@ def _retrieve_discovery_doc(
427427
pass
428428

429429
try:
430-
service = json.loads(content)
431-
except ValueError as e:
430+
json.loads(content)
431+
except ValueError:
432432
logger.error("Failed to parse as JSON: " + content)
433433
raise InvalidJsonError()
434434
if cache_discovery and cache:

samples/coordinate/coordinate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def main(argv):
9494

9595
pprint.pprint(update_result)
9696

97-
except client.AccessTokenRefreshError as e:
97+
except client.AccessTokenRefreshError:
9898
print ('The credentials have been revoked or expired, please re-run'
9999
'the application to re-authorize')
100100

tests/test__auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ def test_default_credentials(self):
128128

129129
def test_credentials_from_file(self):
130130
with self.assertRaises(EnvironmentError):
131-
credentials = _auth.credentials_from_file("credentials.json")
131+
_auth.credentials_from_file("credentials.json")
132132

133133
def test_default_credentials_with_scopes_and_quota_project(self):
134134
with self.assertRaises(EnvironmentError):
135-
credentials = _auth.default_credentials(
135+
_auth.default_credentials(
136136
scopes=["1", "2"], quota_project_id="my-project"
137137
)
138138

tests/test_discovery.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def test_fix_up_parameters_optional_body(self):
243243
dummy_schema = {"Request": {"properties": {}}}
244244
method_desc = {"request": {"$ref": "Request"}}
245245

246-
parameters = _fix_up_parameters(method_desc, {}, "POST", dummy_schema)
246+
_fix_up_parameters(method_desc, {}, "POST", dummy_schema)
247247

248248
def _base_fix_up_method_description_test(
249249
self,
@@ -440,22 +440,22 @@ def test_ResourceMethodParameters_zoo_animals_patch(self):
440440
class Discovery(unittest.TestCase):
441441
def test_discovery_http_is_closed(self):
442442
http = HttpMock(datafile("malformed.json"), {"status": "200"})
443-
service = build("plus", "v1", credentials=mock.sentinel.credentials)
443+
build("plus", "v1", credentials=mock.sentinel.credentials)
444444
http.close.assert_called_once()
445445

446446

447447
class DiscoveryErrors(unittest.TestCase):
448448
def test_tests_should_be_run_with_strict_positional_enforcement(self):
449449
try:
450-
plus = build("plus", "v1", None, static_discovery=False)
450+
build("plus", "v1", None, static_discovery=False)
451451
self.fail("should have raised a TypeError exception over missing http=.")
452452
except TypeError:
453453
pass
454454

455455
def test_failed_to_parse_discovery_json(self):
456456
self.http = HttpMock(datafile("malformed.json"), {"status": "200"})
457457
try:
458-
plus = build(
458+
build(
459459
"plus",
460460
"v1",
461461
http=self.http,
@@ -474,7 +474,7 @@ def test_unknown_api_name_or_version(self):
474474
]
475475
)
476476
with self.assertRaises(UnknownApiNameOrVersion):
477-
plus = build("plus", "v1", http=http, cache_discovery=False)
477+
build("plus", "v1", http=http, cache_discovery=False)
478478

479479
def test_credentials_and_http_mutually_exclusive(self):
480480
http = HttpMock(datafile("plus.json"), {"status": "200"})
@@ -603,7 +603,7 @@ def test_building_with_context_manager(self):
603603
) as plus:
604604
self.assertIsNotNone(plus)
605605
self.assertTrue(hasattr(plus, "activities"))
606-
plus._http.http.close.assert_called_once()
606+
http.close.assert_called_once()
607607

608608
def test_resource_close(self):
609609
discovery = read_datafile("plus.json")
@@ -668,7 +668,7 @@ def test_scopes_from_client_options(self):
668668
discovery = read_datafile("plus.json")
669669

670670
with mock.patch("googleapiclient._auth.default_credentials") as default:
671-
plus = build_from_document(
671+
build_from_document(
672672
discovery,
673673
client_options={"scopes": ["1", "2"]},
674674
)
@@ -679,7 +679,7 @@ def test_quota_project_from_client_options(self):
679679
discovery = read_datafile("plus.json")
680680

681681
with mock.patch("googleapiclient._auth.default_credentials") as default:
682-
plus = build_from_document(
682+
build_from_document(
683683
discovery,
684684
client_options=google.api_core.client_options.ClientOptions(
685685
quota_project_id="my-project"
@@ -692,7 +692,7 @@ def test_credentials_file_from_client_options(self):
692692
discovery = read_datafile("plus.json")
693693

694694
with mock.patch("googleapiclient._auth.credentials_from_file") as default:
695-
plus = build_from_document(
695+
build_from_document(
696696
discovery,
697697
client_options=google.api_core.client_options.ClientOptions(
698698
credentials_file="credentials.json"
@@ -977,7 +977,7 @@ def test_userip_is_added_to_discovery_uri(self):
977977
http = HttpMockSequence(
978978
[({"status": "400"}, read_datafile("zoo.json", "rb"))]
979979
)
980-
zoo = build(
980+
build(
981981
"zoo",
982982
"v1",
983983
http=http,
@@ -995,7 +995,7 @@ def test_userip_missing_is_not_added_to_discovery_uri(self):
995995
http = HttpMockSequence(
996996
[({"status": "400"}, read_datafile("zoo.json", "rb"))]
997997
)
998-
zoo = build(
998+
build(
999999
"zoo",
10001000
"v1",
10011001
http=http,
@@ -1013,7 +1013,7 @@ def test_key_is_added_to_discovery_uri(self):
10131013
http = HttpMockSequence(
10141014
[({"status": "400"}, read_datafile("zoo.json", "rb"))]
10151015
)
1016-
zoo = build(
1016+
build(
10171017
"zoo",
10181018
"v1",
10191019
http=http,
@@ -1232,7 +1232,7 @@ def import_mock(name, *args, **kwargs):
12321232

12331233
self.mocked_api.memcache.get.return_value = None
12341234

1235-
plus = build("plus", "v1", http=self.http, static_discovery=False)
1235+
build("plus", "v1", http=self.http, static_discovery=False)
12361236

12371237
# memcache.get is called once
12381238
url = "https://www.googleapis.com/discovery/v1/apis/plus/v1/rest"
@@ -1253,7 +1253,7 @@ def import_mock(name, *args, **kwargs):
12531253
# (Otherwise it should through an error)
12541254
self.http = HttpMock(None, {"status": "200"})
12551255

1256-
plus = build("plus", "v1", http=self.http, static_discovery=False)
1256+
build("plus", "v1", http=self.http, static_discovery=False)
12571257

12581258
# memcache.get is called twice
12591259
self.mocked_api.memcache.get.assert_has_calls(
@@ -1312,7 +1312,7 @@ def test_file_based_cache(self):
13121312
):
13131313
self.http = HttpMock(datafile("plus.json"), {"status": "200"})
13141314

1315-
plus = build("plus", "v1", http=self.http, static_discovery=False)
1315+
build("plus", "v1", http=self.http, static_discovery=False)
13161316

13171317
# cache.get is called once
13181318
url = "https://www.googleapis.com/discovery/v1/apis/plus/v1/rest"
@@ -1329,7 +1329,7 @@ def test_file_based_cache(self):
13291329
# (Otherwise it should through an error)
13301330
self.http = HttpMock(None, {"status": "200"})
13311331

1332-
plus = build("plus", "v1", http=self.http, static_discovery=False)
1332+
build("plus", "v1", http=self.http, static_discovery=False)
13331333

13341334
# cache.get is called twice
13351335
cache.get.assert_has_calls([mock.call(url), mock.call(url)])
@@ -1951,7 +1951,7 @@ def test_media_io_base_stream_chunksize_resume(self):
19511951
)
19521952

19531953
try:
1954-
body = request.execute(http=http)
1954+
request.execute(http=http)
19551955
except HttpError as e:
19561956
self.assertEqual(b"01234", e.content)
19571957

tests/test_http.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def test_media_io_base_upload_serializable(self):
323323
upload = MediaIoBaseUpload(fd=f, mimetype="image/png")
324324

325325
try:
326-
json = upload.to_json()
326+
upload.to_json()
327327
self.fail("MediaIoBaseUpload should not be serializable.")
328328
except NotImplementedError:
329329
pass
@@ -960,7 +960,7 @@ def test_no_retry_connection_errors(self):
960960
request._sleep = lambda _x: 0 # do nothing
961961
request._rand = lambda: 10
962962
with self.assertRaises(OSError):
963-
response = request.execute(num_retries=3)
963+
request.execute(num_retries=3)
964964

965965
def test_retry_connection_errors_non_resumable(self):
966966
model = JsonModel()
@@ -1238,7 +1238,7 @@ def test_serialize_request_media_body(self):
12381238
resumable=None,
12391239
)
12401240
# Just testing it shouldn't raise an exception.
1241-
s = batch._serialize_request(request).splitlines()
1241+
batch._serialize_request(request).splitlines()
12421242

12431243
def test_serialize_request_no_body(self):
12441244
batch = BatchHttpRequest()

tests/test_mocks.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,7 @@ def test_errors(self):
203203
)
204204

205205
try:
206-
activity = (
207-
plus.activities().list(collection="public", userId="me").execute()
208-
)
206+
plus.activities().list(collection="public", userId="me").execute()
209207
self.fail("An exception should have been thrown")
210208
except HttpError as e:
211209
self.assertEqual(b"{}", e.content)

0 commit comments

Comments
 (0)