From 7359c976d1692c63118fd8b67ff215c9498725e7 Mon Sep 17 00:00:00 2001
From: Dirk Mueller <dirk@dmllr.de>
Date: Sun, 9 Jun 2013 11:18:02 +0200
Subject: [PATCH] Start Gating on Pyflakes and Hacking

Instead of globally ignoring Pyflakes and Hacking
warnings, only blacklist those that occur frequently
and fix the others. Start gating on those checks.

Change-Id: Ice032c16d445ef08ef018bcdc5c221ab3c323755
---
 cinderclient/base.py                | 2 +-
 cinderclient/client.py              | 3 ++-
 cinderclient/exceptions.py          | 6 ++++--
 cinderclient/service_catalog.py     | 5 +++--
 cinderclient/tests/test_shell.py    | 1 -
 cinderclient/tests/test_utils.py    | 2 +-
 cinderclient/tests/utils.py         | 5 +++--
 cinderclient/tests/v1/test_shell.py | 2 --
 cinderclient/tests/v1/test_types.py | 1 -
 cinderclient/v1/__init__.py         | 2 +-
 cinderclient/v1/limits.py           | 8 ++++----
 cinderclient/v1/quota_classes.py    | 3 ++-
 cinderclient/v1/quotas.py           | 5 +++--
 cinderclient/v1/shell.py            | 6 +++---
 cinderclient/v2/__init__.py         | 2 +-
 cinderclient/v2/limits.py           | 8 ++++----
 cinderclient/v2/quota_classes.py    | 2 +-
 cinderclient/v2/quotas.py           | 2 +-
 cinderclient/v2/shell.py            | 6 +++---
 tox.ini                             | 2 +-
 20 files changed, 38 insertions(+), 35 deletions(-)

diff --git a/cinderclient/base.py b/cinderclient/base.py
index 6024f59c3..1822dfb2b 100644
--- a/cinderclient/base.py
+++ b/cinderclient/base.py
@@ -104,7 +104,7 @@ class Manager(utils.HookableMixin):
         cache_dir = os.path.expanduser(os.path.join(base_dir, uniqifier))
 
         try:
-            os.makedirs(cache_dir, 0755)
+            os.makedirs(cache_dir, 0o755)
         except OSError:
             # NOTE(kiall): This is typicaly either permission denied while
             #              attempting to create the directory, or the directory
diff --git a/cinderclient/client.py b/cinderclient/client.py
index 0cdb861c3..755ffcb83 100644
--- a/cinderclient/client.py
+++ b/cinderclient/client.py
@@ -207,7 +207,8 @@ class HTTPClient(object):
     def _extract_service_catalog(self, url, resp, body, extract_token=True):
         """See what the auth service told us and process the response.
         We may get redirected to another site, fail or actually get
-        back a service catalog with a token and our endpoints."""
+        back a service catalog with a token and our endpoints.
+        """
 
         if resp.status_code == 200:  # content must always present
             try:
diff --git a/cinderclient/exceptions.py b/cinderclient/exceptions.py
index d7be18088..d381246f8 100644
--- a/cinderclient/exceptions.py
+++ b/cinderclient/exceptions.py
@@ -6,7 +6,8 @@ Exception definitions.
 
 class UnsupportedVersion(Exception):
     """Indicates that the user is trying to use an unsupported
-    version of the API"""
+    version of the API.
+    """
     pass
 
 
@@ -24,7 +25,8 @@ class NoUniqueMatch(Exception):
 
 class NoTokenLookupException(Exception):
     """This form of authentication does not support looking up
-       endpoints from an existing token."""
+       endpoints from an existing token.
+    """
     pass
 
 
diff --git a/cinderclient/service_catalog.py b/cinderclient/service_catalog.py
index e1778db8d..2be335ac4 100644
--- a/cinderclient/service_catalog.py
+++ b/cinderclient/service_catalog.py
@@ -33,7 +33,8 @@ class ServiceCatalog(object):
                 service_name=None, volume_service_name=None):
         """Fetch the public URL from the Compute service for
         a particular endpoint attribute. If none given, return
