Flake8: Fix and enable H405

Fix H405:
H405  multi line docstring summary not separated with an empty line

With this patch, flake8 passes all checks (incl. hacking checks)
except the on-purpose disabled check H904.
Closes-Bug: #1333290

Change-Id: If41259aefc4d6d588da5036f1f25df17b88db04f
This commit is contained in:
Andreas Jaeger 2014-08-26 19:46:55 +02:00
parent 1ee54a3144
commit 2641eb9b57
15 changed files with 88 additions and 61 deletions

View File

@ -17,8 +17,10 @@ from manila.api import extensions
class Extended_quotas(extensions.ExtensionDescriptor):
"""Adds ability for admins to delete quota
and optionally force the update Quota command.
"""Extend quotas.
Adds ability for admins to delete quota and optionally force the
update Quota command.
"""
name = "ExtendedQuotas"

View File

@ -35,6 +35,7 @@ LOG = logging.getLogger(__name__)
def unquote_header_value(value):
"""Unquotes a header value.
This does not use the real unquoting but what browsers are actually
using for quoting.
@ -74,7 +75,9 @@ def parse_list_header(value):
def parse_options_header(value):
"""Parse a ``Content-Type`` like header into a tuple with the content
"""Parse header into content type and options.
Parse a ``Content-Type`` like header into a tuple with the content
type and the options:
>>> parse_options_header('Content-Type: text/html; mimetype=text/html')

View File

@ -111,8 +111,9 @@ class SecurityServiceController(wsgi.Controller):
return self._get_security_services(req, is_detail=True)
def _get_security_services(self, req, is_detail):
"""Returns a list of security services, transformed through view
builder.
"""Returns a transformed list of security services.
The list gets transformed through view builder.
"""
context = req.environ['manila.context']
policy.check_policy(context, RESOURCE_NAME,

View File

@ -104,9 +104,7 @@ class ShareController(wsgi.Controller):
return self._get_shares(req, is_detail=True)
def _get_shares(self, req, is_detail):
"""Returns a list of shares, transformed through view
builder.
"""
"""Returns a list of shares, transformed through view builder."""
context = req.environ['manila.context']
search_opts = {}

View File

@ -135,8 +135,9 @@ def _untranslate_server_summary_view(server):
def translate_server_exception(method):
"""Transforms the exception for the instance but keeps its traceback
intact.
"""Transforms the exception for the instance.
Note: keeps its traceback intact.
"""
def wrapper(self, ctx, instance_id, *args, **kwargs):
try:

View File

