Fix H402 hacking rules

Fix and enable hacking test:
H402: one line docstring needs punctuation.

Fix testsuite, the change for manila/tests/api/extensions/foxinsocks.py
needs corresponding changes.

Change-Id: I587cd6771787ca56b1410f86a6ec13380bcc206b
This commit is contained in:
Andreas Jaeger 2014-08-14 10:34:28 +02:00
parent 3deb373176
commit 43aeceff2f
23 changed files with 60 additions and 61 deletions

View File

@ -68,7 +68,7 @@ def get_pagination_params(request):
def _get_limit_param(request):
"""Extract integer limit from request or fail"""
"""Extract integer limit from request or fail."""
try:
limit = int(request.GET['limit'])
except ValueError:
@ -81,7 +81,7 @@ def _get_limit_param(request):
def _get_marker_param(request):
"""Extract marker id from request or fail"""
"""Extract marker ID from request or fail."""
return request.GET['marker']
@ -272,7 +272,7 @@ class MetaItemDeserializer(wsgi.MetadataXMLDeserializer):
class MetadataXMLDeserializer(wsgi.XMLDeserializer):
def extract_metadata(self, metadata_node):
"""Marshal the metadata attribute of a parsed request"""
"""Marshal the metadata attribute of a parsed request."""
if metadata_node is None:
return {}
metadata = {}

View File

@ -45,7 +45,7 @@ class QuotaClassTemplate(xmlutil.TemplateBuilder):
class QuotaClassSetsController(object):
def _format_quota_set(self, quota_class, quota_set):
"""Convert the quota object to a result dict"""
"""Convert the quota object to a result dict."""
result = dict(id=str(quota_class))
@ -85,7 +85,7 @@ class QuotaClassSetsController(object):
class Quota_classes(extensions.ExtensionDescriptor):
"""Quota classes management support"""
"""Quota classes management support."""
name = "QuotaClasses"
alias = "os-quota-class-sets"

View File

@ -59,7 +59,7 @@ class QuotaSetsController(object):
self.ext_mgr = ext_mgr
def _format_quota_set(self, project_id, quota_set):
"""Convert the quota object to a result dict"""
"""Convert the quota object to a result dict."""
result = dict(id=str(project_id))
@ -240,7 +240,7 @@ class QuotaSetsController(object):
class Quotas(extensions.ExtensionDescriptor):
"""Quotas management support"""
"""Quotas management support."""
name = "Quotas"
alias = "os-quota-sets"

View File

@ -59,7 +59,7 @@ class ServicesUpdateTemplate(xmlutil.TemplateBuilder):
class ServiceController(object):
@wsgi.serializers(xml=ServicesIndexTemplate)
def index(self, req):
"""Return a list of all running services. """
"""Return a list of all running services."""
context = req.environ['manila.context']
authorize(context)
now = timeutils.utcnow()
@ -96,7 +96,7 @@ class ServiceController(object):
@wsgi.serializers(xml=ServicesUpdateTemplate)
def update(self, req, id, body):
"""Enable/Disable scheduling for a service"""
"""Enable/Disable scheduling for a service."""
context = req.environ['manila.context']
authorize(context)
@ -126,7 +126,7 @@ class ServiceController(object):
class Services(extensions.ExtensionDescriptor):
"""Services support"""
"""Services support."""
name = "Services"
alias = "os-services"

View File

@ -70,7 +70,7 @@ class InjectContext(base_wsgi.Middleware):
class ManilaKeystoneContext(base_wsgi.Middleware):
"""Make a request context from keystone headers"""
"""Make a request context from keystone headers."""
@webob.dec.wsgify(RequestClass=base_wsgi.Request)
def __call__(self, req):

View File

