From dc174c325037bb968bf3f7d541507d1be50fcd89 Mon Sep 17 00:00:00 2001 From: Hugo Date: Wed, 22 May 2019 17:30:45 +0300 Subject: [PATCH 1/3] Drop support for EOL Python 3.4 --- .travis.yml | 12 ------------ docs/installation.rst | 2 +- setup.py | 7 ++----- tox.ini | 2 +- 4 files changed, 4 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 17a2546..180b1dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ language: python -sudo: false before_install: openssl version env: global: @@ -18,37 +17,27 @@ matrix: - env: TOX_SUFFIX="flakes" python: 3.7 dist: xenial - sudo: true - env: TOX_SUFFIX="requests27" python: 3.7 dist: xenial - sudo: true - env: TOX_SUFFIX="httplib2" python: 3.7 dist: xenial - sudo: true - env: TOX_SUFFIX="urllib3121" python: 3.7 dist: xenial - sudo: true - env: TOX_SUFFIX="tornado4" python: 3.7 dist: xenial - sudo: true - env: TOX_SUFFIX="aiohttp" python: 3.7 dist: xenial - sudo: true allow_failures: - env: TOX_SUFFIX="boto3" - env: TOX_SUFFIX="aiohttp" python: "pypy3.5-5.9.0" - - env: TOX_SUFFIX="aiohttp" - python: 3.4 exclude: # Only run flakes on a single Python 2.x and a single 3.x - - env: TOX_SUFFIX="flakes" - python: 3.4 - env: TOX_SUFFIX="flakes" python: 3.5 - env: TOX_SUFFIX="flakes" @@ -61,7 +50,6 @@ matrix: python: pypy python: - 2.7 -- 3.4 - 3.5 - 3.6 - pypy diff --git a/docs/installation.rst b/docs/installation.rst index afec93b..8e475e0 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -9,7 +9,7 @@ with pip:: Compatibility ------------- -VCR.py supports Python 2.7 and 3.4+, and +VCR.py supports Python 2.7 and 3.5+, and `pypy `__. The following HTTP libraries are supported: diff --git a/setup.py b/setup.py index 3c84091..ad54f83 100644 --- a/setup.py +++ b/setup.py @@ -28,9 +28,7 @@ install_requires = [ 'six>=1.5', 'contextlib2; python_version=="2.7"', 'mock; python_version=="2.7"', - 'yarl; python_version>"3.4"', - 'yarl<1.0.0; python_version=="3.4"', - 'multidict<4.0.0,>=2.0; python_version=="3.4"' + 'yarl; python_version>"3.5"', ] excluded_packages = ["tests*"] @@ -49,7 +47,7 @@ setup( author_email='me@kevinmccarthy.org', url='https://github.com/kevin1024/vcrpy', packages=find_packages(exclude=excluded_packages), - python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*', + python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*', install_requires=install_requires, license='MIT', tests_require=['pytest', 'mock', 'pytest-httpbin'], @@ -61,7 +59,6 @@ setup( 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', diff --git a/tox.ini b/tox.ini index bd99f42..865cd62 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = {py27,py34,py35,py36,py37,pypy}-{flakes,requests27,httplib2,urllib3121,tornado4,boto3,aiohttp} +envlist = {py27,py35,py36,py37,pypy}-{flakes,requests27,httplib2,urllib3121,tornado4,boto3,aiohttp} [testenv:flakes] skipsdist = True From 7670e10bc2550308b8459d02b1a1513079c3489f Mon Sep 17 00:00:00 2001 From: Hugo Date: Wed, 22 May 2019 17:35:15 +0300 Subject: [PATCH 2/3] Fix Flake8: E117 over-indented --- vcr/migration.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vcr/migration.py b/vcr/migration.py index ba5ae2c..919494f 100644 --- a/vcr/migration.py +++ b/vcr/migration.py @@ -159,9 +159,9 @@ def main(): for (root, dirs, files) in os.walk(path) for name in files) for file_path in files: - migrated = try_migrate(file_path) - status = 'OK' if migrated else 'FAIL' - sys.stderr.write("[{}] {}\n".format(status, file_path)) + migrated = try_migrate(file_path) + status = 'OK' if migrated else 'FAIL' + sys.stderr.write("[{}] {}\n".format(status, file_path)) sys.stderr.write("Done.\n") From 8f4e089200c8d434a1311ab7334daa434688468d Mon Sep 17 00:00:00 2001 From: Hugo Date: Wed, 22 May 2019 17:44:36 +0300 Subject: [PATCH 3/3] Upgrade Python syntax with pyupgrade --- tests/integration/test_proxy.py | 2 +- vcr/migration.py | 4 ++-- vcr/request.py | 2 +- vcr/stubs/__init__.py | 2 +- vcr/util.py | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/integration/test_proxy.py b/tests/integration/test_proxy.py index 9b3c4ad..09db775 100644 --- a/tests/integration/test_proxy.py +++ b/tests/integration/test_proxy.py @@ -44,7 +44,7 @@ def proxy_server(): target=httpd.serve_forever, ) proxy_process.start() - yield 'http://{0}:{1}'.format(*httpd.server_address) + yield 'http://{}:{}'.format(*httpd.server_address) proxy_process.terminate() diff --git a/vcr/migration.py b/vcr/migration.py index 919494f..435f464 100644 --- a/vcr/migration.py +++ b/vcr/migration.py @@ -68,7 +68,7 @@ def _migrate(data): for item in data: req = item['request'] 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) # convert headers to dict of lists headers = req['headers'] @@ -100,7 +100,7 @@ def migrate_json(in_fp, out_fp): 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): diff --git a/vcr/request.py b/vcr/request.py index e268053..09c83f4 100644 --- a/vcr/request.py +++ b/vcr/request.py @@ -91,7 +91,7 @@ class Request(object): 'method': self.method, 'uri': self.uri, '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 diff --git a/vcr/stubs/__init__.py b/vcr/stubs/__init__.py index a23a731..c01ba59 100644 --- a/vcr/stubs/__init__.py +++ b/vcr/stubs/__init__.py @@ -139,7 +139,7 @@ class VCRConnection(object): if url and not url.startswith('/'): # Then this must be a proxy request. return url - uri = "{0}://{1}{2}{3}".format( + uri = "{}://{}{}{}".format( self._protocol, self.real_connection.host, self._port_postfix(), diff --git a/vcr/util.py b/vcr/util.py index 34185e2..c7ababb 100644 --- a/vcr/util.py +++ b/vcr/util.py @@ -118,10 +118,10 @@ def auto_decorate( ) def __new__(cls, name, bases, attributes_dict): - new_attributes_dict = dict( - (attribute, maybe_decorate(attribute, value)) + new_attributes_dict = { + attribute: maybe_decorate(attribute, value) for attribute, value in attributes_dict.items() - ) + } return super(DecorateAll, cls).__new__( cls, name, bases, new_attributes_dict )