@ -62,7 +62,8 @@ def downgrade(revision):
def stamp(revision):
"""Stamp database with provided revision.
Dont run any migrations.
Don't run any migrations.
:param revision: Should match one from repository or head - to stamp
database with most recent revision

View File

@ -65,8 +65,7 @@ class Scheduler(object):
return self.host_manager.get_host_list()
def get_service_capabilities(self):
"""Get the normalized set of capabilities for the services.
"""
"""Get the normalized set of capabilities for the services."""
return self.host_manager.get_service_capabilities()
def update_service_capabilities(self, service_name, host, capabilities):

View File

@ -40,9 +40,7 @@ class FilterScheduler(driver.Scheduler):
self.max_attempts = self._max_attempts()
def schedule(self, context, topic, method, *args, **kwargs):
"""The schedule() contract requires we return the one
best-suited host for this request.
"""
"""Return best-suited host for request."""
self._schedule(context, topic, *args, **kwargs)
def _get_configuration_options(self):
@ -51,16 +49,19 @@ class FilterScheduler(driver.Scheduler):
def _post_select_populate_filter_properties(self, filter_properties,
host_state):
"""Add additional information to the filter properties after a host has
"""Add additional information to filter properties.
Add additional information to the filter properties after a host has
been selected by the scheduling process.
"""
# Add a retry entry for the selected volume backend:
self._add_retry_host(filter_properties, host_state.host)
def _add_retry_host(self, filter_properties, host):
"""Add a retry entry for the selected volume backend. In the event that
the request gets re-scheduled, this entry will signal that the given
backend has already been tried.
"""Add retry entry for the selected volume backend.
In the event that the request gets re-scheduled, this entry
will signal that the given backend has already been tried.
"""
retry = filter_properties.get('retry', None)
if not retry:
@ -101,8 +102,9 @@ class FilterScheduler(driver.Scheduler):
snapshot_id=snapshot_id)
def _schedule_share(self, context, request_spec, filter_properties=None):
"""Returns a list of hosts that meet the required specs,
ordered by their fitness.
"""Returns a list of hosts that meet the required specs.
The list is ordered by their fitness.
"""
elevated = context.elevated()
@ -157,7 +159,9 @@ class FilterScheduler(driver.Scheduler):
return best_host
def _populate_retry_share(self, filter_properties, properties):
"""Populate filter properties with history of retries for this
"""Populate filter properties with retry history.
Populate filter properties with history of retries for this
request. If maximum retries is exceeded, raise NoValidHost.
"""
max_attempts = self.max_attempts
@ -189,7 +193,9 @@ class FilterScheduler(driver.Scheduler):
raise exception.NoValidHost(reason=msg)
def _log_share_error(self, share_id, retry):
"""If the request contained an exception from a previous share
"""Log any exceptions from a previous share create operation.
If the request contained an exception from a previous share
create operation, log it to aid debugging.
"""
exc = retry.pop('exc', None) # string-ified exception from share
@ -211,8 +217,9 @@ class FilterScheduler(driver.Scheduler):
def populate_filter_properties_share(self, request_spec,
filter_properties):
"""Stuff things into filter_properties. Can be overridden in a
subclass to add more data.
"""Stuff things into filter_properties.
Can be overridden in a subclass to add more data.
"""
shr = request_spec['share_properties']
filter_properties['size'] = shr['size']

View File

@ -20,9 +20,7 @@ LOG = logging.getLogger(__name__)
class RetryFilter(filters.BaseHostFilter):
"""Filter out nodes that have already been attempted for scheduling
purposes
"""
"""Filter out already tried nodes for scheduling purposes."""
def host_passes(self, host_state, filter_properties):
"""Skip nodes that have already been attempted."""

View File

@ -162,10 +162,12 @@ class HostManager(object):
self.weight_classes = self.weight_handler.get_all_classes()
def _choose_host_filters(self, filter_cls_names):
"""Since the caller may specify which filters to use we need
to have an authoritative list of what is permissible. This
function checks the filter names against a predefined set
of acceptable filters.
"""Choose acceptable filters.
Since the caller may specify which filters to use we need to
have an authoritative list of what is permissible. This
function checks the filter names against a predefined set of
acceptable filters.
"""
if filter_cls_names is None:
filter_cls_names = CONF.scheduler_default_filters
@ -188,10 +190,12 @@ class HostManager(object):
return good_filters
def _choose_host_weighers(self, weight_cls_names):
"""Since the caller may specify which weighers to use, we need
to have an authoritative list of what is permissible. This
function checks the weigher names against a predefined set
of acceptable weighers.
"""Choose acceptable weighers.
Since the caller may specify which weighers to use, we need to
have an authoritative list of what is permissible. This
function checks the weigher names against a predefined set of
acceptable weighers.
"""
if weight_cls_names is None:
weight_cls_names = CONF.scheduler_default_weighers
@ -246,11 +250,13 @@ class HostManager(object):
self.service_states[host] = capab_copy
def get_all_host_states_share(self, context):
"""Returns a dict of all the hosts the HostManager
knows about. Also, each of the consumable resources in HostState
are pre-populated and adjusted based on data in the db.
"""Get all hosts and their states.
For example:
Returns a dict of all the hosts the HostManager knows
about. Also, each of the consumable resources in HostState are
pre-populated and adjusted based on data in the db.
For example:
{'192.168.1.100': HostState(), ...}
"""

View File

