From 2d4b0ebee63b2ee9da0f2ea551eaf6b9159bb6d0 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Thu, 20 Jun 2019 12:28:47 +0900 Subject: [PATCH] Fix pep8 errors - E722 do not use bare 'except' Replace bare except clauses with explicit exception types. - E741 ambiguous variable name 'l' Rename 'l' to 'locale' In addition this patch squashes 684782 to use older werkzeug version to not face with exceptions. Generally this patch fixes lodgeit CI. Also, add tox jobs to in-tree zuul config These were defined in project-config, but we don't need to manage that centrally. Change-Id: Id750715472f88fa5dba0a2414fb1667df4a6dc40 Signed-off-by: David Pursehouse --- .zuul.yaml | 10 ++++++++++ lodgeit/__init__.py | 2 +- lodgeit/i18n/__init__.py | 6 +++--- lodgeit/utils.py | 2 +- requirements.txt | 2 +- tox.ini | 1 + 6 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 .zuul.yaml diff --git a/.zuul.yaml b/.zuul.yaml new file mode 100644 index 0000000..bd9ba2b --- /dev/null +++ b/.zuul.yaml @@ -0,0 +1,10 @@ +- project: + check: + jobs: + - tox-pep8 + - tox-py27 + gate: + jobs: + - tox-pep8 + - tox-py27 + diff --git a/lodgeit/__init__.py b/lodgeit/__init__.py index ed4ff83..521f335 100644 --- a/lodgeit/__init__.py +++ b/lodgeit/__init__.py @@ -13,5 +13,5 @@ import subprocess try: lodgeit_version = subprocess.check_output(['git', 'rev-parse', 'HEAD'])[:7] -except: +except Exception: lodgeit_version = "" diff --git a/lodgeit/i18n/__init__.py b/lodgeit/i18n/__init__.py index 3fa716a..f4884ff 100644 --- a/lodgeit/i18n/__init__.py +++ b/lodgeit/i18n/__init__.py @@ -64,10 +64,10 @@ def list_languages(): os.path.isdir(os.path.join(folder, filename)): continue try: - l = Locale.parse(filename) + locale = Locale.parse(filename) except UnknownLocaleError: continue - languages.append((str(l), l.display_name)) + languages.append((str(locale), locale.display_name)) languages.sort(key=lambda x: x[1].lower()) return languages @@ -170,7 +170,7 @@ class _TranslationProxy(object): def __repr__(self): try: return 'i' + repr(unicode(self.value)) - except: + except ValueError: return '<%s broken>' % self.__class__.__name__ diff --git a/lodgeit/utils.py b/lodgeit/utils.py index f4e0bde..34235e0 100644 --- a/lodgeit/utils.py +++ b/lodgeit/utils.py @@ -26,7 +26,7 @@ from lodgeit.i18n import get_translations try: from hashlib import sha1 -except: +except ImportError: from sha import new as sha1 #: Jinja2 Environment for our template handling diff --git a/requirements.txt b/requirements.txt index d6cbb84..e748eb4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ Jinja2 -Werkzeug +Werkzeug<0.16 Pygments SQLAlchemy==0.9.7 simplejson diff --git a/tox.ini b/tox.ini index d22eb75..79fc2dc 100644 --- a/tox.ini +++ b/tox.ini @@ -10,6 +10,7 @@ deps = -r{toxinidir}/requirements.txt commands = nosetests [testenv:pep8] +basepython = python2 commands = flake8 [flake8]