Fixing D202 and D203 PEP257 violation.
Currently tox ignores D202 and D203. D202: No blank lines allowed after function docstring. D203: 1 blank required before class docstring. This change removes D202 and D203 ignores in tox and fix violations. Change-Id: I97ef88c9cfd56774e47f789cbbcf8ccfe85d7737
This commit is contained in:
parent
a9adca02db
commit
bca112c8ba
|
@ -75,7 +75,6 @@ def get_version_data(session, url, authenticated=None):
|
|||
|
||||
def normalize_version_number(version):
|
||||
"""Turn a version representation into a tuple."""
|
||||
|
||||
# trim the v from a 'v2.0' or similar
|
||||
try:
|
||||
version = version.lstrip('v')
|
||||
|
|
|
@ -49,7 +49,6 @@ class AccessInfo(dict):
|
|||
release and may be removed in the 2.0.0 release.
|
||||
|
||||
"""
|
||||
|
||||
if region_name:
|
||||
warnings.warn(
|
||||
'Use of the region_name argument is deprecated as of the '
|
||||
|
|
|
@ -276,7 +276,6 @@ class BaseAuthPlugin(object):
|
|||
:param parser: the parser to attach argparse options.
|
||||
:type parser: argparse.ArgumentParser
|
||||
"""
|
||||
|
||||
# NOTE(jamielennox): ideally oslo_config would be smart enough to
|
||||
# handle all the Opt manipulation that goes on in this file. However it
|
||||
# is currently not. Options are handled in as similar a way as
|
||||
|
@ -313,7 +312,6 @@ class BaseAuthPlugin(object):
|
|||
:returns: An auth plugin, or None if a name is not provided.
|
||||
:rtype: :py:class:`keystoneclient.auth.BaseAuthPlugin`
|
||||
"""
|
||||
|
||||
def _getter(opt):
|
||||
return getattr(namespace, 'os_%s' % opt.dest)
|
||||
|
||||
|
@ -343,7 +341,6 @@ class BaseAuthPlugin(object):
|
|||
:returns: An authentication Plugin.
|
||||
:rtype: :py:class:`keystoneclient.auth.BaseAuthPlugin`
|
||||
"""
|
||||
|
||||
def _getter(opt):
|
||||
return conf[group][opt.dest]
|
||||
|
||||
|
@ -366,7 +363,6 @@ class BaseAuthPlugin(object):
|
|||
:returns: An authentication Plugin.
|
||||
:rtype: :py:class:`keystoneclient.auth.BaseAuthPlugin`
|
||||
"""
|
||||
|
||||
plugin_opts = cls.get_options()
|
||||
|
||||
for opt in plugin_opts:
|
||||
|
|
|
@ -73,7 +73,6 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
|
|||
|
||||
It may be removed in the 2.0.0 release.
|
||||
"""
|
||||
|
||||
warnings.warn(
|
||||
'username is deprecated as of the 1.7.0 release and may be '
|
||||
'removed in the 2.0.0 release.', DeprecationWarning)
|
||||
|
@ -86,7 +85,6 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
|
|||
|
||||
It may be removed in the 2.0.0 release.
|
||||
"""
|
||||
|
||||
warnings.warn(
|
||||
'username is deprecated as of the 1.7.0 release and may be '
|
||||
'removed in the 2.0.0 release.', DeprecationWarning)
|
||||
|
@ -99,7 +97,6 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
|
|||
|
||||
It may be removed in the 2.0.0 release.
|
||||
"""
|
||||
|
||||
warnings.warn(
|
||||
'password is deprecated as of the 1.7.0 release and may be '
|
||||
'removed in the 2.0.0 release.', DeprecationWarning)
|
||||
|
@ -112,7 +109,6 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
|
|||
|
||||
It may be removed in the 2.0.0 release.
|
||||
"""
|
||||
|
||||
warnings.warn(
|
||||
'password is deprecated as of the 1.7.0 release and may be '
|
||||
'removed in the 2.0.0 release.', DeprecationWarning)
|
||||
|
@ -125,7 +121,6 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
|
|||
|
||||
It may be removed in the 2.0.0 release.
|
||||
"""
|
||||
|
||||
warnings.warn(
|
||||
'token is deprecated as of the 1.7.0 release and may be '
|
||||
'removed in the 2.0.0 release.', DeprecationWarning)
|
||||
|
@ -138,7 +133,6 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
|
|||
|
||||
It may be removed in the 2.0.0 release.
|
||||
"""
|
||||
|
||||
warnings.warn(
|
||||
'token is deprecated as of the 1.7.0 release and may be '
|
||||
'removed in the 2.0.0 release.', DeprecationWarning)
|
||||
|
@ -151,7 +145,6 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
|
|||
|
||||
It may be removed in the 2.0.0 release.
|
||||
"""
|
||||
|
||||
warnings.warn(
|
||||
'trust_id is deprecated as of the 1.7.0 release and may be '
|
||||
'removed in the 2.0.0 release.', DeprecationWarning)
|
||||
|
@ -164,7 +157,6 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
|
|||
|
||||
It may be removed in the 2.0.0 release.
|
||||
"""
|
||||
|
||||
warnings.warn(
|
||||
'trust_id is deprecated as of the 1.7.0 release and may be '
|
||||
'removed in the 2.0.0 release.', DeprecationWarning)
|
||||
|
|
|
@ -101,7 +101,6 @@ def _check_files_accessible(files):
|
|||
|
||||
def _process_communicate_handle_oserror(process, data, files):
|
||||
"""Wrapper around process.communicate that checks for OSError."""
|
||||
|
||||
try:
|
||||
output, err = process.communicate(data)
|
||||
except OSError as e:
|
||||
|
|
|
@ -138,7 +138,6 @@ class OidcPassword(federated.FederatedBaseAuth):
|
|||
:returns: a token data representation
|
||||
:rtype: :py:class:`keystoneclient.access.AccessInfo`
|
||||
"""
|
||||
|
||||
# get an access token
|
||||
client_auth = (self.client_id, self.client_secret)
|
||||
payload = {'grant_type': self.grant_type, 'username': self.username,
|
||||
|
|
|
@ -293,7 +293,6 @@ class Saml2UnscopedToken(_BaseSAMLPlugin):
|
|||
|
||||
def _send_idp_saml2_authn_request(self, session):
|
||||
"""Present modified SAML2 authn assertion from the Service Provider."""
|
||||
|
||||
self._prepare_idp_saml2_request(self.saml2_authn_request)
|
||||
idp_saml2_authn_request = self.saml2_authn_request
|
||||
|
||||
|
@ -581,7 +580,6 @@ class ADFSUnscopedToken(_BaseSAMLPlugin):
|
|||
:type fmt: string
|
||||
|
||||
"""
|
||||
|
||||
date_created = datetime.datetime.utcnow()
|
||||
date_expires = date_created + datetime.timedelta(
|
||||
seconds=self.DEFAULT_ADFS_TOKEN_EXPIRATION)
|
||||
|
@ -593,7 +591,6 @@ class ADFSUnscopedToken(_BaseSAMLPlugin):
|
|||
Some values like username or password are inserted in the request.
|
||||
|
||||
"""
|
||||
|
||||
WSS_SECURITY_NAMESPACE = {
|
||||
'o': ('http://docs.oasis-open.org/wss/2004/01/oasis-200401-'
|
||||
'wss-wssecurity-secext-1.0.xsd')
|
||||
|
@ -905,7 +902,6 @@ class Saml2ScopedTokenMethod(v3.TokenMethod):
|
|||
|
||||
def get_auth_data(self, session, auth, headers, **kwargs):
|
||||
"""Build and return request body for token scoping step."""
|
||||
|
||||
t = super(Saml2ScopedTokenMethod, self).get_auth_data(
|
||||
session, auth, headers, **kwargs)
|
||||
_token_method, token = t
|
||||
|
|
|
@ -162,7 +162,6 @@ class Ec2Signer(object):
|
|||
def _calc_signature_4(self, params, verb, server_string, path, headers,
|
||||
body_hash):
|
||||
"""Generate AWS signature version 4 string."""
|
||||
|
||||
def sign(key, msg):
|
||||
return hmac.new(key, self._get_utf8_value(msg),
|
||||
hashlib.sha256).digest()
|
||||
|
|
|
@ -463,7 +463,6 @@ class HTTPClient(baseclient.Client, base.BaseAuthPlugin):
|
|||
This is deprecated as of the 1.7.0 release in favor of project_id
|
||||
and may be removed in the 2.0.0 release.
|
||||
"""
|
||||
|
||||
warnings.warn(
|
||||
'tenant_id is deprecated as of the 1.7.0 release in favor of '
|
||||
'project_id and may be removed in the 2.0.0 release.',
|
||||
|
@ -480,7 +479,6 @@ class HTTPClient(baseclient.Client, base.BaseAuthPlugin):
|
|||
This is deprecated as of the 1.7.0 release in favor of project_name
|
||||
and may be removed in the 2.0.0 release.
|
||||
"""
|
||||
|
||||
warnings.warn(
|
||||
'tenant_name is deprecated as of the 1.7.0 release in favor of '
|
||||
'project_name and may be removed in the 2.0.0 release.',
|
||||
|
|
|
@ -310,7 +310,6 @@ class Session(object):
|
|||
|
||||
:returns: The response to the request.
|
||||
"""
|
||||
|
||||
headers = kwargs.setdefault('headers', dict())
|
||||
|
||||
if authenticated is None:
|
||||
|
@ -563,12 +562,10 @@ class Session(object):
|
|||
functions without session arguments.
|
||||
|
||||
"""
|
||||
|
||||
warnings.warn(
|
||||
'Session.construct() is deprecated as of the 1.7.0 release in '
|
||||
'favor of using session constructor and may be removed in the '
|
||||
'2.0.0 release.', DeprecationWarning)
|
||||
|
||||
return cls._construct(kwargs)
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -180,7 +180,6 @@ class SessionTests(utils.TestCase):
|
|||
|
||||
def test_logs_failed_output(self):
|
||||
"""Test that output is logged even for failed requests."""
|
||||
|
||||
session = client_session.Session()
|
||||
body = uuid.uuid4().hex
|
||||
|
||||
|
@ -192,7 +191,6 @@ class SessionTests(utils.TestCase):
|
|||
|
||||
def test_unicode_data_in_debug_output(self):
|
||||
"""Verify that ascii-encodable data is logged without modification."""
|
||||
|
||||
session = client_session.Session(verify=False)
|
||||
|
||||
body = 'RESP'
|
||||
|
@ -204,7 +202,6 @@ class SessionTests(utils.TestCase):
|
|||
|
||||
def test_binary_data_not_in_debug_output(self):
|
||||
"""Verify that non-ascii-encodable data causes replacement."""
|
||||
|
||||
if six.PY2:
|
||||
data = "my data" + chr(255)
|
||||
else:
|
||||
|
|
|
@ -158,7 +158,6 @@ class DisableModuleFixture(fixtures.Fixture):
|
|||
|
||||
def setUp(self):
|
||||
"""Ensure ImportError for the specified module."""
|
||||
|
||||
super(DisableModuleFixture, self).setUp()
|
||||
|
||||
# Clear 'module' references in sys.modules
|
||||
|
|
|
@ -93,7 +93,6 @@ class AuthenticateOIDCTests(utils.TestCase):
|
|||
" argument 'project_name'")
|
||||
def test_conf_params(self):
|
||||
"""Ensure OpenID Connect config options work."""
|
||||
|
||||
section = uuid.uuid4().hex
|
||||
identity_provider = uuid.uuid4().hex
|
||||
protocol = uuid.uuid4().hex
|
||||
|
@ -129,7 +128,6 @@ class AuthenticateOIDCTests(utils.TestCase):
|
|||
|
||||
def test_initial_call_to_get_access_token(self):
|
||||
"""Test initial call, expect JSON access token."""
|
||||
|
||||
# Mock the output that creates the access token
|
||||
self.requests_mock.post(
|
||||
self.ACCESS_TOKEN_ENDPOINT,
|
||||
|
@ -154,7 +152,6 @@ class AuthenticateOIDCTests(utils.TestCase):
|
|||
|
||||
def test_second_call_to_protected_url(self):
|
||||
"""Test subsequent call, expect Keystone token."""
|
||||
|
||||
# Mock the output that creates the keystone token
|
||||
self.requests_mock.post(
|
||||
self.FEDERATION_AUTH_URL,
|
||||
|
@ -176,7 +173,6 @@ class AuthenticateOIDCTests(utils.TestCase):
|
|||
|
||||
def test_end_to_end_workflow(self):
|
||||
"""Test full OpenID Connect workflow."""
|
||||
|
||||
# Mock the output that creates the access token
|
||||
self.requests_mock.post(
|
||||
self.ACCESS_TOKEN_ENDPOINT,
|
||||
|
|
|
@ -493,7 +493,6 @@ class AuthenticateviaADFSTests(utils.TestCase):
|
|||
|
||||
def test_get_adfs_security_token(self):
|
||||
"""Test ADFSUnscopedToken._get_adfs_security_token()."""
|
||||
|
||||
self.requests_mock.post(
|
||||
self.IDENTITY_PROVIDER_URL,
|
||||
content=make_oneline(self.ADFS_SECURITY_TOKEN_RESPONSE),
|
||||
|
@ -672,7 +671,6 @@ class SAMLGenerationTests(utils.ClientTestCase):
|
|||
|
||||
def test_saml_create(self):
|
||||
"""Test that a token can be exchanged for a SAML assertion."""
|
||||
|
||||
token_id = uuid.uuid4().hex
|
||||
service_provider_id = uuid.uuid4().hex
|
||||
|
||||
|
@ -695,7 +693,6 @@ class SAMLGenerationTests(utils.ClientTestCase):
|
|||
|
||||
def test_ecp_create(self):
|
||||
"""Test that a token can be exchanged for an ECP wrapped assertion."""
|
||||
|
||||
token_id = uuid.uuid4().hex
|
||||
service_provider_id = uuid.uuid4().hex
|
||||
|
||||
|
|
|
@ -98,7 +98,6 @@ class TokenTests(object):
|
|||
Assert that the data in the headers matches the data
|
||||
that is produced from oauthlib.
|
||||
"""
|
||||
|
||||
self.assertThat(auth_header, matchers.StartsWith('OAuth '))
|
||||
parameters = dict(
|
||||
oauth1.rfc5849.utils.parse_authorization_header(auth_header))
|
||||
|
|
|
@ -131,7 +131,6 @@ class ProjectTests(utils.ClientTestCase, utils.CrudTests):
|
|||
:returns: a list of the projects in the created hierarchy.
|
||||
|
||||
"""
|
||||
|
||||
ref = self.new_ref()
|
||||
project_id = ref['id']
|
||||
projects = [ref]
|
||||
|
|
|
@ -29,7 +29,6 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
def find_resource(manager, name_or_id):
|
||||
"""Helper for the _find_* methods."""
|
||||
|
||||
# first try the entity as a string
|
||||
try:
|
||||
return manager.get(name_or_id)
|
||||
|
@ -128,7 +127,6 @@ _ISO8601_TIME_FORMAT = '%Y-%m-%dT%H:%M:%S'
|
|||
|
||||
def isotime(at=None, subsecond=False):
|
||||
"""Stringify time in ISO 8601 format."""
|
||||
|
||||
# Python provides a similar instance method for datetime.datetime objects
|
||||
# called isoformat(). The format of the strings generated by isoformat()
|
||||
# have a couple of problems:
|
||||
|
@ -140,7 +138,6 @@ def isotime(at=None, subsecond=False):
|
|||
# the value happens to be 0. This will likely show up as random failures
|
||||
# as parsers may be written to always expect microseconds, and it will
|
||||
# parse correctly most of the time.
|
||||
|
||||
if not at:
|
||||
at = timeutils.utcnow()
|
||||
st = at.strftime(_ISO8601_TIME_FORMAT
|
||||
|
|
|
@ -25,7 +25,6 @@ class CertificatesManager(object):
|
|||
:rtype: str
|
||||
|
||||
"""
|
||||
|
||||
resp, body = self._client.get('/certificates/ca', authenticated=False)
|
||||
return resp.text
|
||||
|
||||
|
@ -36,7 +35,6 @@ class CertificatesManager(object):
|
|||
:rtype: str
|
||||
|
||||
"""
|
||||
|
||||
resp, body = self._client.get('/certificates/signing',
|
||||
authenticated=False)
|
||||
return resp.text
|
||||
|
|
|
@ -147,7 +147,6 @@ class Client(httpclient.HTTPClient):
|
|||
|
||||
def __init__(self, **kwargs):
|
||||
"""Initialize a new client for the Keystone v2.0 API."""
|
||||
|
||||
if not kwargs.get('session'):
|
||||
warnings.warn(
|
||||
'Constructing an instance of the '
|
||||
|
|
|
@ -32,7 +32,6 @@ class CredentialsManager(base.ManagerWithFind):
|
|||
|
||||
:rtype: object of type :class:`EC2`
|
||||
"""
|
||||
|
||||
params = {'tenant_id': tenant_id}
|
||||
|
||||
return self._post('/users/%s/credentials/OS-EC2' % user_id,
|
||||
|
|
|
@ -107,7 +107,6 @@ class TenantManager(base.ManagerWithFind):
|
|||
:rtype: list of :class:`Tenant`
|
||||
|
||||
"""
|
||||
|
||||
params = {}
|
||||
if limit:
|
||||
params['limit'] = limit
|
||||
|
|
|
@ -106,7 +106,6 @@ class TokenManager(base.Manager):
|
|||
:rtype: :py:class:`keystoneclient.access.AccessInfoV2`
|
||||
|
||||
"""
|
||||
|
||||
def calc_id(token):
|
||||
if isinstance(token, access.AccessInfo):
|
||||
return token.auth_token
|
||||
|
|
|
@ -113,7 +113,6 @@ class UserManager(base.ManagerWithFind):
|
|||
|
||||
:rtype: list of :class:`User`
|
||||
"""
|
||||
|
||||
params = {}
|
||||
if limit:
|
||||
params['limit'] = int(limit)
|
||||
|
|
|
@ -37,7 +37,6 @@ class ProtocolManager(base.CrudManager):
|
|||
|
||||
def build_url(self, dict_args_in_out=None):
|
||||
"""Build URL for federation protocols."""
|
||||
|
||||
if dict_args_in_out is None:
|
||||
dict_args_in_out = {}
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ class SamlManager(base.Manager):
|
|||
:returns: SAML representation of token_id
|
||||
:rtype: string
|
||||
"""
|
||||
|
||||
headers, body = self._create_common_request(service_provider, token_id)
|
||||
resp, body = self.client.post(SAML2_ENDPOINT, json=body,
|
||||
headers=headers)
|
||||
|
@ -54,7 +53,6 @@ class SamlManager(base.Manager):
|
|||
:returns: SAML representation of token_id, wrapped in ECP envelope
|
||||
:rtype: string
|
||||
"""
|
||||
|
||||
headers, body = self._create_common_request(service_provider, token_id)
|
||||
resp, body = self.client.post(ECP_ENDPOINT, json=body,
|
||||
headers=headers)
|
||||
|
|
|
@ -51,7 +51,6 @@ class RequestTokenManager(base.CrudManager):
|
|||
can be exchanged for an access token.
|
||||
:param roles: a list of roles, that will be delegated to the user.
|
||||
"""
|
||||
|
||||
request_id = urlparse.quote(base.getid(request_token))
|
||||
endpoint = utils.OAUTH_PATH + '/authorize/%s' % (request_id)
|
||||
body = {'roles': [{'id': base.getid(r_id)} for r_id in roles]}
|
||||
|
|
|
@ -25,7 +25,6 @@ def get_oauth_token_from_body(body):
|
|||
'oauth_token=12345&oauth_token_secret=67890' with
|
||||
'oauth_expires_at=2013-03-30T05:27:19.463201' possibly there, too.
|
||||
"""
|
||||
|
||||
if six.PY3:
|
||||
body = body.decode('utf-8')
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ class SimpleCertManager(object):
|
|||
:rtype: str
|
||||
|
||||
"""
|
||||
|
||||
resp, body = self._client.get('/OS-SIMPLE-CERT/ca',
|
||||
authenticated=False)
|
||||
return resp.text
|
||||
|
@ -37,7 +36,6 @@ class SimpleCertManager(object):
|
|||
:rtype: str
|
||||
|
||||
"""
|
||||
|
||||
resp, body = self._client.get('/OS-SIMPLE-CERT/certificates',
|
||||
authenticated=False)
|
||||
return resp.text
|
||||
|
|
|
@ -136,6 +136,5 @@ class CredentialManager(base.CrudManager):
|
|||
:type credential: :class:`Credential` or str
|
||||
|
||||
"""
|
||||
|
||||
return super(CredentialManager, self).delete(
|
||||
credential_id=base.getid(credential))
|
||||
|
|
|
@ -28,7 +28,6 @@ class EC2Manager(base.ManagerWithFind):
|
|||
|
||||
:rtype: object of type :class:`EC2`
|
||||
"""
|
||||
|
||||
# NOTE(jamielennox): Yes, this uses tenant_id as a key even though we
|
||||
# are in the v3 API.
|
||||
return self._post('/users/%s/credentials/OS-EC2' % user_id,
|
||||
|
|
|
@ -76,7 +76,6 @@ class ProjectManager(base.CrudManager):
|
|||
:param parent: the project's parent in the hierarchy. (optional)
|
||||
:type parent: :py:class:`keystoneclient.v3.projects.Project` or str
|
||||
"""
|
||||
|
||||
# NOTE(rodrigods): the API must be backwards compatible, so if an
|
||||
# application was passing a 'parent_id' before as kwargs, the call
|
||||
# should not fail. If both 'parent' and 'parent_id' are provided,
|
||||
|
|
|
@ -74,7 +74,6 @@ class RoleAssignmentManager(base.CrudManager):
|
|||
:param boolean include_names: Display names instead
|
||||
of IDs. (optional)
|
||||
"""
|
||||
|
||||
self._check_not_user_and_group(user, group)
|
||||
self._check_not_domain_and_project(domain, project)
|
||||
|
||||
|
|
|
@ -154,7 +154,6 @@ class RoleManager(base.CrudManager):
|
|||
used. It provides the ability for projects to inherit role assignments
|
||||
from their domains or from projects in the hierarchy.
|
||||
"""
|
||||
|
||||
if os_inherit_extension_inherited:
|
||||
kwargs['tail'] = '/inherited_to_projects'
|
||||
if user or group:
|
||||
|
|
|
@ -36,7 +36,6 @@ class TokenManager(object):
|
|||
:py:class:`keystoneclient.access.AccessInfo` or a string
|
||||
token_id.
|
||||
"""
|
||||
|
||||
token_id = _calc_id(token)
|
||||
headers = {'X-Subject-Token': token_id}
|
||||
return self._client.delete('/auth/tokens', headers=headers)
|
||||
|
@ -92,7 +91,6 @@ class TokenManager(object):
|
|||
:rtype: :py:class:`keystoneclient.access.AccessInfoV3`
|
||||
|
||||
"""
|
||||
|
||||
token_id = _calc_id(token)
|
||||
body = self.get_token_data(token_id, include_catalog=include_catalog)
|
||||
return access.AccessInfo.factory(auth_token=token_id, body=body)
|
||||
|
|
4
tox.ini
4
tox.ini
|
@ -47,9 +47,7 @@ passenv = OS_*
|
|||
# D104: Missing docstring in public package
|
||||
# D105: Missing docstring in magic method
|
||||
# D200: One-line docstring should fit on one line with quotes
|
||||
# D202: No blank lines allowed after function docstring
|
||||
# D203: 1 blank required before class docstring.
|
||||
ignore = D100,D101,D102,D103,D104,D105,D200,D202,D203
|
||||
ignore = D100,D101,D102,D103,D104,D105,D200
|
||||
show-source = True
|
||||
exclude = .venv,.tox,dist,doc,*egg,build,*openstack/common*
|
||||
|
||||
|
|
Loading…
Reference in New Issue