pass on @abc.abstractmethods

Although a bare docstring is entirely valid grammar, those new to Python find
that pattern baffling, *especially* when other similar methods contain pass
statements. So, for consistency, add a pass statement to otherwise bare
@abc.abstractmethods.

Note that the implementation of an @abc.abstractmethod (in the abstract
base class) can still be called by concrete children, so suddenly
raising a NotImplementedError() instead might be "surprising" to
implementors. A no-op such as "pass" or "return None" is preferable.

Change-Id: I79969ad1a3429516ea785c649a165ead54944225
This commit is contained in:
Dolph Mathews
2015-10-21 15:32:33 +00:00
parent 6588ad5fb5
commit 574fad7abb
6 changed files with 10 additions and 2 deletions

View File

@@ -184,6 +184,7 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
:returns: Token access information.
:rtype: :py:class:`keystoneclient.access.AccessInfo`
"""
pass
def get_token(self, session, **kwargs):
"""Return a valid auth token.

View File

@@ -103,6 +103,7 @@ class Auth(base.BaseIdentityPlugin):
:return: A dict of authentication data for the auth type.
:rtype: dict
"""
pass
_NOT_PASSED = object()

View File

@@ -240,6 +240,7 @@ class AuthMethod(object):
data for the auth type.
:rtype: tuple(string, dict)
"""
pass
@six.add_metaclass(abc.ABCMeta)

View File

@@ -204,8 +204,8 @@ class BaseAuthPlugin(object):
@abc.abstractmethod
def _do_authenticate(self, http_client):
"""Protected method for authentication.
"""
"""Protected method for authentication."""
pass
def sufficient_options(self):
"""Check if all required options are present.
@@ -232,3 +232,4 @@ class BaseAuthPlugin(object):
:returns: tuple of token and endpoint strings
:raises: EndpointException
"""
pass

View File

@@ -110,6 +110,7 @@ class ServiceCatalog(object):
:returns: True if the provided endpoint matches the required
endpoint_type otherwise False.
"""
pass
@abc.abstractmethod
def _normalize_endpoint_type(self, endpoint_type):
@@ -122,6 +123,7 @@ class ServiceCatalog(object):
:returns: the endpoint string in the format appropriate for this
service catalog.
"""
pass
def get_endpoints(self, service_type=None, endpoint_type=None,
region_name=None, service_name=None):

View File

@@ -55,6 +55,7 @@ class CommonIdentityTests(object):
It doesn't really matter what auth mechanism is used but it should be
appropriate to the API version.
"""
pass
@abc.abstractmethod
def get_auth_data(self, **kwargs):
@@ -63,6 +64,7 @@ class CommonIdentityTests(object):
This should register a valid token response and ensure that the compute
endpoints are set to TEST_COMPUTE_PUBLIC, _INTERNAL and _ADMIN.
"""
pass
def stub_auth_data(self, **kwargs):
token = self.get_auth_data(**kwargs)