Skip to content

Commit 545c5e3

Browse files
committed
Refresh [black](https://github.com/psf/black) formatting.
1 parent dea9cf5 commit 545c5e3

21 files changed

+36
-44
lines changed

cachecontrol/cache.py

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

1111

1212
class BaseCache(object):
13-
1413
def get(self, key):
1514
raise NotImplementedError()
1615

@@ -25,7 +24,6 @@ def close(self):
2524

2625

2726
class DictCache(BaseCache):
28-
2927
def __init__(self, init_dict=None):
3028
self.lock = Lock()
3129
self.data = init_dict or {}

cachecontrol/caches/file_cache.py

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

6363

6464
class FileCache(BaseCache):
65-
6665
def __init__(
6766
self,
6867
directory,
@@ -132,7 +131,9 @@ def set(self, key, value):
132131
try:
133132
os.makedirs(parentdir, self.dirmode)
134133
except (IOError, OSError):
135-
logging.debug("Error trying to create directory '%s'", parentdir, exc_info=True)
134+
logging.debug(
135+
"Error trying to create directory '%s'", parentdir, exc_info=True
136+
)
136137

137138
with self.lock_class(name) as lock:
138139
# Write our actual file

cachecontrol/caches/redis_cache.py

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

1111

1212
class RedisCache(BaseCache):
13-
1413
def __init__(self, conn):
1514
self.conn = conn
1615

cachecontrol/controller.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def cached_request(self, request):
163163
# with cache busting headers as usual (ie no-cache).
164164
if int(resp.status) in PERMANENT_REDIRECT_STATUSES:
165165
msg = (
166-
'Returning cached permanent redirect response '
166+
"Returning cached permanent redirect response "
167167
"(ignoring date and etag information)"
168168
)
169169
logger.debug(msg)
@@ -311,15 +311,13 @@ def cache_response(self, request, response, body=None, status_codes=None):
311311
# If we've been given an etag, then keep the response
312312
if self.cache_etags and "etag" in response_headers:
313313
logger.debug("Caching due to etag")
314-
self.cache.set(
315-
cache_url, self.serializer.dumps(request, response, body)
316-
)
314+
self.cache.set(cache_url, self.serializer.dumps(request, response, body))
317315

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

324322
# Add to the cache if the response headers demand it. If there
325323
# 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
@@ -20,7 +20,6 @@ def datetime_to_header(dt):
2020

2121

2222
class BaseHeuristic(object):
23-
2423
def warning(self, response):
2524
"""
2625
Return a valid 1xx warning header value describing the cache
@@ -99,8 +98,19 @@ class LastModified(BaseHeuristic):
9998
http://lxr.mozilla.org/mozilla-release/source/netwerk/protocol/http/nsHttpResponseHead.cpp#397
10099
Unlike mozilla we limit this to 24-hr.
101100
"""
101+
102102
cacheable_by_default_statuses = {
103-
200, 203, 204, 206, 300, 301, 404, 405, 410, 414, 501
103+
200,
104+
203,
105+
204,
106+
206,
107+
300,
108+
301,
109+
404,
110+
405,
111+
410,
112+
414,
113+
501,
104114
}
105115

106116
def update_headers(self, resp):

cachecontrol/serialize.py

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

2626

2727
class Serializer(object):
28-
2928
def dumps(self, request, response, body):
3029
response_headers = CaseInsensitiveDict(response.headers)
3130

examples/benchmark.py

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

1919

2020
class Server(object):
21-
2221
def __call__(self, env, sr):
2322
body = "Hello World!"
2423
status = "200 OK"
2524
headers = [
26-
("Cache-Control", "max-age=%i" % (60 * 10)), ("Content-Type", "text/plain")
25+
("Cache-Control", "max-age=%i" % (60 * 10)),
26+
("Content-Type", "text/plain"),
2727
]
2828
sr(status, headers)
2929
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
@@ -11,7 +11,6 @@
1111

1212

1313
class SimpleApp(object):
14-
1514
def __init__(self):
1615
self.etag_count = 0
1716
self.update_etag_string()

tests/test_adapter.py

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

3636

3737
class TestSessionActions(object):
38-
3938
def test_get_caches(self, url, sess):
4039
r2 = sess.get(url)
4140
assert r2.from_cache is True

0 commit comments

Comments
 (0)