-        the first. See tests for sample service catalog."""
+        the first. See tests for sample service catalog.
+        """
         matching_endpoints = []
         if 'endpoints' in self.catalog:
             # We have a bastardized service catalog. Treat it special. :/
@@ -44,7 +45,7 @@ class ServiceCatalog(object):
                 raise cinderclient.exceptions.EndpointNotFound()
 
         # We don't always get a service catalog back ...
-        if not 'serviceCatalog' in self.catalog['access']:
+        if 'serviceCatalog' not in self.catalog['access']:
             return None
 
         # Full catalog ...
diff --git a/cinderclient/tests/test_shell.py b/cinderclient/tests/test_shell.py
index 8ebe0f7ad..c3a195fb2 100644
--- a/cinderclient/tests/test_shell.py
+++ b/cinderclient/tests/test_shell.py
@@ -1,5 +1,4 @@
 import cStringIO
-import os
 import re
 import sys
 
diff --git a/cinderclient/tests/test_utils.py b/cinderclient/tests/test_utils.py
index 95b50d0a0..fc6128536 100644
--- a/cinderclient/tests/test_utils.py
+++ b/cinderclient/tests/test_utils.py
@@ -79,7 +79,7 @@ class FindResourceTestCase(test_utils.TestCase):
 
 
 class CaptureStdout(object):
-    """Context manager for capturing stdout from statments in its's block"""
+    """Context manager for capturing stdout from statments in its's block."""
     def __enter__(self):
         self.real_stdout = sys.stdout
         self.stringio = StringIO.StringIO()
diff --git a/cinderclient/tests/utils.py b/cinderclient/tests/utils.py
index 3a1292372..0ab873778 100644
--- a/cinderclient/tests/utils.py
+++ b/cinderclient/tests/utils.py
@@ -23,8 +23,9 @@ class TestCase(testtools.TestCase):
 
 
 class TestResponse(requests.Response):
-    """ Class used to wrap requests.Response and provide some
-        convenience to initialize with a dict """
+    """Class used to wrap requests.Response and provide some
+       convenience to initialize with a dict.
+    """
 
     def __init__(self, data):
         self._text = None
diff --git a/cinderclient/tests/v1/test_shell.py b/cinderclient/tests/v1/test_shell.py
index 9e8e2f7c0..b3c7abfd0 100644
--- a/cinderclient/tests/v1/test_shell.py
+++ b/cinderclient/tests/v1/test_shell.py
@@ -15,8 +15,6 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import os
-
 import fixtures
 
 from cinderclient import client
diff --git a/cinderclient/tests/v1/test_types.py b/cinderclient/tests/v1/test_types.py
index 41a89b75a..6d7dd28e8 100644
--- a/cinderclient/tests/v1/test_types.py
+++ b/cinderclient/tests/v1/test_types.py
@@ -1,4 +1,3 @@
-from cinderclient import exceptions
 from cinderclient.v1 import volume_types
 from cinderclient.tests import utils
 from cinderclient.tests.v1 import fakes
diff --git a/cinderclient/v1/__init__.py b/cinderclient/v1/__init__.py
index cecfacd23..fbb7b0077 100644
--- a/cinderclient/v1/__init__.py
+++ b/cinderclient/v1/__init__.py
@@ -14,4 +14,4 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from cinderclient.v1.client import Client
+from cinderclient.v1.client import Client     # noqa
diff --git a/cinderclient/v1/limits.py b/cinderclient/v1/limits.py
index 2008a6909..007c533ee 100644
--- a/cinderclient/v1/limits.py
+++ b/cinderclient/v1/limits.py
@@ -4,7 +4,7 @@ from cinderclient import base
 
 
 class Limits(base.Resource):
-    """A collection of RateLimit and AbsoluteLimit objects"""
+    """A collection of RateLimit and AbsoluteLimit objects."""
 
     def __repr__(self):
         return "<Limits>"
