mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-08 16:53:23 +00:00
Format project with black (#467)
Format with line length 110 to match flake8 make black part of linting check Update travis spec for updated black requirements Add diff output for black on failure update changelog
This commit is contained in:
28
vcr/util.py
28
vcr/util.py
@@ -29,6 +29,7 @@ class CaseInsensitiveDict(MutableMapping):
|
||||
operations are given keys that have equal ``.lower()``s, the
|
||||
behavior is undefined.
|
||||
"""
|
||||
|
||||
def __init__(self, data=None, **kwargs):
|
||||
self._store = dict()
|
||||
if data is None:
|
||||
@@ -54,11 +55,7 @@ class CaseInsensitiveDict(MutableMapping):
|
||||
|
||||
def lower_items(self):
|
||||
"""Like iteritems(), but with all lowercase keys."""
|
||||
return (
|
||||
(lowerkey, keyval[1])
|
||||
for (lowerkey, keyval)
|
||||
in self._store.items()
|
||||
)
|
||||
return ((lowerkey, keyval[1]) for (lowerkey, keyval) in self._store.items())
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, Mapping):
|
||||
@@ -92,37 +89,30 @@ def compose(*functions):
|
||||
if function:
|
||||
res = function(res)
|
||||
return res
|
||||
|
||||
return composed
|
||||
|
||||
|
||||
def read_body(request):
|
||||
if hasattr(request.body, 'read'):
|
||||
if hasattr(request.body, "read"):
|
||||
return request.body.read()
|
||||
return request.body
|
||||
|
||||
|
||||
def auto_decorate(
|
||||
decorator,
|
||||
predicate=lambda name, value: isinstance(value, types.FunctionType)
|
||||
):
|
||||
def auto_decorate(decorator, predicate=lambda name, value: isinstance(value, types.FunctionType)):
|
||||
def maybe_decorate(attribute, value):
|
||||
if predicate(attribute, value):
|
||||
value = decorator(value)
|
||||
return value
|
||||
|
||||
class DecorateAll(type):
|
||||
|
||||
def __setattr__(cls, attribute, value):
|
||||
return super(DecorateAll, cls).__setattr__(
|
||||
attribute, maybe_decorate(attribute, value)
|
||||
)
|
||||
return super(DecorateAll, cls).__setattr__(attribute, maybe_decorate(attribute, value))
|
||||
|
||||
def __new__(cls, name, bases, attributes_dict):
|
||||
new_attributes_dict = {
|
||||
attribute: maybe_decorate(attribute, value)
|
||||
for attribute, value in attributes_dict.items()
|
||||
attribute: maybe_decorate(attribute, value) for attribute, value in attributes_dict.items()
|
||||
}
|
||||
return super(DecorateAll, cls).__new__(
|
||||
cls, name, bases, new_attributes_dict
|
||||
)
|
||||
return super(DecorateAll, cls).__new__(cls, name, bases, new_attributes_dict)
|
||||
|
||||
return DecorateAll
|
||||
|
||||
Reference in New Issue
Block a user