Fix D401 PEP257 violation.

Currently tox ignores D401.
401: First line should be in imperative mood.
This change removes it and make keystoneclient docstrings compliant with it.

Change-Id: If34ff12d18390b357342cf29f2d116dd3c86a44d
This commit is contained in:
Navid Pustchi
2016-04-23 03:19:58 +00:00
parent c089370930
commit 946e928b52
20 changed files with 66 additions and 67 deletions

View File

@@ -97,7 +97,7 @@ class AccessInfo(dict):
return self.get('region_name')
def will_expire_soon(self, stale_duration=None):
"""Determines if expiration is about to occur.
"""Determine if expiration is about to occur.
:returns: true if expiration is within the given duration
:rtype: boolean
@@ -114,7 +114,7 @@ class AccessInfo(dict):
@classmethod
def is_valid(cls, body, **kwargs):
"""Determines if processing valid v2 or v3 token.
"""Determine if processing valid v2 or v3 token.
Validates from the auth body or a user-provided dict.
@@ -124,7 +124,7 @@ class AccessInfo(dict):
raise NotImplementedError()
def has_service_catalog(self):
"""Returns true if the authorization token has a service catalog.
"""Return true if the authorization token has a service catalog.
:returns: boolean
"""
@@ -132,7 +132,7 @@ class AccessInfo(dict):
@property
def auth_token(self):
"""Returns the token_id associated with the auth request.
"""Return the token_id associated with the auth request.
To be used in headers for authenticating OpenStack API requests.
@@ -153,7 +153,7 @@ class AccessInfo(dict):
@property
def expires(self):
"""Returns the token expiration (as datetime object)
"""Return the token expiration (as datetime object)
:returns: datetime
"""
@@ -161,7 +161,7 @@ class AccessInfo(dict):
@property
def issued(self):
"""Returns the token issue time (as datetime object)
"""Return the token issue time (as datetime object)
:returns: datetime
"""
@@ -169,7 +169,7 @@ class AccessInfo(dict):
@property
def username(self):
"""Returns the username associated with the auth request.
"""Return the username associated with the auth request.
Follows the pattern defined in the V2 API of first looking for 'name',
returning that if available, and falling back to 'username' if name
@@ -181,7 +181,7 @@ class AccessInfo(dict):
@property
def user_id(self):
"""Returns the user id associated with the auth request.
"""Return the user id associated with the auth request.
:returns: str
"""
@@ -189,7 +189,7 @@ class AccessInfo(dict):
@property
def user_domain_id(self):
"""Returns the user's domain id associated with the auth request.
"""Return the user's domain id associated with the auth request.
For v2, it always returns 'default' which may be different from the
Keystone configuration.
@@ -200,7 +200,7 @@ class AccessInfo(dict):
@property
def user_domain_name(self):
"""Returns the user's domain name associated with the auth request.
"""Return the user's domain name associated with the auth request.
For v2, it always returns 'Default' which may be different from the
Keystone configuration.
@@ -211,7 +211,7 @@ class AccessInfo(dict):
@property
def role_ids(self):
"""Returns a list of user's role ids associated with the auth request.
"""Return a list of user's role ids associated with the auth request.
:returns: a list of strings of role ids
"""
@@ -219,7 +219,7 @@ class AccessInfo(dict):
@property
def role_names(self):
"""Returns a list of user's role names associated with the auth request.
"""Return a list of user's role names associated with the auth request.
:returns: a list of strings of role names
"""
@@ -227,7 +227,7 @@ class AccessInfo(dict):
@property
def domain_name(self):
"""Returns the domain name associated with the auth request.
"""Return the domain name associated with the auth request.
:returns: str or None (if no domain associated with the token)
"""
@@ -235,7 +235,7 @@ class AccessInfo(dict):
@property
def domain_id(self):
"""Returns the domain id associated with the auth request.
"""Return the domain id associated with the auth request.
:returns: str or None (if no domain associated with the token)
"""
@@ -243,7 +243,7 @@ class AccessInfo(dict):
@property
def project_name(self):
"""Returns the project name associated with the auth request.
"""Return the project name associated with the auth request.
:returns: str or None (if no project associated with the token)
"""
@@ -256,9 +256,9 @@ class AccessInfo(dict):
@property
def scoped(self):
"""Returns true if the auth token was scoped.
"""Return true if the auth token was scoped.
Returns true if scoped to a tenant(project) or domain,
Return true if scoped to a tenant(project) or domain,
and contains a populated service catalog.
.. warning::
@@ -272,7 +272,7 @@ class AccessInfo(dict):
@property
def project_scoped(self):
"""Returns true if the auth token was scoped to a tenant(project).
"""Return true if the auth token was scoped to a tenant(project).
:returns: bool
"""
@@ -280,7 +280,7 @@ class AccessInfo(dict):
@property
def domain_scoped(self):
"""Returns true if the auth token was scoped to a domain.
"""Return true if the auth token was scoped to a domain.
:returns: bool
"""
@@ -288,7 +288,7 @@ class AccessInfo(dict):
@property
def trust_id(self):
"""Returns the trust id associated with the auth request.
"""Return the trust id associated with the auth request.
:returns: str or None (if no trust associated with the token)
"""
@@ -296,7 +296,7 @@ class AccessInfo(dict):
@property
def trust_scoped(self):
"""Returns true if the auth token was scoped from a delegated trust.
"""Return true if the auth token was scoped from a delegated trust.
The trust delegation is via the OS-TRUST v3 extension.
@@ -306,7 +306,7 @@ class AccessInfo(dict):
@property
def trustee_user_id(self):
"""Returns the trustee user id associated with a trust.
"""Return the trustee user id associated with a trust.
:returns: str or None (if no trust associated with the token)
"""
@@ -314,7 +314,7 @@ class AccessInfo(dict):
@property
def trustor_user_id(self):
"""Returns the trustor user id associated with a trust.
"""Return the trustor user id associated with a trust.
:returns: str or None (if no trust associated with the token)
"""
@@ -322,7 +322,7 @@ class AccessInfo(dict):
@property
def project_id(self):
"""Returns the project ID associated with the auth request.
"""Return the project ID associated with the auth request.
This returns None if the auth token wasn't scoped to a project.
@@ -337,7 +337,7 @@ class AccessInfo(dict):
@property
def project_domain_id(self):
"""Returns the project's domain id associated with the auth request.
"""Return the project's domain id associated with the auth request.
For v2, it returns 'default' if a project is scoped or None which may
be different from the keystone configuration.
@@ -348,7 +348,7 @@ class AccessInfo(dict):
@property
def project_domain_name(self):
"""Returns the project's domain name associated with the auth request.
"""Return the project's domain name associated with the auth request.
For v2, it returns 'Default' if a project is scoped or None which may
be different from the keystone configuration.
@@ -359,7 +359,7 @@ class AccessInfo(dict):
@property
def auth_url(self):
"""Returns a tuple of identity URLs.
"""Return a tuple of identity URLs.
The identity URLs are from publicURL and adminURL for the service
'identity' from the service catalog associated with the authorization
@@ -376,7 +376,7 @@ class AccessInfo(dict):
@property
def management_url(self):
"""Returns the first adminURL of the identity endpoint.
"""Return the first adminURL of the identity endpoint.
The identity endpoint is from the service catalog
associated with the authorization request, or None if the
@@ -392,7 +392,7 @@ class AccessInfo(dict):
@property
def version(self):
"""Returns the version of the auth token from identity service.
"""Return the version of the auth token from identity service.
:returns: str
"""
@@ -416,7 +416,7 @@ class AccessInfo(dict):
@property
def is_federated(self):
"""Returns true if federation was used to get the token.
"""Return true if federation was used to get the token.
:returns: boolean
"""

