Browse Source

Merge "Flake8: Fix and enable H405"

tags/2014.2.b3
Jenkins 4 years ago
parent
commit
369bd6d497

+ 4
- 2
manila/api/contrib/extended_quotas.py View File

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

+ 4
- 1
manila/api/urlmap.py View File

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

+ 3
- 2
manila/api/v1/security_service.py View File

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

+ 1
- 3
manila/api/v1/shares.py View File

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

+ 3
- 2
manila/compute/nova.py View File

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

+ 2
- 1
manila/db/migrations/alembic/migration.py View File

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

+ 1
- 2
manila/scheduler/driver.py View File

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

+ 20
- 13
manila/scheduler/filter_scheduler.py View File

@@ -40,9 +40,7 @@ class FilterScheduler(driver.Scheduler):
40 40
         self.max_attempts = self._max_attempts()
41 41
 
42 42
     def schedule(self, context, topic, method, *args, **kwargs):
43
-        """The schedule() contract requires we return the one
44
-        best-suited host for this request.
45
-        """
43
+        """Return best-suited host for request."""
46 44
         self._schedule(context, topic, *args, **kwargs)
47 45
 
48 46
     def _get_configuration_options(self):
@@ -51,16 +49,19 @@ class FilterScheduler(driver.Scheduler):
51 49
 
52 50
     def _post_select_populate_filter_properties(self, filter_properties,
53 51
                                                 host_state):
54
-        """Add additional information to the filter properties after a host has
52
+        """Add additional information to filter properties.
53
+
54
+        Add additional information to the filter properties after a host has
55 55
         been selected by the scheduling process.
56 56
         """
57 57
         # Add a retry entry for the selected volume backend:
58 58
         self._add_retry_host(filter_properties, host_state.host)
59 59
 
60 60
     def _add_retry_host(self, filter_properties, host):
61
-        """Add a retry entry for the selected volume backend. In the event that
62
-        the request gets re-scheduled, this entry will signal that the given
63
-        backend has already been tried.
61
+        """Add retry entry for the selected volume backend.
62
+
63
+        In the event that the request gets re-scheduled, this entry
64
+        will signal that the given backend has already been tried.
64 65
         """
65 66
         retry = filter_properties.get('retry', None)
66 67
         if not retry:
@@ -101,8 +102,9 @@ class FilterScheduler(driver.Scheduler):
101 102
                                        snapshot_id=snapshot_id)
102 103
 
103 104
     def _schedule_share(self, context, request_spec, filter_properties=None):
104
-        """Returns a list of hosts that meet the required specs,
105
-        ordered by their fitness.
105
+        """Returns a list of hosts that meet the required specs.
106
+
107
+        The list is ordered by their fitness.
106 108
         """
107 109
         elevated = context.elevated()
108 110
 
@@ -157,7 +159,9 @@ class FilterScheduler(driver.Scheduler):
157 159
         return best_host
158 160
 
159 161
     def _populate_retry_share(self, filter_properties, properties):
160
-        """Populate filter properties with history of retries for this
162
+        """Populate filter properties with retry history.
163
+
164
+        Populate filter properties with history of retries for this
161 165
         request. If maximum retries is exceeded, raise NoValidHost.
162 166
         """
163 167
         max_attempts = self.max_attempts
@@ -189,7 +193,9 @@ class FilterScheduler(driver.Scheduler):
189 193
             raise exception.NoValidHost(reason=msg)
190 194
 
191 195
     def _log_share_error(self, share_id, retry):
192
-        """If the request contained an exception from a previous share
196
+        """Log any exceptions from a previous share create operation.
197
+
198
+        If the request contained an exception from a previous share
193 199
         create operation, log it to aid debugging.
194 200
         """
195 201
         exc = retry.pop('exc', None)  # string-ified exception from share
@@ -211,8 +217,9 @@ class FilterScheduler(driver.Scheduler):
211 217
 
212 218
     def populate_filter_properties_share(self, request_spec,
213 219
                                          filter_properties):
214
-        """Stuff things into filter_properties.  Can be overridden in a
215
-        subclass to add more data.
220
+        """Stuff things into filter_properties.
221
+
222
+        Can be overridden in a subclass to add more data.
216 223
         """
217 224
         shr = request_spec['share_properties']
218 225
         filter_properties['size'] = shr['size']

+ 1
- 3
manila/scheduler/filters/retry_filter.py View File

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

+ 18
- 12
manila/scheduler/host_manager.py View File

@@ -162,10 +162,12 @@ class HostManager(object):
162 162
         self.weight_classes = self.weight_handler.get_all_classes()
163 163
 
164 164
     def _choose_host_filters(self, filter_cls_names):
165
-        """Since the caller may specify which filters to use we need
166
-        to have an authoritative list of what is permissible. This
167
-        function checks the filter names against a predefined set
168
-        of acceptable filters.
165
+        """Choose acceptable filters.
166
+
167
+        Since the caller may specify which filters to use we need to
168
+        have an authoritative list of what is permissible. This
169
+        function checks the filter names against a predefined set of
170
+        acceptable filters.
169 171
         """
170 172
         if filter_cls_names is None:
171 173
             filter_cls_names = CONF.scheduler_default_filters
@@ -188,10 +190,12 @@ class HostManager(object):
188 190
         return good_filters
189 191
 
190 192
     def _choose_host_weighers(self, weight_cls_names):
191
-        """Since the caller may specify which weighers to use, we need
192
-        to have an authoritative list of what is permissible. This
193
-        function checks the weigher names against a predefined set
194
-        of acceptable weighers.
193
+        """Choose acceptable weighers.
194
+
195
+        Since the caller may specify which weighers to use, we need to
196
+        have an authoritative list of what is permissible. This
197
+        function checks the weigher names against a predefined set of
198
+        acceptable weighers.
195 199
         """
