From 36e293b5d5322c15cb612356616357e2df2c6f52 Mon Sep 17 00:00:00 2001 From: Radoslaw Smigielski Date: Fri, 23 Jan 2015 15:40:41 +0000 Subject: [PATCH] Fixing PEP8 E712 and E265 1. PEP8 E712, removed singleton comparison using '==' operator: E712 comparison to True should be 'if cond is True:'or 'if cond:' Two places. 2. Fix PEP8 E265 block comment syntax. E265 block comment should start with '# ' 3. No more E712 so removed it from tox.ini ignored list. Change-Id: I778aa5c4e1458cccb7a34d087b3b59eceadd45d0 --- glance_store/_drivers/filesystem.py | 2 +- glance_store/_drivers/swift/store.py | 8 ++++---- glance_store/tests/base.py | 2 +- glance_store/tests/utils.py | 2 +- test-requirements.txt | 4 +++- tests/unit/test_swift_store.py | 2 +- tox.ini | 3 +-- 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/glance_store/_drivers/filesystem.py b/glance_store/_drivers/filesystem.py index f91d0063..c65e780c 100644 --- a/glance_store/_drivers/filesystem.py +++ b/glance_store/_drivers/filesystem.py @@ -493,7 +493,7 @@ class Store(glance_store.driver.Store): :mount_point is path of glance data directory """ - #Calculate total available space + # Calculate total available space stvfs_result = os.statvfs(mount_point) total_available_space = stvfs_result.f_bavail * stvfs_result.f_bsize return max(0, total_available_space) diff --git a/glance_store/_drivers/swift/store.py b/glance_store/_drivers/swift/store.py index 56196eb4..e49c61e0 100644 --- a/glance_store/_drivers/swift/store.py +++ b/glance_store/_drivers/swift/store.py @@ -208,13 +208,13 @@ class StoreLocation(location.StoreLocation): obj = self.obj.strip('/') if not credentials_included: - #Used only in case of an add - #Get the current store from config + # Used only in case of an add + # Get the current store from config store = self.conf.glance_store.default_swift_reference return '%s://%s/%s/%s' % ('swift+config', store, container, obj) if self.scheme == 'swift+config': - if self.ssl_enabled == True: + if self.ssl_enabled: self.scheme = 'swift+https' else: self.scheme = 'swift+http' @@ -346,7 +346,7 @@ class StoreLocation(location.StoreLocation): return self.auth_or_store_url else: if self.scheme == 'swift+config': - if self.ssl_enabled == True: + if self.ssl_enabled: self.scheme = 'swift+https' else: self.scheme = 'swift+http' diff --git a/glance_store/tests/base.py b/glance_store/tests/base.py index 0f07e355..cb848be4 100644 --- a/glance_store/tests/base.py +++ b/glance_store/tests/base.py @@ -27,7 +27,7 @@ from glance_store import location class StoreBaseTest(base.BaseTestCase): - #NOTE(flaper87): temporary until we + # NOTE(flaper87): temporary until we # can move to a fully-local lib. # (Swift store's fault) _CONF = cfg.ConfigOpts() diff --git a/glance_store/tests/utils.py b/glance_store/tests/utils.py index b301822d..52b08080 100644 --- a/glance_store/tests/utils.py +++ b/glance_store/tests/utils.py @@ -19,7 +19,7 @@ import urlparse def sort_url_by_qs_keys(url): - #NOTE(kragniz): this only sorts the keys of the query string of a url. + # NOTE(kragniz): this only sorts the keys of the query string of a url. # For example, an input of '/v2/tasks?sort_key=id&sort_dir=asc&limit=10' # returns '/v2/tasks?limit=10&sort_dir=asc&sort_key=id'. This is to prevent # non-deterministic ordering of the query string causing problems with unit diff --git a/test-requirements.txt b/test-requirements.txt index 779d3a3e..abf35097 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -18,7 +18,9 @@ oslotest sphinx>=1.1.2,!=1.2.0,<1.3 oslosphinx -### Store specific packages +# +# Store specific packages +# # For S3 storage backend boto>=2.12.0,!=2.13.0 diff --git a/tests/unit/test_swift_store.py b/tests/unit/test_swift_store.py index 84a9b944..e0a1a4c7 100644 --- a/tests/unit/test_swift_store.py +++ b/tests/unit/test_swift_store.py @@ -247,7 +247,7 @@ class SwiftTests(object): uri = ("swift://%s:key@auth_address/glance/%s" % (self.swift_store_user, FAKE_UUID)) self.config(swift_store_multi_tenant=True) - #NOTE(markwash): ensure the image is found + # NOTE(markwash): ensure the image is found size = backend.get_size_from_backend(uri, context={}) self.assertEqual(size, 5120) diff --git a/tox.ini b/tox.ini index b602a0c3..98db88d4 100644 --- a/tox.ini +++ b/tox.ini @@ -28,9 +28,8 @@ commands = {posargs} [flake8] # TODO(dmllr): Analyze or fix the warnings blacklisted below # E711 comparison to None should be 'if cond is not None:' -# E712 comparison to True should be 'if cond is True:' or 'if cond:' # H301 one import per line # H404 multi line docstring should start with a summary -ignore = E711,E712,H301,H404 +ignore = E711,H301,H404 builtins = _ exclude = .venv,.git,.tox,dist,doc,etc,*glance_store/locale*,*openstack/common*,*lib/python*,*egg,build