Merge "Fix D204: blank line required after class docstring (PEP257)"

This commit is contained in:
Jenkins
2015-10-29 17:16:23 +00:00
committed by Gerrit Code Review
44 changed files with 74 additions and 2 deletions
+1
View File
@@ -93,6 +93,7 @@ class AuthContext(dict):
earliest value.
"""
# identity attributes need to be reconciled among the auth plugins
IDENTITY_ATTRIBUTES = frozenset(['user_id', 'project_id',
'access_token_id', 'domain_id',
+1
View File
@@ -93,6 +93,7 @@ class Domain(Base):
class KerberosDomain(Domain):
"""Allows `kerberos` as a method."""
def _authenticate(self, remote_user, context):
auth_type = context['environment'].get('AUTH_TYPE')
if auth_type != 'Negotiate':
+2
View File
@@ -43,6 +43,7 @@ class _MemcacheClient(memcache.Client):
methods overloaded by threading.local so we can reuse clients in
different threads
"""
__delattr__ = object.__delattr__
__getattribute__ = object.__getattribute__
__new__ = object.__new__
@@ -61,6 +62,7 @@ class ConnectionPool(queue.Queue):
This class implements the basic connection pool logic as an abstract base
class.
"""
def __init__(self, maxsize, unused_timeout, conn_get_timeout=None):
"""Initialize the connection pool.
+1
View File
@@ -33,6 +33,7 @@ class NoopCacheBackend(api.CacheBackend):
mechanism to cleanup it's internal dict and therefore could cause run-away
memory utilization.
"""
def __init__(self, *args):
return
+1
View File
@@ -210,6 +210,7 @@ def filterprotected(*filters):
class V2Controller(wsgi.Application):
"""Base controller class for Identity API v2."""
def _normalize_domain_id(self, context, ref):
"""Fill in domain_id since v2 calls are not domain-aware.
+1
View File
@@ -60,6 +60,7 @@ class UnresolvableDependencyException(Exception):
See ``resolve_future_dependencies()`` for more details.
"""
def __init__(self, name, targets):
msg = _('Unregistered dependency: %(name)s for %(targets)s') % {
'name': name, 'targets': targets}
+1
View File
@@ -45,6 +45,7 @@ class Hints(object):
* ``type``: will always be 'filter'
"""
def __init__(self):
self.limit = None
self.filters = list()
+1
View File
@@ -38,6 +38,7 @@ class MemoryBackend(api.CacheBackend):
'keystone.common.kvs.Memory'
)
"""
def __init__(self, arguments):
self._db = {}
@@ -47,6 +47,7 @@ class MemcachedLock(object):
http://amix.dk/blog/post/19386
"""
def __init__(self, client_fn, key, lock_timeout, max_lock_attempts):
self.client_fn = client_fn
self.key = "_lock" + key
@@ -81,6 +82,7 @@ class MemcachedBackend(object):
time `memcached`, `bmemcached`, `pylibmc` and `pooled_memcached` are
valid).
"""
def __init__(self, arguments):
self._key_mangler = None
self.raw_no_expiry_keys = set(arguments.pop('no_expiry_keys', set()))
+3
View File
@@ -76,6 +76,7 @@ class KeyValueStore(object):
This manager also supports the concept of locking a given key resource to
allow for a guaranteed atomic transaction to the backend.
"""
def __init__(self, kvs_region):
self.locking = True
self._lock_timeout = 0
@@ -251,6 +252,7 @@ class KeyValueStore(object):
class _LockWrapper(object):
"""weakref-capable threading.Lock wrapper."""
def __init__(self, lock_timeout):
self.lock = threading.Lock()
self.lock_timeout = lock_timeout
@@ -367,6 +369,7 @@ class KeyValueStoreLock(object):
This is only a write lock, and will not prevent reads from occurring.
"""
def __init__(self, mutex, key, locking_enabled=True, lock_timeout=0):
self.mutex = mutex
self.key = key
+5
View File
@@ -414,6 +414,7 @@ class LDAPHandler(object):
derived classes.
"""
@abc.abstractmethod
def __init__(self, conn=None):
self.conn = conn
@@ -620,6 +621,7 @@ def _common_ldap_initialization(url, use_tls=False, tls_cacertfile=None,
class MsgId(list):
"""Wrapper class to hold connection and msgid."""
pass
@@ -660,6 +662,7 @@ class PooledLDAPHandler(LDAPHandler):
the methods in this class.
"""
# Added here to allow override for testing
Connector = ldappool.StateConnector
auth_pool_prefix = 'auth_pool_'
@@ -852,6 +855,7 @@ class KeystoneLDAPHandler(LDAPHandler):
OpenStack.
"""
def __init__(self, conn=None):
super(KeystoneLDAPHandler, self).__init__(conn=conn)
self.page_size = 0
@@ -1898,6 +1902,7 @@ class ProjectLdapStructureMixin(object):
This is shared between the resource and assignment LDAP backends.
"""
DEFAULT_OU = 'ou=Groups'
DEFAULT_STRUCTURAL_CLASSES = []
DEFAULT_OBJECTCLASS = 'groupOfNames'
+1
View File
@@ -21,6 +21,7 @@ Unless marked otherwise, all fields are strings.
class Model(dict):
"""Base model class."""
def __hash__(self):
return self['id'].__hash__()
+2
View File
@@ -81,6 +81,7 @@ def read_cached_file(filename, cache_info, reload_func=None):
class SmarterEncoder(jsonutils.json.JSONEncoder):
"""Help for JSON encoding dict-like objects."""
def default(self, obj):
if not isinstance(obj, dict) and hasattr(obj, 'iteritems'):
return dict(obj.iteritems())
@@ -89,6 +90,7 @@ class SmarterEncoder(jsonutils.json.JSONEncoder):
class PKIEncoder(SmarterEncoder):
"""Special encoder to make token JSON a bit shorter."""
item_separator = ','
key_separator = ':'
+4
View File
@@ -123,6 +123,7 @@ def best_match_language(req):
class BaseApplication(object):
"""Base WSGI application wrapper. Subclasses need to implement __call__."""
@classmethod
def factory(cls, global_config, **local_config):
"""Used for paste app factories in paste.deploy config files.
@@ -395,6 +396,7 @@ class Middleware(Application):
behavior.
"""
@classmethod
def factory(cls, global_config, **local_config):
"""Used for paste app factories in paste.deploy config files.
@@ -473,6 +475,7 @@ class Debug(Middleware):
about the request and response.
"""
@webob.dec.wsgify()
def __call__(self, req):
if not hasattr(LOG, 'isEnabledFor') or LOG.isEnabledFor(LOG.debug):
@@ -596,6 +599,7 @@ class ExtensionRouter(Router):
Expects to be subclassed.
"""
def __init__(self, application, mapper=None):
if mapper is None:
mapper = routes.Mapper()
@@ -20,6 +20,7 @@ from keystone.i18n import _
class ProjectEndpoint(sql.ModelBase, sql.ModelDictMixin):
"""project-endpoint relationship table."""
__tablename__ = 'project_endpoint'
attributes = ['endpoint_id', 'project_id']
endpoint_id = sql.Column(sql.String(64),
@@ -32,6 +33,7 @@ class ProjectEndpoint(sql.ModelBase, sql.ModelDictMixin):
class EndpointGroup(sql.ModelBase, sql.ModelDictMixin):
"""Endpoint Groups table."""
__tablename__ = 'endpoint_group'
attributes = ['id', 'name', 'description', 'filters']
mutable_attributes = frozenset(['name', 'description', 'filters'])
@@ -43,6 +45,7 @@ class EndpointGroup(sql.ModelBase, sql.ModelDictMixin):
class ProjectEndpointGroupMembership(sql.ModelBase, sql.ModelDictMixin):
"""Project to Endpoint group relationship table."""
__tablename__ = 'project_endpoint_group'
attributes = ['endpoint_group_id', 'project_id']
endpoint_group_id = sql.Column(sql.String(64),
@@ -64,6 +64,7 @@ class EndpointFilterExtension(wsgi.V3ExtensionRouter):
{project_id}
"""
PATH_PREFIX = '/OS-EP-FILTER'
PATH_PROJECT_ENDPOINT = '/projects/{project_id}/endpoints/{endpoint_id}'
PATH_ENDPOINT_GROUPS = '/endpoint_groups/{endpoint_group_id}'
@@ -51,6 +51,7 @@ class _ControllerBase(controller.V3Controller):
@dependency.requires('federation_api')
class IdentityProvider(_ControllerBase):
"""Identity Provider representation."""
collection_name = 'identity_providers'
member_name = 'identity_provider'
@@ -129,6 +130,7 @@ class FederationProtocol(_ControllerBase):
and _public_parameters class attributes.
"""
collection_name = 'protocols'
member_name = 'protocol'
+1
View File
@@ -91,6 +91,7 @@ class FederationExtension(wsgi.V3ExtensionRouter):
?origin=https%3A//horizon.example.com
"""
def _construct_url(self, suffix):
return "/OS-FEDERATION/%s" % suffix
+2
View File
@@ -359,6 +359,7 @@ def get_assertion_params_from_env(context):
class UserType(object):
"""User mapping type."""
EPHEMERAL = 'ephemeral'
LOCAL = 'local'
@@ -368,6 +369,7 @@ class RuleProcessor(object):
class _EvalType(object):
"""Mapping rule evaluation types."""
ANY_ONE_OF = 'any_one_of'
NOT_ANY_OF = 'not_any_of'
BLACKLIST = 'blacklist'
+4
View File
@@ -33,6 +33,7 @@ class Error(Exception):
message_format.
"""
code = None
title = None
message_format = None
@@ -160,6 +161,7 @@ class PKITokenExpected(Error):
class SecurityError(Error):
"""Avoids exposing details of security failures, unless in debug mode."""
amendment = _('(Disable debug mode to suppress these details.)')
def _build_message(self, message, **kwargs):
@@ -255,6 +257,7 @@ class MetadataNotFound(NotFound):
"""(dolph): metadata is not a user-facing concept,
so this exception should not be exposed
"""
message_format = _("An unhandled exception has occurred:"
" Could not find metadata.")
@@ -373,6 +376,7 @@ class Conflict(Error):
class UnexpectedError(SecurityError):
"""Avoids exposing details of failures, unless in debug mode."""
_message_format = _("An unexpected error prevented the server "
"from fulfilling your request.")
+1
View File
@@ -61,6 +61,7 @@ class Group(sql.ModelBase, sql.DictBase):
class UserGroupMembership(sql.ModelBase, sql.DictBase):
"""Group membership join table."""
__tablename__ = 'user_group_membership'
user_id = sql.Column(sql.String(64),
sql.ForeignKey('user.id'),
+2
View File
@@ -92,6 +92,7 @@ class DomainConfigs(dict):
the identity manager and driver can use.
"""
configured = False
driver = None
_any_sql = False
@@ -484,6 +485,7 @@ class Manager(manager.Manager):
mapping by default is a more prudent way to introduce this functionality.
"""
driver_namespace = 'keystone.identity'
_USER = 'user'
+1
View File
@@ -106,6 +106,7 @@ class JsonBodyMiddleware(wsgi.Middleware):
an underscore.
"""
def process_request(self, request):
# Abort early if we don't have any work to do
params_json = request.body
+1
View File
@@ -37,6 +37,7 @@ def _parse_and_normalize_time(time_data):
class KeystoneToken(dict):
"""An in-memory representation that unifies v2 and v3 tokens."""
# TODO(morganfainberg): Align this in-memory representation with the
# objects in keystoneclient. This object should be eventually updated
# to be the source of token data with the ability to emit any version
+1
View File
@@ -166,6 +166,7 @@ class ManagerNotificationWrapper(object):
notify_event_callbacks to in process listeners
"""
def __init__(self, operation, resource_type, public=True,
resource_id_arg_index=1, result_id_arg_attr=None):
self.operation = operation
+2
View File
@@ -86,6 +86,7 @@ class BaseBackendLdapCommon(object):
class BaseBackendLdap(object):
"""Mixin class to set up an all-LDAP configuration."""
def setUp(self):
# NOTE(dstanek): The database must be setup prior to calling the
# parent's setUp. The parent's setUp uses services (like
@@ -137,6 +138,7 @@ class BaseBackendLdapIdentitySqlEverythingElseWithMapping(object):
Setting backward_compatible_ids to False will enable this mapping.
"""
def config_overrides(self):
super(BaseBackendLdapIdentitySqlEverythingElseWithMapping,
self).config_overrides()
@@ -32,6 +32,7 @@ class LdapRoleCommon(core_ldap.BaseBackendLdapCommon, core_role.RoleTests):
which should be run for all the various LDAP configurations we test.
"""
pass
@@ -42,6 +43,7 @@ class LdapRole(LdapRoleCommon, core_ldap.BaseBackendLdap, unit.TestCase):
which only need to be run in a basic LDAP configurations.
"""
def test_configurable_allowed_role_actions(self):
role = {'id': u'fäké1', 'name': u'fäké1'}
self.role_api.create_role(u'fäké1', role)
@@ -151,6 +153,7 @@ class LdapIdentitySqlEverythingElseRole(
core_ldap.BaseBackendLdapIdentitySqlEverythingElse, LdapRoleCommon,
unit.TestCase):
"""Test Identity in LDAP, Everything else in SQL."""
pass
@@ -158,4 +161,5 @@ class LdapIdentitySqlEverythingElseWithMappingRole(
LdapIdentitySqlEverythingElseRole,
core_ldap.BaseBackendLdapIdentitySqlEverythingElseWithMapping):
"""Test ID mapping of default LDAP backend."""
pass
+1
View File
@@ -707,6 +707,7 @@ class TestCase(BaseTestCase):
class SQLDriverOverrides(object):
"""A mixin for consolidating sql-specific test overrides."""
def config_overrides(self):
super(SQLDriverOverrides, self).config_overrides()
# SQL specific driver overrides
+1
View File
@@ -136,6 +136,7 @@ class AssignmentTestHelperMixin(object):
# 'inherited_to_projects' options to list_role_assignments.}
"""
def _handle_project_spec(self, test_data, domain_id, project_spec,
parent_id=None):
"""Handle the creation of a project or hierarchy of projects.
+4
View File
@@ -2415,6 +2415,7 @@ class LdapIdentitySqlAssignmentWithMapping(LdapIdentitySqlAssignment):
Setting backward_compatible_ids to False will enable this mapping.
"""
def config_overrides(self):
super(LdapIdentitySqlAssignmentWithMapping, self).config_overrides()
self.config_fixture.config(group='identity_mapping',
@@ -2579,6 +2580,7 @@ class MultiLDAPandSQLIdentity(BaseLDAPIdentity, unit.SQLDriverOverrides,
domain.
"""
def setUp(self):
sqldb = self.useFixture(database.Database())
super(MultiLDAPandSQLIdentity, self).setUp()
@@ -3082,6 +3084,7 @@ class DomainSpecificLDAPandSQLIdentity(
Although the default driver still exists, we don't use it.
"""
def setUp(self):
sqldb = self.useFixture(database.Database())
super(DomainSpecificLDAPandSQLIdentity, self).setUp()
@@ -3246,6 +3249,7 @@ class DomainSpecificSQLIdentity(DomainSpecificLDAPandSQLIdentity):
- A separate SQL backend for domain1
"""
def initial_setup(self, sqldb):
# We aren't setting up any initial data ahead of switching to
# domain-specific operation, so make the switch straight away.
@@ -211,6 +211,7 @@ class LdapIdentitySqlAssignment(LdapPoolCommonTestMixin,
test_backend_ldap.LdapIdentitySqlAssignment,
unit.TestCase):
"""Executes tests in existing base class with pooled LDAP handler."""
def setUp(self):
self.useFixture(mockpatch.PatchObject(
ldap_core.PooledLDAPHandler, 'Connector', fakeldap.FakeLdapPool))
+1
View File
@@ -89,6 +89,7 @@ class TestMemcacheDriver(api.CacheBackend):
"""A test dogpile.cache backend that conforms to the mixin-mechanism for
overriding set and set_multi methods on dogpile memcached drivers.
"""
class test_client(object):
# FIXME(morganfainberg): Convert this test client over to using mock
# and/or mock.MagicMock as appropriate
@@ -20,6 +20,7 @@ from keystone.tests import unit
class FakeApp(object):
"""Fakes a WSGI app URL normalized."""
def __call__(self, env, start_response):
resp = webob.Response()
resp.body = 'SUCCESS'
@@ -33,6 +33,7 @@ class TenantTestCase(unit.TestCase):
These tests exercise :class:`keystone.assignment.controllers.Tenant`.
"""
def setUp(self):
super(TenantTestCase, self).setUp()
self.useFixture(database.Database())
+2
View File
@@ -39,6 +39,7 @@ TIME_FORMAT = unit.TIME_FORMAT
class AuthTestMixin(object):
"""To hold auth building helper functions."""
def build_auth_scope(self, project_id=None, project_name=None,
project_domain_id=None, project_domain_name=None,
domain_id=None, domain_name=None, trust_id=None,
@@ -1284,6 +1285,7 @@ class JsonHomeTestMixin(object):
data must be in the response.
"""
def test_get_json_home(self):
resp = self.get('/', convert=False,
headers={'Accept': 'application/json-home'})
@@ -3099,6 +3099,7 @@ class AssignmentInheritanceDisabledTestCase(test_v3.RestfulTestCase):
class AssignmentV3toV2MethodsTestCase(unit.TestCase):
"""Test domain V3 to V2 conversion methods."""
def _setup_initial_projects(self):
self.project_id = uuid.uuid4().hex
self.domain_id = CONF.identity.default_domain_id
@@ -25,6 +25,7 @@ from keystone.tests import unit
class V3ControllerTestCase(unit.TestCase):
"""Tests for the V3Controller class."""
def setUp(self):
super(V3ControllerTestCase, self).setUp()
@@ -53,6 +53,7 @@ class CredentialBaseTestCase(test_v3.RestfulTestCase):
class CredentialTestCase(CredentialBaseTestCase):
"""Test credential CRUD."""
def setUp(self):
super(CredentialTestCase, self).setUp()
@@ -284,6 +285,7 @@ class CredentialTestCase(CredentialBaseTestCase):
class TestCredentialTrustScoped(test_v3.RestfulTestCase):
"""Test credential with trust scoped token."""
def setUp(self):
super(TestCredentialTrustScoped, self).setUp()
@@ -356,6 +358,7 @@ class TestCredentialTrustScoped(test_v3.RestfulTestCase):
class TestCredentialEc2(CredentialBaseTestCase):
"""Test v3 credential compatibility with ec2tokens."""
def setUp(self):
super(TestCredentialEc2, self).setUp()
@@ -2438,6 +2438,7 @@ class FederatedTokenTestsMethodToken(FederatedTokenTests):
way for scoping all the tokens.
"""
AUTH_METHOD = 'token'
def auth_plugin_config_override(self):
+1
View File
@@ -324,6 +324,7 @@ class IdentityTestFilteredCase(filtering.FilterTests,
class IdentityTestListLimitCase(IdentityTestFilteredCase):
"""Test list limiting enforcement on the v3 Identity API."""
content_type = 'json'
def setUp(self):
+1
View File
@@ -38,6 +38,7 @@ LOG = log.getLogger(__name__)
class ExternalAuthNotApplicable(Exception):
"""External authentication is not applicable."""
pass
+1
View File
@@ -206,6 +206,7 @@ class Manager(object):
This class is a proxy class to the token_provider_api's persistence
manager.
"""
def __init__(self):
# NOTE(morganfainberg): __init__ is required for dependency processing.
super(Manager, self).__init__()
+1
View File
@@ -235,6 +235,7 @@ class V2TokenDataHelper(object):
'identity_api', 'resource_api', 'role_api', 'trust_api')
class V3TokenDataHelper(object):
"""Token data helper."""
def __init__(self):
# Keep __init__ around to ensure dependency injection works.
super(V3TokenDataHelper, self).__init__()
+1 -2
View File
@@ -111,11 +111,10 @@ show-source = true
# D105: Missing docstring in magic method
# D202: No blank lines allowed after docstring.
# D203: 1 blank required before class docstring.
# D204: 1 blank required after class docstring
# D205: Blank line required between one-line summary and description.
# D400: First line should end with a period.
# D401: First line should be in imperative mood.
ignore = H405,D100,D101,D102,D103,D104,D105,D203,D204,D205,D400,D401
ignore = H405,D100,D101,D102,D103,D104,D105,D203,D205,D400,D401
exclude=.venv,.git,.tox,build,dist,doc,*openstack/common*,*lib/python*,*egg,tools,vendor,.update-venv,*.ini,*.po,*.pot
max-complexity=24