196 200
         if weight_cls_names is None:
197 201
             weight_cls_names = CONF.scheduler_default_weighers
@@ -246,11 +250,13 @@ class HostManager(object):
246 250
         self.service_states[host] = capab_copy
247 251
 
248 252
     def get_all_host_states_share(self, context):
249
-        """Returns a dict of all the hosts the HostManager
250
-          knows about. Also, each of the consumable resources in HostState
251
-          are pre-populated and adjusted based on data in the db.
253
+        """Get all hosts and their states.
254
+
255
+        Returns a dict of all the hosts the HostManager knows
256
+        about. Also, each of the consumable resources in HostState are
257
+        pre-populated and adjusted based on data in the db.
252 258
 
253
-          For example:
259
+        For example:
254 260
           {'192.168.1.100': HostState(), ...}
255 261
         """
256 262
 

+ 4
- 2
manila/share/configuration.py View File

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

+ 10
- 5
manila/tests/api/v1/test_limits.py View File

@@ -559,9 +559,12 @@ class WsgiLimiterTest(BaseLimitTestSuite):
559 559
         return jsonutils.dumps({"verb": verb, "path": path})
560 560
 
561 561
     def _request(self, verb, url, username=None):
562
-        """Make sure that POSTing to the given url causes the given username
563
-        to perform the given action.  Make the internal rate limiter return
564
-        delay and make sure that the WSGI app returns the correct response.
562
+        """Send request.
563
+
564
+        Make sure that POSTing to the given url causes the given
565
+        username to perform the given action.  Make the internal rate
566
+        limiter return delay and make sure that the WSGI app returns
567
+        the correct response.
565 568
         """
566 569
         if username:
567 570
             request = webob.Request.blank("/%s" % username)
@@ -662,8 +665,10 @@ class FakeHttplibConnection(object):
662 665
 
663 666
 
664 667
 def wire_HTTPConnection_to_WSGI(host, app):
665
-    """Monkeypatches HTTPConnection so that if you try to connect to host, you
666
-    are instead routed straight to the given WSGI app.
668
+    """Wire HTTPConnection to WSGI app.
669
+
670
+    Monkeypatches HTTPConnection so that if you try to connect to
671
+    host, you are instead routed straight to the given WSGI app.
667 672
 
668 673
     After calling this method, when any code calls
669 674
 

+ 12
- 5
manila/utils.py View File

@@ -546,7 +546,9 @@ def is_valid_boolstr(val):
546 546
 
547 547
 
548 548
 def is_valid_ipv4(address):
549
-    """valid the address strictly as per format xxx.xxx.xxx.xxx.
549
+    """Validate IPv4 address.
550
+
551
+    Valid the address strictly as per format xxx.xxx.xxx.xxx.
550 552
     where xxx is a value between 0 and 255.
551 553
     """
552 554
     parts = address.split(".")
@@ -601,7 +603,9 @@ def is_eventlet_bug105():
601 603
 
602 604
 
603 605
 def monkey_patch():
604
-    """If the Flags.monkey_patch set as True,
606
+    """Patch decorator.
607
+
608
+    If the Flags.monkey_patch set as True,
605 609
     this function patches a decorator
606 610
     for all functions in specified modules.
607 611
     You can set decorators for each modules
@@ -711,7 +715,9 @@ def hash_file(file_like_object):
711 715
 
712 716
 @contextlib.contextmanager
713 717
 def temporary_mutation(obj, **kwargs):
714
-    """Temporarily set the attr on a particular object to a given value then
718
+    """Temporarily set the attr on a particular object.
719
+
720
+    Temporarily set the attr on a particular object to a given value then
715 721
     revert when finished.
716 722
 
717 723
     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):
835 841
 
836 842
 
837 843
 class UndoManager(object):
838
-    """Provides a mechanism to facilitate rolling back a series of actions
839
-    when an exception is raised.
844
+    """Provides a mechanism to facilitate rolling back a series of actions.
845
+
846
+    This can be used when an exception is raised.
840 847
     """
841 848
     def __init__(self):
842 849
         self.undo_stack = []

+ 4
- 4
manila/volume/cinder.py View File

@@ -172,8 +172,7 @@ def _untranslate_snapshot_summary_view(context, snapshot):
172 172
 
173 173
 
174 174
 def translate_volume_exception(method):
175
-    """Transforms the exception for the volume but keeps its traceback intact.
176
-    """
175
+    """Transforms the exception for the volume, keeps its traceback intact."""
177 176
     def wrapper(self, ctx, volume_id, *args, **kwargs):
178 177
         try:
179 178
             res = method(self, ctx, volume_id, *args, **kwargs)
@@ -189,8 +188,9 @@ def translate_volume_exception(method):
189 188
 
190 189
 
191 190
 def translate_snapshot_exception(method):
192
-    """Transforms the exception for the snapshot but keeps its traceback
193
-       intact.
191
+    """Transforms the exception for the snapshot.
192
+
193
+    Note: Keeps its traceback intact.
194 194
     """
195 195
     def wrapper(self, ctx, snapshot_id, *args, **kwargs):
196 196
         try:

+ 1
- 4
tox.ini View File

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

Loading…
Cancel
Save