Skip to content

Commit 99f0ca2

Browse files
committed
Flake8 fixes (mostly removing useless module imports)
1 parent 4bbe73f commit 99f0ca2

17 files changed

+21
-69
lines changed

tests/benchmark_core.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import pickle
1313
import random
1414
import shutil
15-
import sys
1615
import time
1716
import warnings
1817

@@ -30,7 +29,7 @@
3029
# Disk Cache Benchmarks
3130
###############################################################################
3231

33-
import diskcache
32+
import diskcache # noqa
3433

3534
caches.append(
3635
(
@@ -123,13 +122,13 @@ def worker(num, kind, args, kwargs):
123122
start = time.time()
124123
result = obj.set(key, value)
125124
end = time.time()
126-
miss = result == False
125+
miss = result is False
127126
action = 'set'
128127
else:
129128
start = time.time()
130129
result = obj.delete(key)
131130
end = time.time()
132-
miss = result == False
131+
miss = result is False
133132
action = 'delete'
134133

135134
if count > WARMUP:
@@ -154,7 +153,7 @@ def dispatch():
154153

155154
try:
156155
obj.close()
157-
except:
156+
except Exception:
158157
pass
159158

160159
processes = [

tests/benchmark_djangocache.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
import pickle
1313
import random
1414
import shutil
15-
import sys
1615
import time
17-
import warnings
1816

1917
from utils import display
2018

@@ -59,13 +57,13 @@ def worker(num, name):
5957
start = time.time()
6058
result = obj.set(key, value)
6159
end = time.time()
62-
miss = result == False
60+
miss = result is False
6361
action = 'set'
6462
else:
6563
start = time.time()
6664
result = obj.delete(key)
6765
end = time.time()
68-
miss = result == False
66+
miss = result is False
6967
action = 'delete'
7068

7169
if count > WARMUP:
@@ -91,14 +89,14 @@ def prepare(name):
9189

9290
try:
9391
obj.close()
94-
except:
92+
except Exception:
9593
pass
9694

9795

9896
def dispatch():
9997
setup()
10098

101-
from django.core.cache import caches
99+
from django.core.cache import caches # noqa
102100

103101
for name in ['locmem', 'memcached', 'redis', 'diskcache', 'filebased']:
104102
shutil.rmtree('tmp', ignore_errors=True)

tests/issue_85.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def run(statements):
109109
shard._sql(statement)
110110
if index == 0:
111111
values.append(('BEGIN', ident))
112-
except sqlite3.OperationalError as exc:
112+
except sqlite3.OperationalError:
113113
values.append(('ERROR', ident))
114114

115115

tests/plot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def parse_data(infile):
4848
if blocks.match(line):
4949
try:
5050
name = title.match(lines[index + 1]).group(1)
51-
except:
51+
except Exception:
5252
index += 1
5353
continue
5454

tests/plot_early_recompute.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def timer(func):
2222
@ft.wraps(func)
2323
def wrapper(*args, **kwargs):
2424
start = time.time()
25-
result = func(*args, **kwargs)
25+
func(*args, **kwargs)
2626
pair = start, time.time()
2727
with lock:
2828
times.append(pair)

tests/settings_benchmark.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from .settings import *
1+
from .settings import * # noqa
22

33
CACHES = {
44
'default': {
55
'BACKEND': 'diskcache.DjangoCache',
6-
'LOCATION': CACHE_DIR,
6+
'LOCATION': CACHE_DIR, # noqa
77
},
88
'memcached': {
99
'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',

tests/stress_test_core.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import queue
88
import random
99
import shutil
10-
import sys
1110
import threading
1211
import time
1312
import warnings
@@ -196,15 +195,15 @@ def dispatch(num, eviction_policy, processes, threads):
196195
for thread_queue in thread_queues:
197196
thread_queue.put(None)
198197

199-
start = time.time()
198+
# start = time.time()
200199

201200
for thread in subthreads:
202201
thread.start()
203202

204203
for thread in subthreads:
205204
thread.join()
206205

207-
stop = time.time()
206+
# stop = time.time()
208207

209208
timings = co.defaultdict(list)
210209

@@ -396,7 +395,7 @@ def stress_test_mp():
396395
parser.add_argument(
397396
'-v',
398397
'--eviction-policy',
399-
type=unicode,
398+
type=str,
400399
default=u'least-recently-stored',
401400
)
402401

tests/stress_test_deque.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import collections as co
44
import functools as ft
5-
import itertools as it
65
import random
76

87
import diskcache as dc

tests/stress_test_deque_mp.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Stress test diskcache.persistent.Deque."""
22

3-
import functools as ft
43
import itertools as it
54
import multiprocessing as mp
65
import os

tests/stress_test_fanout.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
"Stress test diskcache.core.Cache."
22

3-
import collections as co
43
import multiprocessing as mp
54
import os
65
import pickle
76
import queue
87
import random
98
import shutil
10-
import sys
119
import threading
1210
import time
1311
import warnings
@@ -388,7 +386,7 @@ def stress_test_mp():
388386
parser.add_argument(
389387
'-v',
390388
'--eviction-policy',
391-
type=unicode,
389+
type=str,
392390
default=u'least-recently-stored',
393391
)
394392

0 commit comments

Comments
 (0)