Skip to content

Commit a419b11

Browse files
committed
Refresh [black](https://github.com/psf/black) formatting.
1 parent 9f9e644 commit a419b11

21 files changed

+36
-44
lines changed

cachecontrol/cache.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77

88
class BaseCache(object):
9-
109
def get(self, key):
1110
raise NotImplementedError()
1211

@@ -21,7 +20,6 @@ def close(self):
2120

2221

2322
class DictCache(BaseCache):
24-
2523
def __init__(self, init_dict=None):
2624
self.lock = Lock()
2725
self.data = init_dict or {}

cachecontrol/caches/file_cache.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ def _secure_open_write(filename, fmode):
5858

5959

6060
class FileCache(BaseCache):
61-
6261
def __init__(
6362
self,
6463
directory,
@@ -128,7 +127,9 @@ def set(self, key, value):
128127
try:
129128
os.makedirs(parentdir, self.dirmode)
130129
except (IOError, OSError):
131-
logging.debug("Error trying to create directory '%s'", parentdir, exc_info=True)
130+
logging.debug(
131+
"Error trying to create directory '%s'", parentdir, exc_info=True
132+
)
132133

133134
with self.lock_class(name) as lock:
134135
# Write our actual file

cachecontrol/caches/redis_cache.py

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

77

88
class RedisCache(BaseCache):
9-
109
def __init__(self, conn):
1110
self.conn = conn
1211

cachecontrol/controller.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def cached_request(self, request):
160160
# with cache busting headers as usual (ie no-cache).
161161
if int(resp.status) in PERMANENT_REDIRECT_STATUSES:
162162
msg = (
163-
'Returning cached permanent redirect response '
163+
"Returning cached permanent redirect response "
164164
"(ignoring date and etag information)"
165165
)
166166
logger.debug(msg)
@@ -308,15 +308,13 @@ def cache_response(self, request, response, body=None, status_codes=None):
308308
# If we've been given an etag, then keep the response
309309
if self.cache_etags and "etag" in response_headers:
310310
logger.debug("Caching due to etag")
311-
self.cache.set(
312-
cache_url, self.serializer.dumps(request, response, body)
313-
)
311+
self.cache.set(cache_url, self.serializer.dumps(request, response, body))
314312

315313
# Add to the cache any permanent redirects. We do this before looking
316314
# that the Date headers.
317315
elif int(response.status) in PERMANENT_REDIRECT_STATUSES:
318316
logger.debug("Caching permanent redirect")
319-
self.cache.set(cache_url, self.serializer.dumps(request, response, b''))
317+
self.cache.set(cache_url, self.serializer.dumps(request, response, b""))
320318

321319
# Add to the cache if the response headers demand it. If there
322320
# is no date header then we can't do anything about expiring

cachecontrol/heuristics.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ def datetime_to_header(dt):
1616

1717

1818
class BaseHeuristic(object):
19-
2019
def warning(self, response):
2120
"""
2221
Return a valid 1xx warning header value describing the cache
@@ -95,8 +94,19 @@ class LastModified(BaseHeuristic):
9594
http://lxr.mozilla.org/mozilla-release/source/netwerk/protocol/http/nsHttpResponseHead.cpp#397
9695
Unlike mozilla we limit this to 24-hr.
9796
"""
97+
9898
cacheable_by_default_statuses = {
99-
200, 203, 204, 206, 300, 301, 404, 405, 410, 414, 501
99+
200,
100+
203,
101+
204,
102+
206,
103+
300,
104+
301,
105+
404,
106+
405,
107+
410,
108+
414,
109+
501,
100110
}
101111

102112
def update_headers(self, resp):

cachecontrol/serialize.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ def _b64_decode_str(s):
2121

2222

2323
class Serializer(object):
24-
2524
def dumps(self, request, response, body):
2625
response_headers = CaseInsensitiveDict(response.headers)
2726

examples/benchmark.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414

1515

1616
class Server(object):
17-
1817
def __call__(self, env, sr):
1918
body = "Hello World!"
2019
status = "200 OK"
2120
headers = [
22-
("Cache-Control", "max-age=%i" % (60 * 10)), ("Content-Type", "text/plain")
21+
("Cache-Control", "max-age=%i" % (60 * 10)),
22+
("Content-Type", "text/plain"),
2323
]
2424
sr(status, headers)
2525
return body

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[tool.isort]
22
line_length = 88
33
known_first_party = ['cachecontrol']
4+
# Set multi-line output to "Vertical Hanging indent" to avoid fighting with black.
5+
multi_line_output = 3
6+
include_trailing_comma = true

tests/conftest.py

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

88

99
class SimpleApp(object):
10-
1110
def __init__(self):
1211
self.etag_count = 0
1312
self.update_etag_string()

tests/test_adapter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def sess(url, request):
3131

3232

3333
class TestSessionActions(object):
34-
3534
def test_get_caches(self, url, sess):
3635
r2 = sess.get(url)
3736
assert r2.from_cache is True

0 commit comments

Comments
 (0)