@ -370,7 +370,7 @@ def share_access_get_all_for_share(context, share_id):
def share_access_get_all_by_type_and_access(context, share_id, access_type,
access):
"""Returns share access by given type and access"""
"""Returns share access by given type and access."""
return IMPL.share_access_get_all_by_type_and_access(
context, share_id, access_type, access)
@ -583,14 +583,14 @@ def share_server_get(context, id, session=None):
def share_server_get_by_host(context, host, share_net_id, session=None):
"""Get share server DB records by host"""
"""Get share server DB records by host."""
return IMPL.share_server_get_by_host(context, host, share_net_id,
session=session)
def share_server_get_by_host_and_share_net(context, host, share_net_id,
session=None):
"""Get share server DB records by host and share net"""
"""Get share server DB records by host and share net."""
return IMPL.share_server_get_by_host_and_share_net(context, host,
share_net_id,
session=session)
@ -599,7 +599,7 @@ def share_server_get_by_host_and_share_net(context, host, share_net_id,
def share_server_get_by_host_and_share_net_valid(context, host,
share_net_id,
session=None):
"""Get share server DB records by host and share net not error"""
"""Get share server DB records by host and share net not error."""
return IMPL.share_server_get_by_host_and_share_net_valid(context,
host,
share_net_id,

View File

@ -320,7 +320,7 @@ class ShareSnapshot(BASE, ManilaBase):
class SecurityService(BASE, ManilaBase):
"""Security service information for manila shares"""
"""Security service information for manila shares."""
__tablename__ = 'security_services'
id = Column(String(36), primary_key=True)

View File

@ -133,7 +133,7 @@ class HostState(object):
self.updated = capability['timestamp']
def consume_from_share(self, share):
"""Incrementally update host state from an share"""
"""Incrementally update host state from an share."""
share_gb = share['size']
if self.free_capacity_gb == 'infinite':
# There's virtually infinite space on back-end
@ -216,7 +216,7 @@ class HostManager(object):
def get_filtered_hosts(self, hosts, filter_properties,
filter_class_names=None):
"""Filter hosts and return only ones passing all filters"""
"""Filter hosts and return only ones passing all filters."""
filter_classes = self._choose_host_filters(filter_class_names)
return self.filter_handler.get_filtered_objects(filter_classes,
hosts,
@ -224,7 +224,7 @@ class HostManager(object):
def get_weighed_hosts(self, hosts, weight_properties,
weigher_class_names=None):
"""Weigh the hosts"""
"""Weigh the hosts."""
weigher_classes = self._choose_host_weighers(weigher_class_names)
return self.weight_handler.get_weighed_objects(weigher_classes,
hosts,

View File

@ -570,7 +570,7 @@ class NFSHelper(NASHelperBase):
pass
def allow_access(self, server, share_name, access_type, access):
"""Allow access to the host"""
"""Allow access to the host."""
local_path = os.path.join(self.configuration.share_mount_path,
share_name)
if access_type != 'ip':

View File

@ -133,7 +133,6 @@ class NetAppShareDriver(driver.ShareDriver):
return self._create_export(share)
def ensure_share(self, context, share, share_server=None):
""""""
pass
def _allocate_container(self, share):

View File

@ -278,7 +278,7 @@ class TestCase(testtools.TestCase):
self.assertEqual(sub_value, super_value)
def assertIn(self, a, b, *args, **kwargs):
"""Python < v2.7 compatibility. Assert 'a' in 'b'"""
"""Python < v2.7 compatibility. Assert 'a' in 'b'."""
try:
f = super(TestCase, self).assertIn
except AttributeError:
@ -287,7 +287,7 @@ class TestCase(testtools.TestCase):
f(a, b, *args, **kwargs)
def assertNotIn(self, a, b, *args, **kwargs):
"""Python < v2.7 compatibility. Assert 'a' NOT in 'b'"""
"""Python < v2.7 compatibility. Assert 'a' NOT in 'b'."""
try:
f = super(TestCase, self).assertNotIn
except AttributeError:

View File

@ -61,7 +61,7 @@ class FoxInSocksFlavorBandsControllerExtension(wsgi.Controller):
class Foxinsocks(extensions.ExtensionDescriptor):
"""The Fox In Socks Extension"""
"""The Fox In Socks Extension."""
name = "Fox In Socks"
alias = "FOXNSOX"

View File

@ -110,12 +110,12 @@ class TestFaults(test.TestCase):
self.assertTrue('forbidden' in resp.body)
def test_fault_has_status_int(self):
"""Ensure the status_int is set correctly on faults"""
"""Ensure the status_int is set correctly on faults."""
fault = wsgi.Fault(webob.exc.HTTPBadRequest(explanation='what?'))
self.assertEqual(fault.status_int, 400)
def test_xml_serializer(self):
"""Ensure that a v1.1 request responds with a v1 xmlns"""
"""Ensure that a v1.1 request responds with a v1 xmlns."""
request = webob.Request.blank('/v1',
headers={"Accept": "application/xml"})

View File

@ -38,7 +38,7 @@ class LimiterTest(test.TestCase):
"""
def setUp(self):
"""Run before each test. """
"""Run before each test."""
super(LimiterTest, self).setUp()
self.tiny = range(1)
self.small = range(10)
@ -46,7 +46,7 @@ class LimiterTest(test.TestCase):
self.large = range(10000)
def test_limiter_offset_zero(self):
"""Test offset key works with 0. """
"""Test offset key works with 0."""
req = webob.Request.blank('/?offset=0')
self.assertEqual(common.limited(self.tiny, req), self.tiny)
self.assertEqual(common.limited(self.small, req), self.small)
@ -54,7 +54,7 @@ class LimiterTest(test.TestCase):
self.assertEqual(common.limited(self.large, req), self.large[:1000])
def test_limiter_offset_medium(self):
"""Test offset key works with a medium sized number. """
"""Test offset key works with a medium sized number."""
req = webob.Request.blank('/?offset=10')
self.assertEqual(common.limited(self.tiny, req), [])
self.assertEqual(common.limited(self.small, req), self.small[10:])
@ -62,7 +62,7 @@ class LimiterTest(test.TestCase):
self.assertEqual(common.limited(self.large, req), self.large[10:1010])
def test_limiter_offset_over_max(self):
"""Test offset key works with a number over 1000 (max_limit). """
"""Test offset key works with a number over 1000 (max_limit)."""
req = webob.Request.blank('/?offset=1001')
self.assertEqual(common.limited(self.tiny, req), [])
self.assertEqual(common.limited(self.small, req), [])
@ -71,19 +71,19 @@ class LimiterTest(test.TestCase):
common.limited(self.large, req), self.large[1001:2001])
def test_limiter_offset_blank(self):
"""Test offset key works with a blank offset. """
"""Test offset key works with a blank offset."""
req = webob.Request.blank('/?offset=')
self.assertRaises(
webob.exc.HTTPBadRequest, common.limited, self.tiny, req)
def test_limiter_offset_bad(self):
"""Test offset key works with a BAD offset. """
"""Test offset key works with a BAD offset."""
req = webob.Request.blank(u'/?offset=\u0020aa')
self.assertRaises(
webob.exc.HTTPBadRequest, common.limited, self.tiny, req)
def test_limiter_nothing(self):
"""Test request with no offset or limit """
"""Test request with no offset or limit."""
req = webob.Request.blank('/')
self.assertEqual(common.limited(self.tiny, req), self.tiny)
self.assertEqual(common.limited(self.small, req), self.small)
@ -91,7 +91,7 @@ class LimiterTest(test.TestCase):
self.assertEqual(common.limited(self.large, req), self.large[:1000])
def test_limiter_limit_zero(self):
"""Test limit of zero. """
"""Test limit of zero."""
req = webob.Request.blank('/?limit=0')
self.assertEqual(common.limited(self.tiny, req), self.tiny)
self.assertEqual(common.limited(self.small, req), self.small)
@ -99,7 +99,7 @@ class LimiterTest(test.TestCase):
self.assertEqual(common.limited(self.large, req), self.large[:1000])
def test_limiter_limit_medium(self):
"""Test limit of 10. """
"""Test limit of 10."""
req = webob.Request.blank('/?limit=10')
self.assertEqual(common.limited(self.tiny, req), self.tiny)
self.assertEqual(common.limited(self.small, req), self.small)
@ -107,7 +107,7 @@ class LimiterTest(test.TestCase):
self.assertEqual(common.limited(self.large, req), self.large[:10])
def test_limiter_limit_over_max(self):
"""Test limit of 3000. """
"""Test limit of 3000."""
req = webob.Request.blank('/?limit=3000')
self.assertEqual(common.limited(self.tiny, req), self.tiny)
self.assertEqual(common.limited(self.small, req), self.small)
@ -115,7 +115,7 @@ class LimiterTest(test.TestCase):
self.assertEqual(common.limited(self.large, req), self.large[:1000])
def test_limiter_limit_and_offset(self):
"""Test request with both limit and offset. """
"""Test request with both limit and offset."""
items = range(2000)
req = webob.Request.blank('/?offset=1&limit=3')
self.assertEqual(common.limited(items, req), items[1:4])
@ -127,7 +127,7 @@ class LimiterTest(test.TestCase):
self.assertEqual(common.limited(items, req), [])
def test_limiter_custom_max_limit(self):
"""Test a max_limit other than 1000. """
"""Test a max_limit other than 1000."""
items = range(2000)
req = webob.Request.blank('/?offset=1&limit=3')
self.assertEqual(
@ -142,13 +142,13 @@ class LimiterTest(test.TestCase):
self.assertEqual(common.limited(items, req, max_limit=2000), [])
def test_limiter_negative_limit(self):
"""Test a negative limit. """
"""Test a negative limit."""
req = webob.Request.blank('/?limit=-3000')
self.assertRaises(
webob.exc.HTTPBadRequest, common.limited, self.tiny, req)
def test_limiter_negative_offset(self):
"""Test a negative offset. """
"""Test a negative offset."""
req = webob.Request.blank('/?offset=-30')
self.assertRaises(
webob.exc.HTTPBadRequest, common.limited, self.tiny, req)
@ -162,30 +162,30 @@ class PaginationParamsTest(test.TestCase):
"""
def test_no_params(self):
"""Test no params. """
"""Test no params."""
req = webob.Request.blank('/')
self.assertEqual(common.get_pagination_params(req), {})
def test_valid_marker(self):
"""Test valid marker param. """
"""Test valid marker param."""
req = webob.Request.blank(
'/?marker=263abb28-1de6-412f-b00b-f0ee0c4333c2')
self.assertEqual(common.get_pagination_params(req),
{'marker': '263abb28-1de6-412f-b00b-f0ee0c4333c2'})
def test_valid_limit(self):
"""Test valid limit param. """
"""Test valid limit param."""
req = webob.Request.blank('/?limit=10')
self.assertEqual(common.get_pagination_params(req), {'limit': 10})
def test_invalid_limit(self):
"""Test invalid limit param. """
"""Test invalid limit param."""
req = webob.Request.blank('/?limit=-2')
self.assertRaises(
webob.exc.HTTPBadRequest, common.get_pagination_params, req)
def test_valid_limit_and_marker(self):
"""Test valid limit and marker parameters. """
"""Test valid limit and marker parameters."""
marker = '263abb28-1de6-412f-b00b-f0ee0c4333c2'
req = webob.Request.blank('/?limit=20&marker=%s' % marker)
self.assertEqual(common.get_pagination_params(req),

View File

@ -71,7 +71,7 @@ class ExtensionControllerTest(ExtensionTestCase):
fox_ext, {'namespace': 'http://www.fox.in.socks/api/ext/pie/v1.0',
'name': 'Fox In Socks',
'updated': '2011-01-22T13:25:27-06:00',
'description': 'The Fox In Socks Extension',
'description': 'The Fox In Socks Extension.',
'alias': 'FOXNSOX',
'links': []}, )
@ -94,7 +94,7 @@ class ExtensionControllerTest(ExtensionTestCase):
{"namespace": "http://www.fox.in.socks/api/ext/pie/v1.0",
"name": "Fox In Socks",
"updated": "2011-01-22T13:25:27-06:00",
"description": "The Fox In Socks Extension",
"description": "The Fox In Socks Extension.",
"alias": "FOXNSOX",
"links": []})
@ -127,7 +127,7 @@ class ExtensionControllerTest(ExtensionTestCase):
self.assertEqual(fox_ext.get('updated'), '2011-01-22T13:25:27-06:00')
self.assertEqual(
fox_ext.findtext('{0}description'.format(NS)),
'The Fox In Socks Extension')
'The Fox In Socks Extension.')
xmlutil.validate_schema(root, 'extensions')
@ -149,6 +149,6 @@ class ExtensionControllerTest(ExtensionTestCase):
self.assertEqual(root.get('updated'), '2011-01-22T13:25:27-06:00')
self.assertEqual(
root.findtext('{0}description'.format(NS)),
'The Fox In Socks Extension')
'The Fox In Socks Extension.')
xmlutil.validate_schema(root, 'extension')

View File

@ -283,7 +283,7 @@ class LimitMiddlewareTest(BaseLimitTestSuite):
self.assertEqual(value, expected)
def test_limited_request_xml(self):
"""Test a rate-limited (413) response as XML"""
"""Test a rate-limited (413) response as XML."""
request = webob.Request.blank("/")
response = request.get_response(self.app)
self.assertEqual(200, response.status_int)

View File

@ -69,7 +69,7 @@ class FakeSecurityGroup(object):
class API(object):
"""Fake Compute API"""
"""Fake Compute API."""
def instance_volume_attach(self, ctx, server_id, volume_id, mount_path):
pass

View File

@ -77,7 +77,7 @@ class FakeRouter(object):
class API(object):
"""Fake Network API"""
"""Fake Network API."""
admin_tenant_id = 'fake admin tenant id'
network = {

View File

@ -51,7 +51,7 @@ class FakeVolumeSnapshot(object):
class API(object):
"""Fake Volume API"""
"""Fake Volume API."""
def get(self, volume_id):
pass

View File

@ -41,7 +41,7 @@ class FakeFilterClass2(filters.BaseHostFilter):
class HostManagerTestCase(test.TestCase):
"""Test case for HostManager class"""
"""Test case for HostManager class."""
def setUp(self):
super(HostManagerTestCase, self).setUp()

View File

@ -49,7 +49,7 @@ CONF.register_opts(test_service_opts)
class FakeManager(manager.Manager):
"""Fake manager for tests"""
"""Fake manager for tests."""
def __init__(self, host=None, db_driver=None, service_name=None):
super(FakeManager, self).__init__(host=host, db_driver=db_driver)
@ -63,7 +63,7 @@ class ExtendedService(service.Service):
class ServiceManagerTestCase(test.TestCase):
"""Test cases for Services"""
"""Test cases for Services."""
def test_message_gets_to_manager(self):
serv = service.Service('test', 'test', 'test', CONF.fake_manager)
@ -129,7 +129,7 @@ service_ref = {
class ServiceTestCase(test.TestCase):
"""Test cases for Services"""
"""Test cases for Services."""
def test_create(self):
app = service.Service.create(host='foo',

View File

@ -477,7 +477,7 @@ def utf8(value):
def delete_if_exists(pathname):
"""delete a file, but ignore file not found error"""
"""Delete a file, but ignore file not found error."""
try:
os.unlink(pathname)
@ -540,7 +540,7 @@ def get_from_path(items, path):
def is_valid_boolstr(val):
"""Check if the provided string is a valid bool string or not. """
"""Check if the provided string is a valid bool string or not."""
val = str(val).lower()
return (val == 'true' or val == 'false' or
val == 'yes' or val == 'no' or
@ -825,7 +825,7 @@ def strcmp_const_time(s1, s2):
def walk_class_hierarchy(clazz, encountered=None):
"""Walk class hierarchy, yielding most derived classes first"""
"""Walk class hierarchy, yielding most derived classes first."""
if not encountered:
encountered = []
for subclass in clazz.__subclasses__():

View File

@ -42,6 +42,6 @@ commands = bash tools/lintstack.sh
# TODO: These are not intentionally disabled, reenable when fixed:
# H405: multi line docstring summary not separated with an empty line
# H501: Do not use locals() for string formatting
ignore = E12,H302,H303,H402,H404,H405,H501,H904,F401,F403,F841
ignore = E12,H302,H303,H404,H405,H501,H904,F401,F403,F841
builtins = _
exclude = .venv,.tox,dist,doc,openstack,*egg