View File

@@ -114,14 +114,14 @@ class BaseGenericPlugin(base.BaseIdentityPlugin):
@property
def _v2_params(self):
"""Parameters that are common to v2 plugins."""
"""Return parameters that are common to v2 plugins."""
return {'trust_id': self._trust_id,
'tenant_id': self._project_id,
'tenant_name': self._project_name}
@property
def _v3_params(self):
"""Parameters that are common to v3 plugins."""
"""Return parameters that are common to v3 plugins."""
return {'trust_id': self._trust_id,
'project_id': self._project_id,
'project_name': self._project_name,

View File

@@ -298,7 +298,7 @@ class CrudManager(Manager):
base_url = None
def build_url(self, dict_args_in_out=None):
"""Builds a resource URL for the given kwargs.
"""Build a resource URL for the given kwargs.
Given an example collection where `collection_key = 'entities'` and
`key = 'entity'`, the following URL's could be generated.
@@ -355,7 +355,7 @@ class CrudManager(Manager):
return '?%s' % urllib.parse.urlencode(params) if params else ''
def build_key_only_query(self, params_list):
"""Builds a query that does not include values, just keys.
"""Build a query that does not include values, just keys.
The Identity API has some calls that define queries without values,
this can not be accomplished by using urllib.parse.urlencode(). This

View File

@@ -153,7 +153,7 @@ def _encoding_for_form(inform):
def cms_verify(formatted, signing_cert_file_name, ca_file_name,
inform=PKI_ASN1_FORM):
"""Verifies the signature of the contents IAW CMS syntax.
"""Verify the signature of the contents IAW CMS syntax.
:raises subprocess.CalledProcessError:
:raises keystoneclient.exceptions.CertificateConfigError: if certificate
@@ -241,7 +241,7 @@ def pkiz_verify(signed_text, signing_cert_file_name, ca_file_name):
def token_to_cms(signed_text):
"""Converts a custom formatted token to a PEM-formatted token.
"""Convert a custom formatted token to a PEM-formatted token.
See documentation for cms_to_token() for details on the custom formatting.
"""
@@ -329,7 +329,7 @@ def cms_sign_text(data_to_sign, signing_cert_file_name, signing_key_file_name,
def cms_sign_data(data_to_sign, signing_cert_file_name, signing_key_file_name,
outform=PKI_ASN1_FORM,
message_digest=DEFAULT_TOKEN_DIGEST_ALGORITHM):
"""Uses OpenSSL to sign a document.
"""Use OpenSSL to sign a document.
Produces a Base64 encoding of a DER formatted CMS Document
http://en.wikipedia.org/wiki/Cryptographic_Message_Syntax
@@ -386,7 +386,7 @@ def cms_sign_token(text, signing_cert_file_name, signing_key_file_name,
def cms_to_token(cms_text):
"""Converts a CMS-signed token in PEM format to a custom URL-safe format.
"""Convert a CMS-signed token in PEM format to a custom URL-safe format.
The conversion consists of replacing '/' char in the PEM-formatted token
with the '-' char and doing other such textual replacements to make the

View File

@@ -107,7 +107,7 @@ class RevokeTree(object):
self.add_events(revoke_events)
def add_event(self, event):
"""Updates the tree based on a revocation event.
"""Update the tree based on a revocation event.
Creates any necessary internal nodes in the tree corresponding to the
fields of the revocation event. The leaf node will always be set to

View File

@@ -339,7 +339,7 @@ class Discover(_discover.Discover):
def add_catalog_discover_hack(service_type, old, new):
"""Adds a version removal rule for a particular service.
"""Add a version removal rule for a particular service.
Originally deployments of OpenStack would contain a versioned endpoint in
the catalog for different services. E.g. an identity service might look

View File

@@ -337,7 +337,7 @@ An alias of :py:exc:`keystoneauth1.exceptions.http.HttpVersionNotSupported`
"""
from_response = _exc.from_response
"""Returns an instance of :class:`HttpError` or subclass based on response.
"""Return an instance of :class:`HttpError` or subclass based on response.
An alias of :py:func:`keystoneauth1.exceptions.http.from_response`
"""

View File

@@ -75,14 +75,14 @@ class Client(httpclient.HTTPClient):
return self._local_keystone_exists()
def _local_keystone_exists(self):
"""Checks if Keystone is available on default local port 35357."""
"""Check if Keystone is available on default local port 35357."""
results = self._check_keystone_versions("http://localhost:35357")
if results is None:
results = self._check_keystone_versions("https://localhost:35357")
return results
def _check_keystone_versions(self, url):
"""Calls Keystone URL and detects the available API versions."""
"""Call Keystone URL and detects the available API versions."""
try:
resp, body = self._request(url, "GET",
headers={'Accept':
@@ -144,7 +144,7 @@ class Client(httpclient.HTTPClient):
return self._check_keystone_extensions(url)
def _check_keystone_extensions(self, url):
"""Calls Keystone URL and detects the available extensions."""
"""Call Keystone URL and detects the available extensions."""
try:
if not url.endswith("/"):
url += '/'
@@ -173,7 +173,7 @@ class Client(httpclient.HTTPClient):
@staticmethod
def _get_version_info(version, root_url):
"""Parses version information.
"""Parse version information.
:param version: a dict of a Keystone version response
:param root_url: string url used to construct
@@ -192,7 +192,7 @@ class Client(httpclient.HTTPClient):
@staticmethod
def _get_extension_info(extension):
"""Parses extension information.
"""Parse extension information.
:param extension: a dict of a Keystone extension response
:returns: tuple - (alias, name)

View File

@@ -447,11 +447,11 @@ class HTTPClient(baseclient.Client, base.BaseAuthPlugin):
@property
def service_catalog(self):
"""Returns this client's service catalog."""
"""Return this client's service catalog."""
return self.auth_ref.service_catalog
def has_service_catalog(self):
"""Returns True if this client provides a service catalog."""
"""Return True if this client provides a service catalog."""
return self.auth_ref and self.auth_ref.has_service_catalog()
@property
@@ -608,7 +608,7 @@ class HTTPClient(baseclient.Client, base.BaseAuthPlugin):
Used to store and retrieve auth_ref from keyring.
Returns a slash-separated string of values ordered by key name.
Return a slash-separated string of values ordered by key name.
"""
return '/'.join([kwargs[k] or '?' for k in sorted(kwargs)])
@@ -751,7 +751,7 @@ class HTTPClient(baseclient.Client, base.BaseAuthPlugin):
return self._adapter.request(*args, **kwargs)
def _cs_request(self, url, method, management=True, **kwargs):
"""Makes an authenticated request to keystone endpoint.
"""Make an authenticated request to keystone endpoint.
Request are made to keystone endpoint by concatenating
self.management_url and url and passing in method and

View File

@@ -162,7 +162,7 @@ class Session(object):
@staticmethod
def _process_header(header):
"""Redacts the secure headers to be logged."""
"""Redact the secure headers to be logged."""
secure_headers = ('authorization', 'x-auth-token',
'x-subject-token',)
if header[0].lower() in secure_headers:
@@ -545,7 +545,7 @@ class Session(object):
@classmethod
def construct(cls, kwargs):
"""Handles constructing a session from both old and new arguments.
"""Handle constructing a session from both old and new arguments.
Support constructing a session from the old
:py:class:`~keystoneclient.httpclient.HTTPClient` args as well as the

View File

@@ -20,7 +20,7 @@ OPENSTACK_CLOUDS = ('functional_admin', 'devstack-admin', 'envvars')
def get_client(version):
"""Creates a keystoneclient instance to run functional tests
"""Create a keystoneclient instance to run functional tests
The client is instantiated via os-client-config either based on a
clouds.yaml config file or from the environment variables.

View File

@@ -124,7 +124,7 @@ class ProjectTests(utils.ClientTestCase, utils.CrudTests):
self.assertEntityRequestBodyIs(ref)
def _create_projects_hierarchy(self, hierarchy_size=3):
"""Creates a project hierarchy with specified size.
"""Create a project hierarchy with specified size.
:param hierarchy_size: the desired hierarchy size, default is 3.

View File

@@ -20,7 +20,7 @@ from keystoneclient.tests.unit import utils
def parameterize(ref):
"""Rewrites attributes to match the kwarg naming convention in client.
"""Rewrite attributes to match the kwarg naming convention in client.
>>> parameterize({'project_id': 0})
{'project': 0}

View File

@@ -54,7 +54,7 @@ def find_resource(manager, name_or_id):
def unauthenticated(f):
"""Adds 'unauthenticated' attribute to decorated function.
"""Add 'unauthenticated' attribute to decorated function.
Usage::

View File

@@ -56,7 +56,7 @@ class RoleManager(base.ManagerWithFind):
return self._list("/users/%s/roles" % user_id, "roles")
def add_user_role(self, user, role, tenant=None):
"""Adds a role to a user.
"""Add a role to a user.
If tenant is specified, the role is added just for that tenant,
otherwise the role is added globally.
@@ -72,7 +72,7 @@ class RoleManager(base.ManagerWithFind):
return self._update(route % (user_id, role_id), None, "roles")
def remove_user_role(self, user, role, tenant=None):
"""Removes a role from a user.
"""Remove a role from a user.
If tenant is specified, the role is removed just for that tenant,
otherwise the role is removed from the user's global roles.

View File

@@ -117,7 +117,7 @@ class TokenManager(base.Manager):
return access.AccessInfo.factory(auth_token=token_id, body=body)
def get_revoked(self):
"""Returns the revoked tokens response.
"""Return the revoked tokens response.
The response will be a dict containing 'signed' which is a CMS-encoded
document.

View File

@@ -58,7 +58,7 @@ class EndpointFilterManager(base.Manager):
return super(EndpointFilterManager, self)._delete(url=base_url)
def check_endpoint_in_project(self, project, endpoint):
"""Checks if project-endpoint association exist."""
"""Check if project-endpoint association exist."""
if not (project and endpoint):
raise ValueError(_('project and endpoint are required'))

View File

@@ -49,7 +49,7 @@ class RoleAssignmentManager(base.CrudManager):
def list(self, user=None, group=None, project=None, domain=None, role=None,
effective=False, os_inherit_extension_inherited_to=None,
include_subtree=False, include_names=False):
"""Lists role assignments.
"""List role assignments.
If no arguments are provided, all role assignments in the
system will be listed.

View File

@@ -137,7 +137,7 @@ class RoleManager(base.CrudManager):
@positional(enforcement=positional.WARN)
def list(self, user=None, group=None, domain=None,
project=None, os_inherit_extension_inherited=False, **kwargs):
"""Lists roles and role grants.
"""List roles and role grants.
If no arguments are provided, all roles in the system will be
listed.
@@ -179,7 +179,7 @@ class RoleManager(base.CrudManager):
@positional(enforcement=positional.WARN)
def grant(self, role, user=None, group=None, domain=None, project=None,
os_inherit_extension_inherited=False, **kwargs):
"""Grants a role to a user or group on a domain or project.
"""Grant a role to a user or group on a domain or project.
If 'os_inherit_extension_inherited' is passed, then OS-INHERIT will be
used. It provides the ability for projects to inherit role assignments
@@ -200,7 +200,7 @@ class RoleManager(base.CrudManager):
@positional(enforcement=positional.WARN)
def check(self, role, user=None, group=None, domain=None, project=None,
os_inherit_extension_inherited=False, **kwargs):
"""Checks if a user or group has a role on a domain or project.
"""Check if a user or group has a role on a domain or project.
If 'os_inherit_extension_inherited' is passed, then OS-INHERIT will be
used. It provides the ability for projects to inherit role assignments
@@ -223,7 +223,7 @@ class RoleManager(base.CrudManager):
@positional(enforcement=positional.WARN)
def revoke(self, role, user=None, group=None, domain=None, project=None,
os_inherit_extension_inherited=False, **kwargs):
"""Revokes a role from a user or group on a domain or project.
"""Revoke a role from a user or group on a domain or project.
If 'os_inherit_extension_inherited' is passed, then OS-INHERIT will be
used. It provides the ability for projects to inherit role assignments

View File

@@ -56,8 +56,7 @@ passenv = OS_*
# D211: No blank lines allowed before class docstring
# D301: Use r”“” if any backslashes in a docstring
# D400: First line should end with a period.
# D401: First line should be in imperative mood.
ignore = D100,D101,D102,D103,D104,D105,D200,D202,D203,D204,D205,D207,D208,D211,D301,D400,D401
ignore = D100,D101,D102,D103,D104,D105,D200,D202,D203,D204,D205,D207,D208,D211,D301,D400
show-source = True
exclude = .venv,.tox,dist,doc,*egg,build,*openstack/common*