10000 Removing unused nvariablesdetected by pyflakes. · googleapis/google-cloud-python@114fe90 · GitHub
[go: up one dir, main page]

Skip to content

Commit 114fe90

Browse files
committed
Removing unused nvariablesdetected by pyflakes.
1 parent 6dd5f2b commit 114fe90

File tree

11 files changed

+22
-95
lines changed

11 files changed

+22
-95
lines changed

gcloud/datastore/connection.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
import httplib2
2-
31
from gcloud import connection
42
from gcloud.datastore import datastore_v1_pb2 as datastore_pb
53
from gcloud.datastore import helpers
64
from gcloud.datastore.dataset import Dataset
7-
from gcloud.datastore.transaction import Transaction
85

96

107
class Connection(connection.Connection):

gcloud/datastore/test_connection.py

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def test__request_not_200(self):
7575
METHOD = 'METHOD'
7676
DATA = 'DATA'
7777
conn = self._makeOne()
78-
http = conn._http = Http({'status': '400'}, 'Bad Request')
78+
conn._http = Http({'status': '400'}, 'Bad Request')
7979
with self.assertRaises(Exception) as e:
8080
conn._request(DATASET_ID, METHOD, DATA)
8181
self.assertEqual(str(e.exception),
@@ -199,7 +199,6 @@ def test_begin_transaction_w_existing_transaction(self):
199199
def test_begin_transaction_default_serialize(self):
200200
from gcloud.datastore.connection import datastore_pb
201201

202-
xact = object()
203202
DATASET_ID = 'DATASET'
204203
TRANSACTION = 'TRANSACTION'
205204
rsp_pb = datastore_pb.BeginTransactionResponse()
@@ -230,7 +229,6 @@ def test_begin_transaction_default_serialize(self):
230229
def test_begin_transaction_explicit_serialize(self):
231230
from gcloud.datastore.connection import datastore_pb
232231

233-
xact = object()
234232
DATASET_ID = 'DATASET'
235233
TRANSACTION = 'TRANSACTION'
236234
rsp_pb = datastore_pb.BeginTransactionResponse()
@@ -368,7 +366,7 @@ def test_run_query_w_namespace_nonempty_result(self):
368366
])
369367
http = conn._http = Http({'status': '200'}, rsp_pb.SerializeToString())
370368
pbs, end, more, skipped = conn.run_query(DATASET_ID, q_pb, 'NS')
371-
returned, = pbs, # One entity.
369+
self.assertEqual(len(pbs), 1)
372370
cw = http._called_with
373371
self.assertEqual(cw['uri'], URI)
374372
self.assertEqual(cw['method'], 'POST')
@@ -694,13 +692,6 @@ def mutation(self):
694692
rsp_pb = datastore_pb.CommitResponse()
695693
conn = self._makeOne()
696694
conn.transaction(Xact())
697-
URI = '/'.join([conn.API_BASE_URL,
698-
'datastore',
699-
conn.API_VERSION,
700-
'datasets',
701-
DATASET_ID,
702-
'commit',
703-
])
704695
http = conn._http = Http({'status': '200'}, rsp_pb.SerializeToString())
705696
result = conn.save_entity(DATASET_ID, key_pb, {'foo': 'Foo'})
706697
self.assertEqual(result, True)
@@ -765,13 +756,6 @@ def mutation(self):
765756
rsp_pb = datastore_pb.CommitResponse()
766757
conn = self._makeOne()
767758
conn.transaction(Xact())
768-
URI = '/'.join([conn.API_BASE_URL,
769-
'datastore',
770-
conn.API_VERSION,
771-
'datasets',
772-
DATASET_ID,
773-
'commit',
774-
])
775759
http = conn._http = Http({'status': '200'}, rsp_pb.SerializeToString())
776760
result = conn.delete_entities(DATASET_ID, [key_pb])
777761
self.assertEqual(result, True)
@@ -837,13 +821,6 @@ def mutation(self):
837821
rsp_pb = datastore_pb.CommitResponse()
838822
conn = self._makeOne()
839823
conn.transaction(Xact())
840-
URI = '/'.join([conn.API_BASE_URL,
841-
'datastore',
842-
conn.API_VERSION,
843-
'datasets',
844-
DATASET_ID,
845-
'commit',
846-
])
847824
http = conn._http = Http({'status': '200'}, rsp_pb.SerializeToString())
848825
result = conn.delete_entity(DATASET_ID, key_pb)
849826
self.assertEqual(result, True)

gcloud/datastore/test_helpers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ def test_datetime(self):
103103
import datetime
104104
import pytz
105105