@ -55,8 +55,10 @@ LOG = logging.getLogger(__name__)
class Configuration(object):
def __init__(self, share_opts, config_group=None):
"""This takes care of grafting the implementation's config
values into the config group.
"""Graft config values into config group.
This takes care of grafting the implementation's config values
into the config group.
"""
self.config_group = config_group

View File

@ -559,9 +559,12 @@ class WsgiLimiterTest(BaseLimitTestSuite):
return jsonutils.dumps({"verb": verb, "path": path})
def _request(self, verb, url, username=None):
"""Make sure that POSTing to the given url causes the given username
to perform the given action. Make the internal rate limiter return
delay and make sure that the WSGI app returns the correct response.
"""Send request.
Make sure that POSTing to the given url causes the given
username to perform the given action. Make the internal rate
limiter return delay and make sure that the WSGI app returns
the correct response.
"""
if username:
request = webob.Request.blank("/%s" % username)
@ -662,8 +665,10 @@ class FakeHttplibConnection(object):
def wire_HTTPConnection_to_WSGI(host, app):
"""Monkeypatches HTTPConnection so that if you try to connect to host, you
are instead routed straight to the given WSGI app.
"""Wire HTTPConnection to WSGI app.
Monkeypatches HTTPConnection so that if you try to connect to
host, you are instead routed straight to the given WSGI app.
After calling this method, when any code calls

View File

@ -546,7 +546,9 @@ def is_valid_boolstr(val):
def is_valid_ipv4(address):
"""valid the address strictly as per format xxx.xxx.xxx.xxx.
"""Validate IPv4 address.
Valid the address strictly as per format xxx.xxx.xxx.xxx.
where xxx is a value between 0 and 255.
"""
parts = address.split(".")
@ -601,7 +603,9 @@ def is_eventlet_bug105():
def monkey_patch():
"""If the Flags.monkey_patch set as True,
"""Patch decorator.
If the Flags.monkey_patch set as True,
this function patches a decorator
for all functions in specified modules.
You can set decorators for each modules
@ -711,7 +715,9 @@ def hash_file(file_like_object):
@contextlib.contextmanager
def temporary_mutation(obj, **kwargs):
"""Temporarily set the attr on a particular object to a given value then
"""Temporarily set the attr on a particular object.
Temporarily set the attr on a particular object to a given value then
revert when finished.
One use of this is to temporarily set the read_deleted flag on a context
@ -835,8 +841,9 @@ def walk_class_hierarchy(clazz, encountered=None):
class UndoManager(object):
"""Provides a mechanism to facilitate rolling back a series of actions
when an exception is raised.
"""Provides a mechanism to facilitate rolling back a series of actions.
This can be used when an exception is raised.
"""
def __init__(self):
self.undo_stack = []

View File

@ -172,8 +172,7 @@ def _untranslate_snapshot_summary_view(context, snapshot):
def translate_volume_exception(method):
"""Transforms the exception for the volume but keeps its traceback intact.
"""
"""Transforms the exception for the volume, keeps its traceback intact."""
def wrapper(self, ctx, volume_id, *args, **kwargs):
try:
res = method(self, ctx, volume_id, *args, **kwargs)
@ -189,8 +188,9 @@ def translate_volume_exception(method):
def translate_snapshot_exception(method):
"""Transforms the exception for the snapshot but keeps its traceback
intact.
"""Transforms the exception for the snapshot.
Note: Keeps its traceback intact.
"""
def wrapper(self, ctx, snapshot_id, *args, **kwargs):
try:

View File

@ -42,13 +42,10 @@ deps = -r{toxinidir}/requirements.txt
commands = bash tools/lintstack.sh
[flake8]
# TODO: These are not intentionally disabled, reenable when fixed:
# H405: multi line docstring summary not separated with an empty line
#
# Following checks are ignored on purpose:
#
# H904 wrap long lines in parentheses instead of a backslash
# reason: removed in hacking (https://review.openstack.org/#/c/101701/)
ignore = H405,H904
ignore = H904
builtins = _
exclude = .venv,.tox,dist,doc,openstack,*egg