Permalink
Browse files

Gate on H4xx docstrings for pep8

In an effort to help horizon more friendly to OpenStack hacking
guidelines, we now gate on H40* violations.

Change-Id: Id07294543660368d2f7f5ac363710176ab23b874
Signed-off-by: Paul Belanger <paul.belanger@polybeacon.com>
  • Loading branch information...
1 parent 94129ba commit da8c69afa6392c92b587a1a22eb8dd20768c617d @pabelanger pabelanger committed Nov 1, 2013
Showing with 411 additions and 577 deletions.
  1. +22 −25 horizon/base.py
  2. +2 −3 horizon/browsers/base.py
  3. +1 −1 horizon/browsers/breadcrumb.py
  4. +1 −1 horizon/context_processors.py
  5. +3 −3 horizon/decorators.py
  6. +17 −25 horizon/exceptions.py
  7. +3 −5 horizon/forms/base.py
  8. +4 −6 horizon/forms/fields.py
  9. +4 −9 horizon/forms/views.py
  10. +6 −18 horizon/messages.py
  11. +4 −6 horizon/middleware.py
  12. +25 −33 horizon/tables/actions.py
  13. +48 −64 horizon/tables/base.py
  14. +4 −5 horizon/tables/views.py
  15. +23 −41 horizon/tabs/base.py
  16. +8 −11 horizon/tabs/views.py
  17. +5 −7 horizon/templatetags/horizon.py
  18. +2 −2 horizon/templatetags/parse_date.py
  19. +3 −2 horizon/templatetags/sizeformat.py
  20. +4 −7 horizon/test/helpers.py
  21. +7 −8 horizon/test/tests/base.py
  22. +1 −1 horizon/test/tests/tables.py
  23. +4 −4 horizon/test/tests/templatetags.py
  24. +3 −7 horizon/utils/fields.py
  25. +1 −2 horizon/utils/filters.py
  26. +6 −12 horizon/utils/html.py
  27. +1 −1 horizon/utils/validators.py
  28. +3 −4 horizon/views.py
  29. +29 −51 horizon/workflows/base.py
  30. +7 −10 horizon/workflows/views.py
  31. +14 −14 openstack_dashboard/api/base.py
  32. +44 −52 openstack_dashboard/api/ceilometer.py
  33. +2 −4 openstack_dashboard/api/cinder.py
  34. +3 −3 openstack_dashboard/api/fwaas.py
  35. +1 −2 openstack_dashboard/api/glance.py
  36. +11 −13 openstack_dashboard/api/keystone.py
  37. +5 −5 openstack_dashboard/api/lbaas.py
  38. +9 −12 openstack_dashboard/api/neutron.py
  39. +2 −3 openstack_dashboard/api/nova.py
  40. +1 −1 openstack_dashboard/api/swift.py
  41. +1 −1 openstack_dashboard/api/trove.py
  42. +1 −1 openstack_dashboard/context_processors.py
  43. +1 −1 openstack_dashboard/dashboards/admin/domains/tables.py
  44. +1 −1 openstack_dashboard/dashboards/admin/flavors/tables.py
  45. +2 −2 openstack_dashboard/dashboards/admin/groups/tables.py
  46. +1 −1 openstack_dashboard/dashboards/admin/images/views.py
  47. +1 −1 openstack_dashboard/dashboards/admin/instances/tables.py
  48. +2 −2 openstack_dashboard/dashboards/admin/metering/tabs.py
  49. +1 −1 openstack_dashboard/dashboards/admin/metering/views.py
  50. +1 −1 openstack_dashboard/dashboards/admin/projects/tables.py
  51. +1 −1 openstack_dashboard/dashboards/admin/roles/tables.py
  52. +1 −1 openstack_dashboard/dashboards/admin/users/tables.py
  53. +1 −1 openstack_dashboard/dashboards/admin/volumes/tables.py
  54. +1 −2 openstack_dashboard/dashboards/project/containers/tables.py
  55. +3 −3 openstack_dashboard/dashboards/project/containers/views.py
  56. +1 −2 openstack_dashboard/dashboards/project/databases/workflows/create_instance.py
  57. +2 −4 openstack_dashboard/dashboards/project/images_and_snapshots/images/tests.py
  58. +1 −2 openstack_dashboard/dashboards/project/images_and_snapshots/utils.py
  59. +1 −1 openstack_dashboard/dashboards/project/instances/tables.py
  60. +2 −1 openstack_dashboard/dashboards/project/instances/workflows/create_instance.py
  61. +1 −1 openstack_dashboard/dashboards/project/networks/workflows.py
  62. +1 −2 openstack_dashboard/dashboards/project/routers/extensions/routerrules/forms.py
  63. +1 −3 openstack_dashboard/dashboards/project/stacks/forms.py
  64. +1 −3 openstack_dashboard/dashboards/project/stacks/mappings.py
  65. +5 −5 openstack_dashboard/dashboards/project/volumes/tables.py
  66. +2 −2 openstack_dashboard/dashboards/router/nexus1000v/forms.py
  67. +2 −1 openstack_dashboard/policy.py
  68. +3 −3 openstack_dashboard/test/api_tests/base_tests.py
  69. +1 −2 openstack_dashboard/test/api_tests/keystone_tests.py
  70. +8 −16 openstack_dashboard/test/helpers.py
  71. +7 −10 openstack_dashboard/test/test_data/utils.py
  72. +1 −1 openstack_dashboard/test/tests/error_pages.py
  73. +1 −1 openstack_dashboard/test/tests/templates.py
  74. +3 −8 openstack_dashboard/usage/base.py
  75. +4 −4 openstack_dashboard/usage/quotas.py
  76. +1 −2 tox.ini