106-
naive = datetime.datetime(2014, 9, 16, 10, 19, 32, 4375) # No zone.
107106
utc = datetime.datetime(2014, 9, 16, 10, 19, 32, 4375, pytz.utc)
108107
micros = (calendar.timegm(utc.timetuple()) * 1000000) + 4375
109108
pb = self._makePB('timestamp_microseconds_value', micros)

gcloud/datastore/test_query.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ def test_ctor_explicit(self):
2121
from gcloud.datastore.dataset import Dataset
2222

2323
_DATASET = 'DATASET'
24-
_NAMESPACE = 'NAMESPACE'
2524
_KIND = 'KIND'
2625
dataset = Dataset(_DATASET)
2726
query = self._makeOne(_KIND, dataset)

gcloud/datastore/test_transaction.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def test_commit_w_already(self):
8989
connection = _Connection(234)
9090
dataset = _Dataset(_DATASET, connection)
9191
xact = self._makeOne(dataset)
92-
xact._mutation = mutation = object()
92+
xact._mutation = object()
9393
xact.begin()
9494
connection.transaction(()) # Simulate previous commit via false-ish.
9595
xact.commit()
@@ -118,7 +118,7 @@ class Foo(Exception):
118118
connection = _Connection(234)
119119
dataset = _Dataset(_DATASET, connection)
120120
xact = self._makeOne(dataset)
121-
xact._mutation = mutation = object()
121+
xact._mutation = object()
122122
try:
123123
with xact:
124124
self.assertEqual(xact.id(), 234)

gcloud/storage/connection.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import base64
22
import datetime
3-
import httplib2
43
import json
54
import time
65
import urllib
@@ -390,7 +389,7 @@ def delete_bucket(self, bucket, force=False):
390389
for key in bucket:
391390
key.delete()
392391

393-
response = self.api_request(method='DELETE', path=bucket.path)
392+
self.api_request(method='DELETE', path=bucket.path)
394393
return True
395394

396395
def new_bucket(self, bucket):

gcloud/storage/key.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import errno
2-
import json
32
import mimetypes
43
import os
54
from StringIO import StringIO

gcloud/storage/test_acl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def test___iter___non_empty_no_roles(self):
140140
TYPE = 'type'
141141
ID = 'id'
142142
acl = self._makeOne()
143-
entity = acl.entity(TYPE, ID)
143+
acl.entity(TYPE, ID)
144144
self.assertEqual(list(acl), [])
145145

146146
def test___iter___non_empty_w_roles(self):

gcloud/storage/test_bucket.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ def test_delete_key_hit(self):
216216

217217
def test_delete_keys_empty(self):
218218
NAME = 'name'
219-
NONESUCH = 'nonesuch'
220219
connection = _Connection()
221220
bucket = self._makeOne(connection, NAME)
222221
bucket.delete_keys([])
@@ -509,7 +508,6 @@ def test_disable_website(self):
509508
def test_reload_acl_eager_empty(self):
510509
from gcloud.storage.acl import BucketACL
511510
metadata = {'acl': []}
512-
connection = _Connection()
513511
bucket = self._makeOne(metadata=metadata)
514512
self.assertTrue(bucket.reload_acl() is bucket)
515513
self.assertTrue(isinstance(bucket.acl, BucketACL))
@@ -519,7 +517,6 @@ def test_reload_acl_eager_nonempty(self):
519517
from gcloud.storage.acl import BucketACL
520518
ROLE = 'role'
521519
metadata = {'acl': [{'entity': 'allUsers', 'role': ROLE}]}
522-
connection = _Connection()
523520
bucket = self._makeOne(metadata=metadata)
524521
self.assertTrue(bucket.reload_acl() is bucket)
525522
self.assertTrue(isinstance(bucket.acl, BucketACL))
@@ -623,7 +620,6 @@ def test_clear_acl(self):
623620
def test_reload_default_object_acl_eager_empty(self):
624621
from gcloud.storage.acl import BucketACL
625622
metadata = {'defaultObjectAcl': []}
626-
connection = _Connection()
627623
bucket = self._makeOne(metadata=metadata)
628624
self.assertTrue(bucket.reload_default_object_acl() is bucket)
629625
self.assertTrue(isinstance(bucket.default_object_acl, BucketACL))
@@ -633,7 +629,6 @@ def test_reload_default_object_acl_eager_nonempty(self):
633629
from gcloud.storage.acl import BucketACL
634630
ROLE = 'role'
635631
metadata = {'defaultObjectAcl': [{'entity': 'allUsers', 'role': ROLE}]}
636-
connection = _Connection()
637632
bucket = self._makeOne(metadata=metadata)
638633
self.assertTrue(bucket.reload_default_object_acl() is bucket)
639634
self.assertTrue(isinstance(bucket.default_object_acl, BucketACL))

