From 010e237e0323b24864bfeb8caa59a4740ed116fe Mon Sep 17 00:00:00 2001 From: Martin Chacon Piza Date: Tue, 15 Dec 2020 10:50:08 +0100 Subject: [PATCH] Update hacking for Python3 The repo is Python 3 now, so update hacking to version 3.0 which supports Python 3. Fix problems found by updated hacking version. Remove hacking and friends from lower-constraints, they are not needed there at all. Align lower-constraints for new pip [1] Fix flake8 E305 and E117 and set W504 as ignored [1] http://lists.openstack.org/pipermail/openstack-discuss/2020-December/019285.html Change-Id: Idae87291f4556eee77d40ab49f0d151435d70875 (cherry picked from commit 35a9b57f9136b4ce735a00d788fa49133aa29abc) --- lower-constraints.txt | 12 ++++++------ monasca_notification/common/utils.py | 12 ++++++------ monasca_notification/plugins/email_notifier.py | 1 + monasca_notification/plugins/hipchat_notifier.py | 1 + monasca_notification/plugins/jira_notifier.py | 1 + monasca_notification/plugins/slack_notifier.py | 1 + monasca_notification/plugins/webhook_notifier.py | 1 + requirements.txt | 2 +- test-requirements.txt | 3 +-- tox.ini | 3 ++- 10 files changed, 21 insertions(+), 16 deletions(-) diff --git a/lower-constraints.txt b/lower-constraints.txt index 3f143d3..c293d14 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -1,4 +1,4 @@ -appdirs==1.3.0 +appdirs==1.4.0 Babel==2.3.4 bandit==1.4.0 configparser==3.5.0 @@ -7,21 +7,21 @@ debtcollector==1.2.0 docutils==0.11 extras==1.0.0 fixtures==3.0.0 -flake8==2.5.5 +flake8==3.6.0 funcsigs==1.0.0 future==0.16.0 gevent==1.2.2 gitdb==0.6.4 GitPython==1.0.1 greenlet==0.4.10 -hacking==0.12.0 +hacking==3.0.1 iso8601==0.1.11 Jinja2==2.10 jira==2.0.0 kazoo==2.2 keystoneauth1==3.4.0 linecache2==1.0.0 -mccabe==0.2.1 +mccabe==0.6.0 monasca-common==2.16.0 monasca-statsd==1.4.0 monotonic==0.6 @@ -39,10 +39,10 @@ oslo.policy==1.30.0 oslo.serialization==2.18.0 oslo.utils==3.33.0 oslotest==3.2.0 -pbr==2.0.0 +pbr==3.1.1 pep8==1.5.7 psycopg2==2.8.4 -pyflakes==0.8.1 +pyflakes==2.0.0 pyinotify==0.9.6 PyMySQL==0.7.6 pyparsing==2.1.0 diff --git a/monasca_notification/common/utils.py b/monasca_notification/common/utils.py index 67c9b61..e302eaa 100644 --- a/monasca_notification/common/utils.py +++ b/monasca_notification/common/utils.py @@ -70,13 +70,13 @@ def construct_notification_object(db_repo, notification_json): def grab_stored_notification_method(db_repo, notification_id): - try: - stored_notification = db_repo.get_notification(notification_id) - except exceptions.DatabaseException: - LOG.debug('Database Error. Attempting reconnect') - stored_notification = db_repo.get_notification(notification_id) + try: + stored_notification = db_repo.get_notification(notification_id) + except exceptions.DatabaseException: + LOG.debug('Database Error. Attempting reconnect') + stored_notification = db_repo.get_notification(notification_id) - return stored_notification + return stored_notification def get_statsd_client(dimensions=None): diff --git a/monasca_notification/plugins/email_notifier.py b/monasca_notification/plugins/email_notifier.py index ff1d6dd..7760f97 100644 --- a/monasca_notification/plugins/email_notifier.py +++ b/monasca_notification/plugins/email_notifier.py @@ -291,6 +291,7 @@ def _format_dimensions(notification): return dimensions + email_notifier_group = cfg.OptGroup(name='%s_notifier' % EmailNotifier.type) email_notifier_opts = [ cfg.StrOpt(name='from_addr'), diff --git a/monasca_notification/plugins/hipchat_notifier.py b/monasca_notification/plugins/hipchat_notifier.py index a5c9068..58e2d36 100644 --- a/monasca_notification/plugins/hipchat_notifier.py +++ b/monasca_notification/plugins/hipchat_notifier.py @@ -141,6 +141,7 @@ class HipChatNotifier(abstract_notifier.AbstractNotifier): self._log.exception("Error trying to send to hipchat on URL {}".format(url)) return False + hipchat_notifier_group = cfg.OptGroup(name='%s_notifier' % HipChatNotifier.type) hipchat_notifier_opts = [ cfg.IntOpt(name='timeout', default=5, min=1), diff --git a/monasca_notification/plugins/jira_notifier.py b/monasca_notification/plugins/jira_notifier.py index d0de668..55aeb2d 100644 --- a/monasca_notification/plugins/jira_notifier.py +++ b/monasca_notification/plugins/jira_notifier.py @@ -223,6 +223,7 @@ class JiraNotifier(AbstractNotifier): if jira_comment_message: jira_obj.add_comment(issue, jira_comment_message) + jira_notifier_group = cfg.OptGroup(name='%s_notifier' % JiraNotifier.type) jira_notifier_opts = [ cfg.IntOpt(name='timeout', default=5, min=1), diff --git a/monasca_notification/plugins/slack_notifier.py b/monasca_notification/plugins/slack_notifier.py index 98dbede..a7a8872 100644 --- a/monasca_notification/plugins/slack_notifier.py +++ b/monasca_notification/plugins/slack_notifier.py @@ -198,6 +198,7 @@ class SlackNotifier(abstract_notifier.AbstractNotifier): .format(url, data_format)) return False + slack_notifier_group = cfg.OptGroup(name='%s_notifier' % SlackNotifier.type) slack_notifier_opts = [ cfg.IntOpt(name='timeout', default=5, min=1), diff --git a/monasca_notification/plugins/webhook_notifier.py b/monasca_notification/plugins/webhook_notifier.py index e1d0e55..7ad10e8 100644 --- a/monasca_notification/plugins/webhook_notifier.py +++ b/monasca_notification/plugins/webhook_notifier.py @@ -91,6 +91,7 @@ class WebhookNotifier(abstract_notifier.AbstractNotifier): self._log.exception("Error trying to post on URL {}".format(url)) return False + webhook_notifier_group = cfg.OptGroup(name='%s_notifier' % WebhookNotifier.type) webhook_notifier_opts = [ cfg.IntOpt(name='timeout', default=5, min=1) diff --git a/requirements.txt b/requirements.txt index c947faf..a0b1e35 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ # The order of packages is significant, because pip processes them in the order # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -pbr!=2.1.0,>=2.0.0 # Apache-2.0 +pbr>=3.1.1 # Apache-2.0 debtcollector>=1.2.0 # Apache-2.0 keystoneauth1>=3.4.0 # Apache-2.0 monasca-statsd>=1.4.0 # Apache-2.0 diff --git a/test-requirements.txt b/test-requirements.txt index ff5a0c7..eb0bab8 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -5,11 +5,10 @@ bandit!=1.6.0,>=1.1.0 # Apache-2.0 Babel!=2.4.0,>=2.3.4 # BSD -hacking>=1.1.0,<1.2.0 # Apache-2.0 +hacking>=3.0.1,<3.1.0 # Apache-2.0 # remove this pyflakes from here once you bump the # hacking to 3.2.0 or above. hacking 3.2.0 takes # care of pyflakes version compatibilty. -pyflakes>=2.1.1 coverage!=4.4,>=4.0 # Apache-2.0 stestr>=1.0.0 # Apache-2.0 oslotest>=3.2.0 # Apache-2.0 diff --git a/tox.ini b/tox.ini index ba6e244..9c93e4e 100644 --- a/tox.ini +++ b/tox.ini @@ -67,7 +67,8 @@ max-line-length = 100 # H201 no 'except:' at least use 'except Exception:' # H202: assertRaises Exception too broad # H405 multi line docstring summary not separated with an empty line -ignore = F821,H201,H202,H405 +# W504 line break occurred after a binary operator +ignore = F821,H201,H202,H405,W504 exclude=.venv,.git,.tox,dist,*egg,build [hacking]