@@ -26,7 +26,7 @@ class Limits(base.Resource):
 
 
 class RateLimit(object):
-    """Data model that represents a flattened view of a single rate limit"""
+    """Data model that represents a flattened view of a single rate limit."""
 
     def __init__(self, verb, uri, regex, value, remain,
                  unit, next_available):
@@ -52,7 +52,7 @@ class RateLimit(object):
 
 
 class AbsoluteLimit(object):
-    """Data model that represents a single absolute limit"""
+    """Data model that represents a single absolute limit."""
 
     def __init__(self, name, value):
         self.name = name
@@ -66,7 +66,7 @@ class AbsoluteLimit(object):
 
 
 class LimitsManager(base.Manager):
-    """Manager object used to interact with limits resource"""
+    """Manager object used to interact with limits resource."""
 
     resource_class = Limits
 
diff --git a/cinderclient/v1/quota_classes.py b/cinderclient/v1/quota_classes.py
index caadd486f..669602454 100644
--- a/cinderclient/v1/quota_classes.py
+++ b/cinderclient/v1/quota_classes.py
@@ -21,7 +21,8 @@ class QuotaClassSet(base.Resource):
     @property
     def id(self):
         """QuotaClassSet does not have a 'id' attribute but base.Resource
-        needs it to self-refresh and QuotaSet is indexed by class_name"""
+        needs it to self-refresh and QuotaSet is indexed by class_name.
+        """
         return self.class_name
 
     def update(self, *args, **kwargs):
diff --git a/cinderclient/v1/quotas.py b/cinderclient/v1/quotas.py
index 846fb13b2..a463b8192 100644
--- a/cinderclient/v1/quotas.py
+++ b/cinderclient/v1/quotas.py
@@ -20,8 +20,9 @@ class QuotaSet(base.Resource):
 
     @property
     def id(self):
-        """QuotaSet does not have a 'id' attribute but base.Resource needs it
-        to self-refresh and QuotaSet is indexed by tenant_id"""
+        """QuotaSet does not have a 'id' attribute but base. Resource needs it
+        to self-refresh and QuotaSet is indexed by tenant_id.
+        """
         return self.tenant_id
 
     def update(self, *args, **kwargs):
diff --git a/cinderclient/v1/shell.py b/cinderclient/v1/shell.py
index 214a47502..51f47023a 100644
--- a/cinderclient/v1/shell.py
+++ b/cinderclient/v1/shell.py
@@ -462,7 +462,7 @@ def do_type_create(cs, args):
            help="Unique ID of the volume type to delete")
 @utils.service_type('volume')
 def do_type_delete(cs, args):
-    """Delete a specific volume type"""
+    """Delete a specific volume type."""
     cs.volume_types.delete(args.id)
 
 
@@ -493,14 +493,14 @@ def do_type_key(cs, args):
 
 
 def do_endpoints(cs, args):
-    """Discover endpoints that get returned from the authenticate services"""
+    """Discover endpoints that get returned from the authenticate services."""
     catalog = cs.client.service_catalog.catalog
     for e in catalog['access']['serviceCatalog']:
         utils.print_dict(e['endpoints'][0], e['name'])
 
 
 def do_credentials(cs, args):
-    """Show user credentials returned from auth"""
+    """Show user credentials returned from auth."""
     catalog = cs.client.service_catalog.catalog
     utils.print_dict(catalog['access']['user'], "User Credentials")
     utils.print_dict(catalog['access']['token'], "Token")
diff --git a/cinderclient/v2/__init__.py b/cinderclient/v2/__init__.py
index 5408cd3bd..d09fab5bd 100644
--- a/cinderclient/v2/__init__.py
+++ b/cinderclient/v2/__init__.py
@@ -14,4 +14,4 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from cinderclient.v2.client import Client
+from cinderclient.v2.client import Client    # noqa
diff --git a/cinderclient/v2/limits.py b/cinderclient/v2/limits.py
index d076db8a1..72f9ea652 100644
--- a/cinderclient/v2/limits.py
+++ b/cinderclient/v2/limits.py
@@ -4,7 +4,7 @@ from cinderclient import base
 
 
 class Limits(base.Resource):
-    """A collection of RateLimit and AbsoluteLimit objects"""
+    """A collection of RateLimit and AbsoluteLimit objects."""
 
     def __repr__(self):
         return "<Limits>"
@@ -26,7 +26,7 @@ class Limits(base.Resource):
 
 
 class RateLimit(object):
-    """Data model that represents a flattened view of a single rate limit"""
+    """Data model that represents a flattened view of a single rate limit."""
 
     def __init__(self, verb, uri, regex, value, remain,
                  unit, next_available):
@@ -52,7 +52,7 @@ class RateLimit(object):
 
 
 class AbsoluteLimit(object):
-    """Data model that represents a single absolute limit"""
+    """Data model that represents a single absolute limit."""
 
     def __init__(self, name, value):
         self.name = name
@@ -66,7 +66,7 @@ class AbsoluteLimit(object):
 
 
 class LimitsManager(base.Manager):
-    """Manager object used to interact with limits resource"""
+    """Manager object used to interact with limits resource."""
 
     resource_class = Limits
 
diff --git a/cinderclient/v2/quota_classes.py b/cinderclient/v2/quota_classes.py
index cc0b75320..0a2a8df40 100644
--- a/cinderclient/v2/quota_classes.py
+++ b/cinderclient/v2/quota_classes.py
@@ -20,7 +20,7 @@ class QuotaClassSet(base.Resource):
 
     @property
     def id(self):
-        """Needed by base.Resource to self-refresh and be indexed"""
+        """Needed by base.Resource to self-refresh and be indexed."""
         return self.class_name
 
     def update(self, *args, **kwargs):
diff --git a/cinderclient/v2/quotas.py b/cinderclient/v2/quotas.py
index 7c9db9006..476ab418e 100644
--- a/cinderclient/v2/quotas.py
+++ b/cinderclient/v2/quotas.py
@@ -20,7 +20,7 @@ class QuotaSet(base.Resource):
 
     @property
     def id(self):
-        """Needed by base.Resource to self-refresh and be indexed"""
+        """Needed by base.Resource to self-refresh and be indexed."""
         return self.tenant_id
 
     def update(self, *args, **kwargs):
diff --git a/cinderclient/v2/shell.py b/cinderclient/v2/shell.py
index a502378cc..432c3b1c7 100644
--- a/cinderclient/v2/shell.py
+++ b/cinderclient/v2/shell.py
@@ -507,7 +507,7 @@ def do_type_create(cs, args):
            help="Unique ID of the volume type to delete")
 @utils.service_type('volume')
 def do_type_delete(cs, args):
-    """Delete a specific volume type"""
+    """Delete a specific volume type."""
     cs.volume_types.delete(args.id)
 
 
@@ -537,14 +537,14 @@ def do_type_key(cs, args):
 
 
 def do_endpoints(cs, args):
-    """Discover endpoints that get returned from the authenticate services"""
+    """Discover endpoints that get returned from the authenticate services."""
     catalog = cs.client.service_catalog.catalog
     for e in catalog['access']['serviceCatalog']:
         utils.print_dict(e['endpoints'][0], e['name'])
 
 
 def do_credentials(cs, args):
-    """Show user credentials returned from auth"""
+    """Show user credentials returned from auth."""
     catalog = cs.client.service_catalog.catalog
     utils.print_dict(catalog['access']['user'], "User Credentials")
     utils.print_dict(catalog['access']['token'], "Token")
diff --git a/tox.ini b/tox.ini
index 161a11bbe..ca047b722 100644
--- a/tox.ini
+++ b/tox.ini
@@ -25,5 +25,5 @@ downloadcache = ~/cache/pip
 
 [flake8]
 show-source = True
-ignore = F,H
+ignore = F811,F821,H302,H306,H404
 exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools