Fixing D105 PEP257

Currently tox ignores D105.
D105: Missing docstring in magic method.
This change removes it and make keystoneclient docstring compliant with it.

Change-Id: I34dfc164891880425f542f8f8aa3426ec8640c96
This commit is contained in:
Navid Pustchi
2016-05-04 19:14:01 +00:00
parent 4c180e691f
commit 01500be7fb
14 changed files with 17 additions and 2 deletions

View File

@@ -460,6 +460,7 @@ class Resource(object):
self._loaded = loaded self._loaded = loaded
def __repr__(self): def __repr__(self):
"""Return string representation of resource attributes."""
reprkeys = sorted(k reprkeys = sorted(k
for k in self.__dict__.keys() for k in self.__dict__.keys()
if k[0] != '_' and k != 'manager') if k[0] != '_' and k != 'manager')
@@ -485,6 +486,7 @@ class Resource(object):
pass pass
def __getattr__(self, k): def __getattr__(self, k):
"""Checking attrbiute existence."""
if k not in self.__dict__: if k not in self.__dict__:
# NOTE(bcwaldon): disallow lazy-loading if already loaded once # NOTE(bcwaldon): disallow lazy-loading if already loaded once
if not self.is_loaded(): if not self.is_loaded():
@@ -513,6 +515,7 @@ class Resource(object):
{'x_request_id': self.manager.client.last_request_id}) {'x_request_id': self.manager.client.last_request_id})
def __eq__(self, other): def __eq__(self, other):
"""Define equality for resources."""
if not isinstance(other, Resource): if not isinstance(other, Resource):
return NotImplemented return NotImplemented
# two resources of different types are not equal # two resources of different types are not equal

View File

@@ -868,6 +868,7 @@ class HTTPClient(baseclient.Client, base.BaseAuthPlugin):
deprecated_adapter_variables = {'region_name': None} deprecated_adapter_variables = {'region_name': None}
def __getattr__(self, name): def __getattr__(self, name):
"""Fetch deprecated session variables."""
try: try:
var_name = self.deprecated_session_variables[name] var_name = self.deprecated_session_variables[name]
except KeyError: # nosec(cjschaef): try adapter variable or raise except KeyError: # nosec(cjschaef): try adapter variable or raise
@@ -894,6 +895,7 @@ class HTTPClient(baseclient.Client, base.BaseAuthPlugin):
raise AttributeError(_("Unknown Attribute: %s") % name) raise AttributeError(_("Unknown Attribute: %s") % name)
def __setattr__(self, name, val): def __setattr__(self, name, val):
"""Assign value to deprecated seesion variables."""
try: try:
var_name = self.deprecated_session_variables[name] var_name = self.deprecated_session_variables[name]
except KeyError: # nosec(cjschaef): try adapter variable or call except KeyError: # nosec(cjschaef): try adapter variable or call

View File

@@ -37,6 +37,7 @@ class MockPlugin(base.BaseAuthPlugin):
self._data = kwargs self._data = kwargs
def __getitem__(self, key): def __getitem__(self, key):
"""Get the data of the key."""
return self._data[key] return self._data[key]
def get_token(self, *args, **kwargs): def get_token(self, *args, **kwargs):

View File

@@ -18,6 +18,7 @@ from keystoneclient import base
class EC2(base.Resource): class EC2(base.Resource):
def __repr__(self): def __repr__(self):
"""Return string representation of EC2 resource information."""
return "<EC2 %s>" % self._info return "<EC2 %s>" % self._info
def delete(self): def delete(self):

View File

@@ -20,6 +20,7 @@ class Endpoint(base.Resource):
"""Represents a Keystone endpoint.""" """Represents a Keystone endpoint."""
def __repr__(self): def __repr__(self):
"""Return string representation of endpoint resource information."""
return "<Endpoint %s>" % self._info return "<Endpoint %s>" % self._info

View File

@@ -17,6 +17,7 @@ class Extension(base.Resource):
"""Represents an Identity API extension.""" """Represents an Identity API extension."""
def __repr__(self): def __repr__(self):
"""Return string representation of extension resource information."""
return "<Extension %s>" % self._info return "<Extension %s>" % self._info

View File

@@ -21,6 +21,7 @@ class Role(base.Resource):
"""Represents a Keystone role.""" """Represents a Keystone role."""
def __repr__(self): def __repr__(self):
"""Return string representation of role resource information."""
return "<Role %s>" % self._info return "<Role %s>" % self._info
def delete(self): def delete(self):

View File

@@ -21,6 +21,7 @@ class Service(base.Resource):
"""Represents a Keystone service.""" """Represents a Keystone service."""
def __repr__(self): def __repr__(self):
"""Return string representation of service resource information."""
return "<Service %s>" % self._info return "<Service %s>" % self._info

View File

@@ -34,6 +34,7 @@ class Tenant(base.Resource):
""" """
def __repr__(self): def __repr__(self):
"""Return string representation of tenant resource information."""
return "<Tenant %s>" % self._info return "<Tenant %s>" % self._info
def delete(self): def delete(self):

View File

@@ -21,6 +21,7 @@ from keystoneclient.i18n import _
class Token(base.Resource): class Token(base.Resource):
def __repr__(self): def __repr__(self):
"""Return string representation of resource information."""
return "<Token %s>" % self._info return "<Token %s>" % self._info
@property @property

View File

@@ -23,6 +23,7 @@ class User(base.Resource):
"""Represents a Keystone user.""" """Represents a Keystone user."""
def __repr__(self): def __repr__(self):
"""Return string representation of user resource information."""
return "<User %s>" % self._info return "<User %s>" % self._info
def delete(self): def delete(self):

View File

@@ -58,6 +58,7 @@ class OAuthManagerOptionalImportProxy(object):
""" """
def __getattribute__(self, name): def __getattribute__(self, name):
"""Return error when name is related to oauthlib and not exist."""
if name in ('access_tokens', 'consumers', 'request_tokens'): if name in ('access_tokens', 'consumers', 'request_tokens'):
raise NotImplementedError( raise NotImplementedError(
_('To use %r oauthlib must be installed') % name) _('To use %r oauthlib must be installed') % name)

View File

@@ -16,6 +16,7 @@ from keystoneclient import base
class EC2(base.Resource): class EC2(base.Resource):
def __repr__(self): def __repr__(self):
"""Return string representation of EC2 resource information."""
return "<EC2 %s>" % self._info return "<EC2 %s>" % self._info

View File

@@ -45,8 +45,7 @@ passenv = OS_*
# D102: Missing docstring in public method # D102: Missing docstring in public method
# D103: Missing docstring in public function # D103: Missing docstring in public function
# D104: Missing docstring in public package # D104: Missing docstring in public package
# D105: Missing docstring in magic method ignore = D100,D101,D102,D103,D104
ignore = D100,D101,D102,D103,D104,D105
show-source = True show-source = True
exclude = .venv,.tox,dist,doc,*egg,build,*openstack/common* exclude = .venv,.tox,dist,doc,*egg,build,*openstack/common*