1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-10 17:45:35 +00:00

Upgrade Python syntax with pyupgrade

This commit is contained in:
Hugo
2019-05-22 17:44:36 +03:00
parent 7670e10bc2
commit 8f4e089200
5 changed files with 8 additions and 8 deletions

View File

@@ -44,7 +44,7 @@ def proxy_server():
target=httpd.serve_forever, target=httpd.serve_forever,
) )
proxy_process.start() proxy_process.start()
yield 'http://{0}:{1}'.format(*httpd.server_address) yield 'http://{}:{}'.format(*httpd.server_address)
proxy_process.terminate() proxy_process.terminate()

View File

@@ -68,7 +68,7 @@ def _migrate(data):
for item in data: for item in data:
req = item['request'] req = item['request']
res = item['response'] res = item['response']
uri = dict((k, req.pop(k)) for k in PARTS) uri = {k: req.pop(k) for k in PARTS}
req['uri'] = build_uri(**uri) req['uri'] = build_uri(**uri)
# convert headers to dict of lists # convert headers to dict of lists
headers = req['headers'] headers = req['headers']
@@ -100,7 +100,7 @@ def migrate_json(in_fp, out_fp):
def _list_of_tuples_to_dict(fs): def _list_of_tuples_to_dict(fs):
return dict((k, v) for k, v in fs[0]) return {k: v for k, v in fs[0]}
def _already_migrated(data): def _already_migrated(data):

View File

@@ -91,7 +91,7 @@ class Request(object):
'method': self.method, 'method': self.method,
'uri': self.uri, 'uri': self.uri,
'body': self.body, 'body': self.body,
'headers': dict(((k, [v]) for k, v in self.headers.items())), 'headers': {k: [v] for k, v in self.headers.items()},
} }
@classmethod @classmethod

View File

@@ -139,7 +139,7 @@ class VCRConnection(object):
if url and not url.startswith('/'): if url and not url.startswith('/'):
# Then this must be a proxy request. # Then this must be a proxy request.
return url return url
uri = "{0}://{1}{2}{3}".format( uri = "{}://{}{}{}".format(
self._protocol, self._protocol,
self.real_connection.host, self.real_connection.host,
self._port_postfix(), self._port_postfix(),

View File

@@ -118,10 +118,10 @@ def auto_decorate(
) )
def __new__(cls, name, bases, attributes_dict): def __new__(cls, name, bases, attributes_dict):
new_attributes_dict = dict( new_attributes_dict = {
(attribute, maybe_decorate(attribute, value)) attribute: maybe_decorate(attribute, value)
for attribute, value in attributes_dict.items() for attribute, value in attributes_dict.items()
) }
return super(DecorateAll, cls).__new__( return super(DecorateAll, cls).__new__(
cls, name, bases, new_attributes_dict cls, name, bases, new_attributes_dict
) )