Enable hacking checks
Enabled following hacking checks from tox.ini: - H233 Python 3.x incompatible use of print operator - H303 no wildcard import - H404 multi line docstring should start with a summary Change-Id: I2553bcd3e80c00acc08d135a1d2dadfb6cda49fe Partial-Bugs: #1475054
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
# This is here for compatibility purposes. Once all known OpenStack clients
|
# This is here for compatibility purposes. Once all known OpenStack clients
|
||||||
# are updated to use glanceclient.exc, this file should be removed
|
# are updated to use glanceclient.exc, this file should be removed
|
||||||
from glanceclient.exc import *
|
from glanceclient.exc import * # noqa
|
||||||
|
@@ -52,7 +52,7 @@ from glanceclient import exc
|
|||||||
|
|
||||||
|
|
||||||
def verify_callback(host=None):
|
def verify_callback(host=None):
|
||||||
"""
|
"""Provide wrapper for do_verify_callback.
|
||||||
|
|
||||||
We use a partial around the 'real' verify_callback function
|
We use a partial around the 'real' verify_callback function
|
||||||
so that we can stash the host value without holding a
|
so that we can stash the host value without holding a
|
||||||
@@ -87,7 +87,7 @@ def do_verify_callback(connection, x509, errnum,
|
|||||||
|
|
||||||
|
|
||||||
def host_matches_cert(host, x509):
|
def host_matches_cert(host, x509):
|
||||||
"""
|
"""Verify the certificate identifies the host.
|
||||||
|
|
||||||
Verify that the x509 certificate we have received
|
Verify that the x509 certificate we have received
|
||||||
from 'host' correctly identifies the server we are
|
from 'host' correctly identifies the server we are
|
||||||
@@ -187,7 +187,7 @@ class HTTPSAdapter(adapters.HTTPAdapter):
|
|||||||
|
|
||||||
|
|
||||||
class HTTPSConnectionPool(connectionpool.HTTPSConnectionPool):
|
class HTTPSConnectionPool(connectionpool.HTTPSConnectionPool):
|
||||||
"""
|
"""A replacement for the default HTTPSConnectionPool.
|
||||||
|
|
||||||
HTTPSConnectionPool will be instantiated when a new
|
HTTPSConnectionPool will be instantiated when a new
|
||||||
connection is requested to the HTTPSAdapter. This
|
connection is requested to the HTTPSAdapter. This
|
||||||
@@ -232,10 +232,8 @@ class OpenSSLConnectionDelegator(object):
|
|||||||
|
|
||||||
|
|
||||||
class VerifiedHTTPSConnection(HTTPSConnection):
|
class VerifiedHTTPSConnection(HTTPSConnection):
|
||||||
"""
|
"""Extended OpenSSL HTTPSConnection for enhanced SSL support.
|
||||||
|
|
||||||
Extended HTTPSConnection which uses the OpenSSL library
|
|
||||||
for enhanced SSL support.
|
|
||||||
Note: Much of this functionality can eventually be replaced
|
Note: Much of this functionality can eventually be replaced
|
||||||
with native Python 3.3 code.
|
with native Python 3.3 code.
|
||||||
"""
|
"""
|
||||||
@@ -325,10 +323,9 @@ class VerifiedHTTPSConnection(HTTPSConnection):
|
|||||||
self.context.set_default_verify_paths()
|
self.context.set_default_verify_paths()
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
"""
|
"""Connect to an SSL port using the OpenSSL library.
|
||||||
|
|
||||||
Connect to an SSL port using the OpenSSL library
|
This method also applies per-connection parameters to the connection.
|
||||||
and apply per-connection parameters.
|
|
||||||
"""
|
"""
|
||||||
result = socket.getaddrinfo(self.host, self.port, 0,
|
result = socket.getaddrinfo(self.host, self.port, 0,
|
||||||
socket.SOCK_STREAM)
|
socket.SOCK_STREAM)
|
||||||
|
@@ -19,7 +19,7 @@ import six
|
|||||||
|
|
||||||
|
|
||||||
class _ProgressBarBase(object):
|
class _ProgressBarBase(object):
|
||||||
"""
|
"""A progress bar provider for a wrapped obect.
|
||||||
|
|
||||||
Base abstract class used by specific class wrapper to show
|
Base abstract class used by specific class wrapper to show
|
||||||
a progress bar when the wrapped object are consumed.
|
a progress bar when the wrapped object are consumed.
|
||||||
@@ -51,10 +51,10 @@ class _ProgressBarBase(object):
|
|||||||
|
|
||||||
|
|
||||||
class VerboseFileWrapper(_ProgressBarBase):
|
class VerboseFileWrapper(_ProgressBarBase):
|
||||||
"""
|
"""A file wrapper with a progress bar.
|
||||||
|
|
||||||
A file wrapper that show and advance a progress bar
|
The file wrapper shows and advances a progress bar whenever the
|
||||||
whenever file's read method is called.
|
wrapped file's read method is called.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def read(self, *args, **kwargs):
|
def read(self, *args, **kwargs):
|
||||||
@@ -70,10 +70,11 @@ class VerboseFileWrapper(_ProgressBarBase):
|
|||||||
|
|
||||||
|
|
||||||
class VerboseIteratorWrapper(_ProgressBarBase):
|
class VerboseIteratorWrapper(_ProgressBarBase):
|
||||||
"""
|
"""An iterator wrapper with a progress bar.
|
||||||
|
|
||||||
|
The iterator wrapper shows and advances a progress bar whenever the
|
||||||
|
wrapped data is consumed from the iterator.
|
||||||
|
|
||||||
An iterator wrapper that show and advance a progress bar whenever
|
|
||||||
data is consumed from the iterator.
|
|
||||||
:note: Use only with iterator that yield strings.
|
:note: Use only with iterator that yield strings.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@@ -160,7 +160,7 @@ class TestClient(testtools.TestCase):
|
|||||||
self.assertTrue('Accept-Language' not in headers)
|
self.assertTrue('Accept-Language' not in headers)
|
||||||
|
|
||||||
def test_connection_timeout(self):
|
def test_connection_timeout(self):
|
||||||
"""Should receive an InvalidEndpoint if connection timeout."""
|
"""Verify a InvalidEndpoint is received if connection times out."""
|
||||||
def cb(request, context):
|
def cb(request, context):
|
||||||
raise requests.exceptions.Timeout
|
raise requests.exceptions.Timeout
|
||||||
|
|
||||||
@@ -172,11 +172,9 @@ class TestClient(testtools.TestCase):
|
|||||||
self.assertIn(self.endpoint, comm_err.message)
|
self.assertIn(self.endpoint, comm_err.message)
|
||||||
|
|
||||||
def test_connection_refused(self):
|
def test_connection_refused(self):
|
||||||
"""
|
"""Verify a CommunicationError is received if connection is refused.
|
||||||
|
|
||||||
Should receive a CommunicationError if connection refused.
|
The error should list the host and port that refused the connection.
|
||||||
And the error should list the host and port that refused the
|
|
||||||
connection
|
|
||||||
"""
|
"""
|
||||||
def cb(request, context):
|
def cb(request, context):
|
||||||
raise requests.exceptions.ConnectionError()
|
raise requests.exceptions.ConnectionError()
|
||||||
|
@@ -440,11 +440,10 @@ class ShellInvalidEndpointandParameterTest(utils.TestCase):
|
|||||||
class ShellStdinHandlingTests(testtools.TestCase):
|
class ShellStdinHandlingTests(testtools.TestCase):
|
||||||
|
|
||||||
def _fake_update_func(self, *args, **kwargs):
|
def _fake_update_func(self, *args, **kwargs):
|
||||||
"""
|
"""Replace glanceclient.images.update with a fake.
|
||||||
|
|
||||||
Function to replace glanceclient.images.update,
|
To determine the parameters that would be supplied with the update
|
||||||
to determine the parameters that would be supplied with the update
|
request.
|
||||||
request
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Store passed in args
|
# Store passed in args
|
||||||
@@ -523,7 +522,7 @@ class ShellStdinHandlingTests(testtools.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_image_update_closed_stdin(self):
|
def test_image_update_closed_stdin(self):
|
||||||
"""
|
"""Test image update with a closed stdin.
|
||||||
|
|
||||||
Supply glanceclient with a closed stdin, and perform an image
|
Supply glanceclient with a closed stdin, and perform an image
|
||||||
update to an active image. Glanceclient should not attempt to read
|
update to an active image. Glanceclient should not attempt to read
|
||||||
@@ -542,7 +541,7 @@ class ShellStdinHandlingTests(testtools.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_image_update_opened_stdin(self):
|
def test_image_update_opened_stdin(self):
|
||||||
"""
|
"""Test image update with an opened stdin.
|
||||||
|
|
||||||
Supply glanceclient with a stdin, and perform an image
|
Supply glanceclient with a stdin, and perform an image
|
||||||
update to an active image. Glanceclient should not allow it.
|
update to an active image. Glanceclient should not allow it.
|
||||||
|
@@ -74,7 +74,7 @@ class FakeSchemaAPI(FakeAPI):
|
|||||||
class RawRequest(object):
|
class RawRequest(object):
|
||||||
def __init__(self, headers, body=None,
|
def __init__(self, headers, body=None,
|
||||||
version=1.0, status=200, reason="Ok"):
|
version=1.0, status=200, reason="Ok"):
|
||||||
"""
|
"""A crafted request object used for testing.
|
||||||
|
|
||||||
:param headers: dict representing HTTP response headers
|
:param headers: dict representing HTTP response headers
|
||||||
:param body: file-like object
|
:param body: file-like object
|
||||||
@@ -101,7 +101,7 @@ class RawRequest(object):
|
|||||||
class FakeResponse(object):
|
class FakeResponse(object):
|
||||||
def __init__(self, headers=None, body=None,
|
def __init__(self, headers=None, body=None,
|
||||||
version=1.0, status_code=200, reason="Ok"):
|
version=1.0, status_code=200, reason="Ok"):
|
||||||
"""
|
"""A crafted response object used for testing.
|
||||||
|
|
||||||
:param headers: dict representing HTTP response headers
|
:param headers: dict representing HTTP response headers
|
||||||
:param body: file-like object
|
:param body: file-like object
|
||||||
|
@@ -87,11 +87,10 @@ class Schema(object):
|
|||||||
self.properties = translate_schema_properties(raw_properties)
|
self.properties = translate_schema_properties(raw_properties)
|
||||||
|
|
||||||
def is_core_property(self, property_name):
|
def is_core_property(self, property_name):
|
||||||
"""
|
"""Check if a property with a given name is known to the schema.
|
||||||
|
|
||||||
Checks if a property with a given name is known to the schema,
|
Determines if it is either a base property or a custom one
|
||||||
i.e. is either a base property or a custom one registered in
|
registered in schema-image.json file
|
||||||
schema-image.json file
|
|
||||||
|
|
||||||
:param property_name: name of the property
|
:param property_name: name of the property
|
||||||
:returns: True if the property is known, False otherwise
|
:returns: True if the property is known, False otherwise
|
||||||
|
7
tox.ini
7
tox.ini
@@ -41,12 +41,7 @@ commands=
|
|||||||
commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
|
commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
# H233 Python 3.x incompatible use of print operator
|
ignore = F403,F812,F821
|
||||||
# H301 one import per line
|
|
||||||
# H303 no wildcard import
|
|
||||||
# H404 multi line docstring should start with a summary
|
|
||||||
|
|
||||||
ignore = F403,F812,F821,H233,H301,H303,H404
|
|
||||||
show-source = True
|
show-source = True
|
||||||
exclude = .venv*,.tox,dist,*egg,build,.git,doc,*openstack/common*,*lib/python*,.update-venv
|
exclude = .venv*,.tox,dist,*egg,build,.git,doc,*openstack/common*,*lib/python*,.update-venv
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user