gcloud/storage/test_connection.py

Lines changed: 16 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ def test___contains___hit(self):
123123

124124
def test_build_api_url_no_extra_query_params(self):
125125
PROJECT = 'project'
126-
KEY = 'key'
127126
conn = self._makeOne(PROJECT)
128127
URI = '/'.join([conn.API_BASE_URL,
129128
'storage',
@@ -136,13 +135,7 @@ def test_build_api_url_w_extra_query_params(self):
136135
from urlparse import parse_qsl
137136
from urlparse import urlsplit
138137
PROJECT = 'project'
139-
KEY = 'key'
140138
conn = self._makeOne(PROJECT)
141-
URI = '/'.join([conn.API_BASE_URL,
142-
'storage',
143-
conn.API_VERSION,
144-
'foo'
145-
])
146139
uri = conn.build_api_url('/foo', {'bar': 'baz'})
147140
scheme, netloc, path, qs, frag = urlsplit(uri)
148141
self.assertEqual('%s://%s' % (scheme, netloc), conn.API_BASE_URL)
@@ -237,29 +230,19 @@ def test_api_request_defaults(self):
237230
def test_api_request_w_non_json_response(self):
238231
PROJECT = 'project'
239232
conn = self._makeOne(PROJECT)
240-
URI = '/'.join([conn.API_BASE_URL,
241-
'storage',
242-
conn.API_VERSION,
243-
'?project=%s' % PROJECT,
244-
])
245-
http = conn._http = Http({'status': '200',
246-
'content-type': 'text/plain',
247-
},
248-
'CONTENT')
233+
conn._http = Http({'status': '200',
234+
'content-type': 'text/plain',
235+
},
236+
'CONTENT')
249237
self.assertRaises(TypeError, conn.api_request, 'GET', '/')
250238

251239
def test_api_request_wo_json_expected(self):
252240
PROJECT = 'project'
253241
conn = self._makeOne(PROJECT)
254-
URI = '/'.join([conn.API_BASE_URL,
255-
'storage',
256-
conn.API_VERSION,
257-
'?project=%s' % PROJECT,
258-
])
259-
http = conn._http = Http({'status': '200',
260-
'content-type': 'text/plain',
261-
},
262-
'CONTENT')
242+
conn._http = Http({'status': '200',
243+
'content-type': 'text/plain',
244+
},
245+
'CONTENT')
263246
self.assertEqual(conn.api_request('GET', '/', expect_json=False),
264247
'CONTENT')
265248

@@ -268,11 +251,6 @@ def test_api_request_w_query_params(self):
268251
from urlparse import urlsplit
269252
PROJECT = 'project'
270253
conn = self._makeOne(PROJECT)
271-
URI = '/'.join([conn.API_BASE_URL,
272-
'storage',
273-
conn.API_VERSION,
274-
'?project=%s&foo=bar' % PROJECT,
275-
])
276254
http = conn._http = Http({'status': '200',
277255
'content-type': 'application/json',
278256
},
@@ -324,30 +302,20 @@ def test_api_request_w_404(self):
324302
from gcloud.storage.exceptions import NotFoundError
325303
PROJECT = 'project'
326304
conn = self._makeOne(PROJECT)
327-
URI = '/'.join([conn.API_BASE_URL,
328-
'storage',
329-
conn.API_VERSION,
330-
'?project=%s' % PROJECT,
331-
])
332-
http = conn._http = Http({'status': '404',
333-
'content-type': 'text/plain',
334-
},
335-
'')
305+
conn._http = Http({'status': '404',
306+
'content-type': 'text/plain',
307+
},
308+
'')
336309
self.assertRaises(NotFoundError, conn.api_request, 'GET', '/')
337310

338311
def test_api_request_w_500(self):
339312
from gcloud.storage.exceptions import ConnectionError
340313
PROJECT = 'project'
341314
conn = self._makeOne(PROJECT)
342-
URI = '/'.join([conn.API_BASE_URL,
343-
'storage',
344-
conn.API_VERSION,
345-
'?project=%s' % PROJECT,
346-
])
347-
http = conn._http = Http({'status': '500',
348-
'content-type': 'text/plain',
349-
},
350-
'')
315+
conn._http = Http({'status': '500',
316+
'content-type': 'text/plain',
317+
},
318+
'')
351319
self.assertRaises(ConnectionError, conn.api_request, 'GET', '/')
352320

353321
def test_get_all_buckets_empty(self):

0 commit comments

Comments
 (0)
0