From af88d16028e2e266a62028fe1927c61d80c68b8c Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 10 Nov 2017 16:40:45 +0100 Subject: [PATCH] Python2: Fix tox -e py27 With this change, unit tests now pass on Python 2.7: tox -e py27. Changes: * Replace "yield from ..." with "for item in ...: yield item" * Remove last annotations from utils.py * tox.ini: use python3 as basepython rather than python3.5 to support Python 2.7 and Python 3.6 * tox.ini: add py27 to envlist Related-Bug: 1726399 Change-Id: Ief1a95402e8a31a34ada2937a7ae6a604f7f8757 --- ospurge/resources/swift.py | 3 ++- ospurge/utils.py | 4 ++-- tox.ini | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ospurge/resources/swift.py b/ospurge/resources/swift.py index 121c3b8..95d75b5 100644 --- a/ospurge/resources/swift.py +++ b/ospurge/resources/swift.py @@ -30,7 +30,8 @@ class Objects(base.ServiceResource, glance.ListImagesMixin, ListObjectsMixin): self.cloud.list_volume_backups() == []) def list(self): - yield from self.list_objects() + for item in self.list_objects(): + yield item def delete(self, resource): self.cloud.delete_object(resource['container_name'], resource['name']) diff --git a/ospurge/utils.py b/ospurge/utils.py index 8830f37..07dae58 100644 --- a/ospurge/utils.py +++ b/ospurge/utils.py @@ -59,12 +59,12 @@ def monkeypatch_oscc_logging_warning(f): oscc_target = 'os_client_config.cloud_config' orig_logging = logging.getLogger(oscc_target).warning - def logging_warning(msg: str, *args, **kwargs): + def logging_warning(msg, *args, **kwargs): if 'catalog entry not found' not in msg: orig_logging(msg, *args, **kwargs) @functools.wraps(f) - def wrapper(*args: list, **kwargs): + def wrapper(*args, **kwargs): try: setattr(logging.getLogger(oscc_target), 'warning', logging_warning) return f(*args, **kwargs) diff --git a/tox.ini b/tox.ini index 198e5bc..a5fbb51 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = pep8,pip-check-reqs,cover,py35 +envlist = pep8,pip-check-reqs,cover,py35,py27 minversion = 1.9 skipsdist = True @@ -8,13 +8,12 @@ usedevelop=True deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt -basepython = - run,pep8,cover,mypy,pip-check-reqs,py35,functional: python3.5 - docs,venv: python2 +basepython = python3 commands = python setup.py testr --testr-args='{posargs}' [testenv:venv] +basepython = python2.7 commands = {posargs} [testenv:run] @@ -60,6 +59,7 @@ commands= pip-missing-reqs -d ospurge [testenv:docs] +basepython = python2.7 whitelist_externals = echo skip_install = True deps =