View
@@ -159,7 +159,7 @@ def _registered(self, cls):
class Panel(HorizonComponent):
- """ A base class for defining Horizon dashboard panels.
+ """A base class for defining Horizon dashboard panels.
All Horizon dashboard panels should extend from this class. It provides
the appropriate hooks for automatically constructing URLconfs, and
@@ -214,7 +214,7 @@ def __repr__(self):
return "<Panel: %s>" % self.slug
def get_absolute_url(self):
- """ Returns the default URL for this panel.
+ """Returns the default URL for this panel.
The default URL is defined as the URL pattern with ``name="index"`` in
the URLconf for this panel.
@@ -243,7 +243,7 @@ def _decorated_urls(self):
class PanelGroup(object):
- """ A container for a set of :class:`~horizon.Panel` classes.
+ """A container for a set of :class:`~horizon.Panel` classes.
When iterated, it will yield each of the ``Panel`` instances it
contains.
@@ -286,7 +286,7 @@ def __iter__(self):
class Dashboard(Registry, HorizonComponent):
- """ A base class for defining Horizon dashboards.
+ """A base class for defining Horizon dashboards.
All Horizon dashboards should extend from this base class. It provides the
appropriate hooks for automatic discovery of :class:`~horizon.Panel`
@@ -390,15 +390,13 @@ def __init__(self, *args, **kwargs):
self._panel_groups = None
def get_panel(self, panel):
- """
- Returns the specified :class:`~horizon.Panel` instance registered
+ """Returns the specified :class:`~horizon.Panel` instance registered
with this dashboard.
"""
return self._registered(panel)
def get_panels(self):
- """
- Returns the :class:`~horizon.Panel` instances registered with this
+ """Returns the :class:`~horizon.Panel` instances registered with this
dashboard in order, without any panel groupings.
"""
all_panels = []
@@ -432,7 +430,7 @@ def get_panel_groups(self):
return SortedDict(panel_groups)
def get_absolute_url(self):
- """ Returns the default URL for this dashboard.
+ """Returns the default URL for this dashboard.
The default URL is defined as the URL pattern with ``name="index"``
in the URLconf for the :class:`~horizon.Panel` specified by
@@ -478,7 +476,7 @@ def _decorated_urls(self):
return urlpatterns, self.slug, self.slug
def _autodiscover(self):
- """ Discovers panels to register from the current dashboard module. """
+ """Discovers panels to register from the current dashboard module."""
if getattr(self, "_autodiscover_complete", False):
return
@@ -520,7 +518,7 @@ def _autodiscover(self):
@classmethod
def register(cls, panel):
- """ Registers a :class:`~horizon.Panel` with this dashboard. """
+ """Registers a :class:`~horizon.Panel` with this dashboard."""
panel_class = Horizon.register_panel(cls, panel)
# Support template loading from panel template directories.
panel_mod = import_module(panel.__module__)
@@ -533,7 +531,7 @@ def register(cls, panel):
@classmethod
def unregister(cls, panel):
- """ Unregisters a :class:`~horizon.Panel` from this dashboard. """
+ """Unregisters a :class:`~horizon.Panel` from this dashboard."""
success = Horizon.unregister_panel(cls, panel)
if success:
# Remove the panel's template directory.
@@ -578,7 +576,7 @@ def __getitem__(self, idx):
class Site(Registry, HorizonComponent):
- """ The overarching class which encompasses all dashboards and panels. """
+ """The overarching class which encompasses all dashboards and panels."""
# Required for registry
_registerable_class = Dashboard
@@ -604,11 +602,11 @@ def default_dashboard(self):
return self._conf['default_dashboard']
def register(self, dashboard):
- """ Registers a :class:`~horizon.Dashboard` with Horizon."""
+ """Registers a :class:`~horizon.Dashboard` with Horizon."""
return self._register(dashboard)
def unregister(self, dashboard):
- """ Unregisters a :class:`~horizon.Dashboard` from Horizon. """
+ """Unregisters a :class:`~horizon.Dashboard` from Horizon."""
return self._unregister(dashboard)
def registered(self, dashboard):
@@ -626,11 +624,11 @@ def unregister_panel(self, dashboard, panel):
return dash_instance._unregister(panel)
def get_dashboard(self, dashboard):
- """ Returns the specified :class:`~horizon.Dashboard` instance. """
+ """Returns the specified :class:`~horizon.Dashboard` instance."""
return self._registered(dashboard)
def get_dashboards(self):
- """ Returns an ordered tuple of :class:`~horizon.Dashboard` modules.
+ """Returns an ordered tuple of :class:`~horizon.Dashboard` modules.
Orders dashboards according to the ``"dashboards"`` key in
``HORIZON_CONFIG`` or else returns all registered dashboards
@@ -658,7 +656,7 @@ def get_dashboards(self):
return dashboards
def get_default_dashboard(self):
- """ Returns the default :class:`~horizon.Dashboard` instance.
+ """Returns the default :class:`~horizon.Dashboard` instance.
If ``"default_dashboard"`` is specified in ``HORIZON_CONFIG``
then that dashboard will be returned. If not, the first dashboard
@@ -672,7 +670,7 @@ def get_default_dashboard(self):
raise NotRegistered("No dashboard modules have been registered.")
def get_user_home(self, user):
- """ Returns the default URL for a particular user.
+ """Returns the default URL for a particular user.
This method can be used to customize where a user is sent when
they log in, etc. By default it returns the value of
@@ -710,7 +708,7 @@ def get_user_home(self, user):
return self.get_absolute_url()
def get_absolute_url(self):
- """ Returns the default URL for Horizon's URLconf.
+ """Returns the default URL for Horizon's URLconf.
The default URL is determined by calling
:meth:`~horizon.Dashboard.get_absolute_url`
@@ -721,7 +719,7 @@ def get_absolute_url(self):
@property
def _lazy_urls(self):
- """ Lazy loading for URL patterns.
+ """Lazy loading for URL patterns.
This method avoids problems associated with attempting to evaluate
the the URLconf before the settings module has been loaded.
@@ -732,7 +730,7 @@ def url_patterns():
return LazyURLPattern(url_patterns), self.namespace, self.slug
def _urls(self):
- """ Constructs the URLconf for Horizon from registered Dashboards. """
+ """Constructs the URLconf for Horizon from registered Dashboards."""
urlpatterns = self._get_default_urlpatterns()
self._autodiscover()
@@ -764,7 +762,7 @@ def _urls(self):
return urlpatterns, self.namespace, self.slug
def _autodiscover(self):
- """ Discovers modules to register from ``settings.INSTALLED_APPS``.
+ """Discovers modules to register from ``settings.INSTALLED_APPS``.
This makes sure that the appropriate modules get imported to register
themselves with Horizon.
@@ -787,8 +785,7 @@ def _autodiscover(self):
class HorizonSite(Site):
- """
- A singleton implementation of Site such that all dealings with horizon
+ """A singleton implementation of Site such that all dealings with horizon
get the same instance no matter what. There can be only one.
"""
_instance = None
View
@@ -121,9 +121,8 @@ def check_table_class(self, cls, attr_name):
% (attr_name, self.__class__.__name__))
def set_tables(self, tables):
- """
- Sets the table instances on the browser from a dictionary mapping table
- names to table instances (as constructed by MultiTableView).
+ """Sets the table instances on the browser from a dictionary mapping
+ table names to table instances (as constructed by MultiTableView).
"""
self.navigation_table = tables[self.navigation_table_class._meta.name]
self.content_table = tables[self.content_table_class._meta.name]
@@ -41,7 +41,7 @@ def get_subfolders(self):
return self._subfolders
def render(self):
- """ Renders the table using the template from the table options. """
+ """Renders the table using the template from the table options."""
breadcrumb_template = template.loader.get_template(self.template)
extra_context = {"breadcrumb": self}
context = template.RequestContext(self.request, extra_context)
@@ -25,7 +25,7 @@
def horizon(request):
- """ The main Horizon context processor. Required for Horizon to function.
+ """The main Horizon context processor. Required for Horizon to function.
It adds the Horizon config to the context as well as setting the names
``True`` and ``False`` in the context to their boolean equivalents
View
@@ -28,7 +28,7 @@
def _current_component(view_func, dashboard=None, panel=None):
- """ Sets the currently-active dashboard and/or panel on the request. """
+ """Sets the currently-active dashboard and/or panel on the request."""
@functools.wraps(view_func, assigned=available_attrs(view_func))
def dec(request, *args, **kwargs):
if dashboard:
@@ -40,7 +40,7 @@ def dec(request, *args, **kwargs):
def require_auth(view_func):
- """ Performs user authentication check.
+ """Performs user authentication check.
Similar to Django's `login_required` decorator, except that this throws
:exc:`~horizon.exceptions.NotAuthenticated` exception if the user is not
@@ -57,7 +57,7 @@ def dec(request, *args, **kwargs):
def require_perms(view_func, required):
- """ Enforces permission-based access controls.
+ """Enforces permission-based access controls.
:param list required: A tuple of permission names, all of which the request
user must possess in order access the decorated view.
View
@@ -36,15 +36,14 @@
class HorizonReporterFilter(SafeExceptionReporterFilter):
- """ Error report filter that's always active, even in DEBUG mode. """
+ """Error report filter that's always active, even in DEBUG mode."""
def is_active(self, request):
return True
# TODO(gabriel): This bugfix is cribbed from Django's code. When 1.4.1
# is available we can remove this code.
def get_traceback_frame_variables(self, request, tb_frame):
- """
- Replaces the values of variables marked as sensitive with
+ """Replaces the values of variables marked as sensitive with
stars (*********).
"""
# Loop through the frame's callers to see if the sensitive_variables
@@ -93,13 +92,12 @@ def get_traceback_frame_variables(self, request, tb_frame):
class HorizonException(Exception):
- """ Base exception class for distinguishing our own exception classes. """
+ """Base exception class for distinguishing our own exception classes."""
pass
class Http302(HorizonException):
- """
- Error class which can be raised from within a handler to cause an
+ """Error class which can be raised from within a handler to cause an
early bailout and redirect at the middleware level.
"""
status_code = 302
@@ -110,8 +108,7 @@ def __init__(self, location, message=None):
class NotAuthorized(HorizonException):
- """
- Raised whenever a user attempts to access a resource which they do not
+ """Raised whenever a user attempts to access a resource which they do not
have permission-based access to (such as when failing the
:func:`~horizon.decorators.require_perms` decorator).
@@ -123,8 +120,8 @@ class NotAuthorized(HorizonException):
class NotAuthenticated(HorizonException):
- """
- Raised when a user is trying to make requests and they are not logged in.
+ """Raised when a user is trying to make requests and they are not logged
+ in.
The included :class:`~horizon.middleware.HorizonMiddleware` catches
``NotAuthenticated`` and handles it gracefully by displaying an error
@@ -134,28 +131,26 @@ class NotAuthenticated(HorizonException):
class NotFound(HorizonException):
- """ Generic error to replace all "Not Found"-type API errors. """
+ """Generic error to replace all "Not Found"-type API errors."""
status_code = 404
class RecoverableError(HorizonException):
- """ Generic error to replace any "Recoverable"-type API errors. """
+ """Generic error to replace any "Recoverable"-type API errors."""
status_code = 100 # HTTP status code "Continue"
class ServiceCatalogException(HorizonException):
- """
- Raised when a requested service is not available in the ``ServiceCatalog``
- returned by Keystone.
+ """Raised when a requested service is not available in the
+ ``ServiceCatalog`` returned by Keystone.
"""
def __init__(self, service_name):
message = 'Invalid service catalog service: %s' % service_name
super(ServiceCatalogException, self).__init__(message)
class AlreadyExists(HorizonException):
- """
- Exception to be raised when trying to create an API resource which
+ """Exception to be raised when trying to create an API resource which
already exists.
"""
def __init__(self, name, resource_type):
@@ -173,21 +168,19 @@ def __unicode__(self):
class WorkflowError(HorizonException):
- """ Exception to be raised when something goes wrong in a workflow. """
+ """Exception to be raised when something goes wrong in a workflow."""
pass
class WorkflowValidationError(HorizonException):
- """
- Exception raised during workflow validation if required data is missing,
+ """Exception raised during workflow validation if required data is missing,
or existing data is not valid.
"""
pass
class HandledException(HorizonException):
- """
- Used internally to track exceptions that have gone through
+ """Used internally to track exceptions that have gone through
:func:`horizon.exceptions.handle` more than once.
"""
def __init__(self, wrapped):
@@ -205,8 +198,7 @@ def error_color(msg):
def check_message(keywords, message):
- """
- Checks an exception for given keywords and raises a new ``ActionError``
+ """Checks an exception for given keywords and raises a new ``ActionError``
with the desired message if the keywords are found. This allows selective
control over API error messages.
"""
@@ -218,7 +210,7 @@ def check_message(keywords, message):
def handle(request, message=None, redirect=None, ignore=False,
escalate=False, log_level=None, force_log=None):
- """ Centralized error handling for Horizon.
+ """Centralized error handling for Horizon.
Because Horizon consumes so many different APIs with completely
different ``Exception`` types, it's necessary to have a centralized
Oops, something went wrong.

0 comments on commit da8c69a

Please sign in to comment.