diff --git a/examples/claims.py b/examples/claims.py index 5925fc44..31695f4a 100644 --- a/examples/claims.py +++ b/examples/claims.py @@ -46,6 +46,7 @@ def process_jobs(): msg.delete() time.sleep(0.5) + if __name__ == '__main__': while True: send_jobs() diff --git a/examples/management.py b/examples/management.py index e25d3cbe..8a2cd965 100644 --- a/examples/management.py +++ b/examples/management.py @@ -25,5 +25,6 @@ def healthy(): cli = client.Client(url=URL, version=2) return True if cli.health() else False + if __name__ == '__main__': healthy() diff --git a/examples/simple.py b/examples/simple.py index 8213f718..b5c4d84a 100644 --- a/examples/simple.py +++ b/examples/simple.py @@ -44,6 +44,7 @@ def create_post_delete(queue_name, messages): queue.delete() + if __name__ == '__main__': messages = [{'body': {'id': idx}, 'ttl': 360} for idx in range(20)] diff --git a/test-requirements.txt b/test-requirements.txt index d0f6f0f1..879bf767 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,7 +2,7 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. # Hacking already pins down pep8, pyflakes and flake8 -hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0 +hacking>=3.0,<3.1.0 # Apache-2.0 # Unit testing fixtures>=3.0.0 # Apache-2.0/BSD diff --git a/tox.ini b/tox.ini index ab093fa5..98ec479e 100644 --- a/tox.ini +++ b/tox.ini @@ -50,6 +50,8 @@ commands = sphinx-build -a -E -d releasenotes/build/doctrees -b html releasenote [flake8] builtins = _ exclude = .venv,.git,.tox,dist,doc,*.egg +# W504 line break after binary operator +ignore = W504 [testenv:lower-constraints] deps = diff --git a/zaqarclient/_i18n.py b/zaqarclient/_i18n.py index ac2e5323..c5fd3d48 100644 --- a/zaqarclient/_i18n.py +++ b/zaqarclient/_i18n.py @@ -15,7 +15,7 @@ from oslo_i18n import * # noqa -_translators = TranslatorFactory(domain='zaqarclient') +_translators = TranslatorFactory(domain='zaqarclient') # noqa: F405 # The primary translation function using the well-known name "_" _ = _translators.primary diff --git a/zaqarclient/queues/v1/cli.py b/zaqarclient/queues/v1/cli.py index 8c3c758b..38489a32 100644 --- a/zaqarclient/queues/v1/cli.py +++ b/zaqarclient/queues/v1/cli.py @@ -476,7 +476,7 @@ class UpdatePool(command.ShowOne): """Update a pool attribute""" _description = _("Update a pool attribute") - log = logging.getLogger(__name__+".UpdatePool") + log = logging.getLogger(__name__ + ".UpdatePool") def get_parser(self, prog_name): parser = super(UpdatePool, self).get_parser(prog_name) @@ -648,7 +648,7 @@ class UpdateFlavor(command.ShowOne): """Update a flavor's attributes""" _description = _("Update a flavor's attributes") - log = logging.getLogger(__name__+".UpdateFlavor") + log = logging.getLogger(__name__ + ".UpdateFlavor") def get_parser(self, prog_name): parser = super(UpdateFlavor, self).get_parser(prog_name) diff --git a/zaqarclient/queues/v1/queues.py b/zaqarclient/queues/v1/queues.py index e0911ab8..2e2b4d4d 100644 --- a/zaqarclient/queues/v1/queues.py +++ b/zaqarclient/queues/v1/queues.py @@ -24,7 +24,7 @@ from zaqarclient.queues.v1 import message # NOTE(wanghao): This is copied from Zaqar server side, so if server have # updated it someday, we should update it here to keep consistent. -QUEUE_NAME_REGEX = re.compile('^[a-zA-Z0-9_\-]+$') +QUEUE_NAME_REGEX = re.compile(r'^[a-zA-Z0-9_\-]+$') class Queue(object): diff --git a/zaqarclient/tests/base.py b/zaqarclient/tests/base.py index 9af90ec8..a3999053 100644 --- a/zaqarclient/tests/base.py +++ b/zaqarclient/tests/base.py @@ -102,6 +102,6 @@ class TestBase(testtools.TestCase): If a group argument is supplied, the overrides are applied to the specified configuration option group. """ - parent = (group and self.conf.setdefault(group, {}) - or self.conf) + parent = (group and self.conf.setdefault(group, {}) or + self.conf) parent.update(kw)