Raise hacking to latest 2.0.0 release
We were capped at a very old version of hacking. Hacking itself caps the various linters it uses to remain consistent, so our pep8 job was not checking quite a bit that current versions have added. This raises that limit to the latest to get up to the level of other projects and addresses the errors the updated linters uncovered. Change-Id: I89a9d73fbd59606a649e26077acebc5c42873d67 Co-authored-by: Sean McGinnis <sean.mcginnis@gmail.com>
This commit is contained in:
parent
2d80135f9b
commit
595c1b17ff
@ -242,7 +242,7 @@ def upload_data_to_store(req, image_meta, image_data, store, notifier):
|
||||
request=req,
|
||||
content_type='text/plain')
|
||||
|
||||
except exception.ImageSizeLimitExceeded as e:
|
||||
except exception.ImageSizeLimitExceeded:
|
||||
msg = (_("Denying attempt to upload image larger than %d bytes.")
|
||||
% CONF.image_size_cap)
|
||||
LOG.warn(msg)
|
||||
@ -273,7 +273,7 @@ def upload_data_to_store(req, image_meta, image_data, store, notifier):
|
||||
LOG.exception(msg)
|
||||
safe_kill(req, image_id, 'saving')
|
||||
|
||||
except (ValueError, IOError) as e:
|
||||
except (ValueError, IOError):
|
||||
msg = _("Client disconnected before sending all data to backend")
|
||||
LOG.warn(msg)
|
||||
safe_kill(req, image_id, 'saving')
|
||||
@ -281,7 +281,7 @@ def upload_data_to_store(req, image_meta, image_data, store, notifier):
|
||||
content_type="text/plain",
|
||||
request=req)
|
||||
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
msg = _("Failed to upload image %s") % image_id
|
||||
LOG.exception(msg)
|
||||
safe_kill(req, image_id, 'saving')
|
||||
|
@ -234,7 +234,7 @@ class ImageDataController(object):
|
||||
LOG.exception(msg)
|
||||
raise webob.exc.HTTPConflict(explanation=e.msg, request=req)
|
||||
|
||||
except exception.Forbidden as e:
|
||||
except exception.Forbidden:
|
||||
msg = ("Not allowed to upload image data for image %s" %
|
||||
image_id)
|
||||
LOG.debug(msg)
|
||||
@ -283,16 +283,16 @@ class ImageDataController(object):
|
||||
self._delete(image_repo, image)
|
||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
except webob.exc.HTTPGone as e:
|
||||
except webob.exc.HTTPGone:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.error(_LE("Failed to upload image data due to HTTP error"))
|
||||
|
||||
except webob.exc.HTTPError as e:
|
||||
except webob.exc.HTTPError:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.error(_LE("Failed to upload image data due to HTTP error"))
|
||||
self._restore(image_repo, image)
|
||||
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.error(_LE("Failed to upload image data due to "
|
||||
"internal error"))
|
||||
@ -346,7 +346,7 @@ class ImageDataController(object):
|
||||
staging_store.add(
|
||||
image_id, utils.LimitingReader(
|
||||
utils.CooperativeReader(data), CONF.image_size_cap), 0)
|
||||
except glance_store.Duplicate as e:
|
||||
except glance_store.Duplicate:
|
||||
msg = _("The image %s has data on staging") % image_id
|
||||
raise webob.exc.HTTPConflict(explanation=msg)
|
||||
|
||||
@ -390,7 +390,7 @@ class ImageDataController(object):
|
||||
LOG.debug(msg)
|
||||
raise webob.exc.HTTPConflict(explanation=e.msg, request=req)
|
||||
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.exception(_LE("Failed to stage image data due to "
|
||||
"internal error"))
|
||||
|
@ -182,12 +182,10 @@ class ImagesController(object):
|
||||
'backend': stores}
|
||||
|
||||
if (import_method == 'web-download' and
|
||||
not utils.validate_import_uri(uri)):
|
||||
LOG.debug("URI for web-download does not pass filtering: %s",
|
||||
uri)
|
||||
msg = (_("URI for web-download does not pass filtering: %s") %
|
||||
uri)
|
||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
not utils.validate_import_uri(uri)):
|
||||
LOG.debug("URI for web-download does not pass filtering: %s", uri)
|
||||
msg = (_("URI for web-download does not pass filtering: %s") % uri)
|
||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
try:
|
||||
import_task = task_factory.new_task(task_type='api_image_import',
|
||||
@ -506,7 +504,7 @@ class ImagesController(object):
|
||||
except (glance_store.Forbidden, exception.Forbidden) as e:
|
||||
LOG.debug("User not permitted to delete image '%s'", image_id)
|
||||
raise webob.exc.HTTPForbidden(explanation=e.msg)
|
||||
except (glance_store.NotFound, exception.NotFound) as e:
|
||||
except (glance_store.NotFound, exception.NotFound):
|
||||
msg = (_("Failed to find image %(image_id)s to delete") %
|
||||
{'image_id': image_id})
|
||||
LOG.warn(msg)
|
||||
@ -1176,8 +1174,8 @@ class ResponseSerializer(wsgi.JSONResponseSerializer):
|
||||
locations = _get_image_locations(image)
|
||||
if locations:
|
||||
# Choose best location configured strategy
|
||||
l = location_strategy.choose_best_location(locations)
|
||||
image_view['direct_url'] = l['url']
|
||||
loc = location_strategy.choose_best_location(locations)
|
||||
image_view['direct_url'] = loc['url']
|
||||
else:
|
||||
LOG.debug("The 'locations' list of image %s is empty, "
|
||||
"not including 'direct_url' in response",
|
||||
|
@ -128,7 +128,7 @@ class ResourceTypeController(object):
|
||||
LOG.debug("User not permitted to delete metadata resource type "
|
||||
"'%s' within '%s' namespace", resource_type, namespace)
|
||||
raise webob.exc.HTTPForbidden(explanation=e.msg)
|
||||
except exception.NotFound as e:
|
||||
except exception.NotFound:
|
||||
msg = (_("Failed to find resource type %(resourcetype)s to "
|
||||
"delete") % {'resourcetype': resource_type})
|
||||
LOG.error(msg)
|
||||
|
@ -524,5 +524,6 @@ def main():
|
||||
except (RuntimeError, NotImplementedError) as e:
|
||||
sys.exit("ERROR: %s" % e)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -757,7 +757,7 @@ def main():
|
||||
config.parse_args()
|
||||
except RuntimeError as e:
|
||||
sys.exit("ERROR: %s" % encodeutils.exception_to_unicode(e))
|
||||
except SystemExit as e:
|
||||
except SystemExit:
|
||||
sys.exit("Please specify one command")
|
||||
|
||||
# Setup logging
|
||||
|
@ -136,7 +136,7 @@ class SwiftParams(object):
|
||||
reference['user'] = CONFIG.get(ref, 'user')
|
||||
reference['key'] = CONFIG.get(ref, 'key')
|
||||
account_params[ref] = reference
|
||||
except (ValueError, SyntaxError, configparser.NoOptionError) as e:
|
||||
except (ValueError, SyntaxError, configparser.NoOptionError):
|
||||
LOG.exception(_LE("Invalid format of swift store config "
|
||||
"cfg"))
|
||||
return account_params
|
||||
|
@ -76,6 +76,7 @@ def iso8601_from_timestamp(timestamp, microsecond=False):
|
||||
"""Returns an iso8601 formatted date from timestamp."""
|
||||
return isotime(datetime.datetime.utcfromtimestamp(timestamp), microsecond)
|
||||
|
||||
|
||||
utcnow.override_time = None
|
||||
|
||||
|
||||
|
@ -970,7 +970,7 @@ class APIMapper(routes.Mapper):
|
||||
"""
|
||||
|
||||
def routematch(self, url=None, environ=None):
|
||||
if url is "":
|
||||
if url == "":
|
||||
result = self._match("", environ)
|
||||
return result[0], result[1]
|
||||
return routes.Mapper.routematch(self, url, environ)
|
||||
|
@ -19,6 +19,7 @@ import osprofiler.initializer
|
||||
|
||||
from glance.common import config
|
||||
from glance.common import store_utils
|
||||
from glance.i18n import _
|
||||
from glance import notifier
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
@ -1056,8 +1056,11 @@ def _sort_tasks(tasks, sort_key, sort_dir):
|
||||
reverse = False
|
||||
if tasks and not (sort_key in tasks[0]):
|
||||
raise exception.InvalidSortKey()
|
||||
keyfn = lambda x: (x[sort_key] if x[sort_key] is not None else '',
|
||||
x['created_at'], x['id'])
|
||||
|
||||
def keyfn(x):
|
||||
return (x[sort_key] if x[sort_key] is not None else '',
|
||||
x['created_at'], x['id'])
|
||||
|
||||
reverse = sort_dir == 'desc'
|
||||
tasks.sort(key=keyfn, reverse=reverse)
|
||||
return tasks
|
||||
|
@ -82,6 +82,7 @@ def run_migrations_online():
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
if context.is_offline_mode():
|
||||
run_migrations_offline()
|
||||
else:
|
||||
|
@ -182,7 +182,7 @@ def _get_all_by_resource_types(context, session, filters, marker=None,
|
||||
for name, namespace_id in db_recs:
|
||||
namespace_id_list.append(namespace_id)
|
||||
|
||||
if len(namespace_id_list) is 0:
|
||||
if len(namespace_id_list) == 0:
|
||||
return []
|
||||
|
||||
filters2 = filters
|
||||
|
@ -26,32 +26,40 @@ from glance.i18n import _LI
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
String = lambda length: sqlalchemy.types.String(
|
||||
length=length, convert_unicode=False,
|
||||
unicode_error=None, _warn_on_bytestring=False)
|
||||
def String(length):
|
||||
return sqlalchemy.types.String(
|
||||
length=length, convert_unicode=False,
|
||||
unicode_error=None, _warn_on_bytestring=False)
|
||||
|
||||
|
||||
Text = lambda: sqlalchemy.types.Text(
|
||||
length=None, convert_unicode=False,
|
||||
unicode_error=None, _warn_on_bytestring=False)
|
||||
def Text():
|
||||
return sqlalchemy.types.Text(
|
||||
length=None, convert_unicode=False,
|
||||
unicode_error=None, _warn_on_bytestring=False)
|
||||
|
||||
|
||||
Boolean = lambda: sqlalchemy.types.Boolean(create_constraint=True, name=None)
|
||||
def Boolean():
|
||||
return sqlalchemy.types.Boolean(create_constraint=True, name=None)
|
||||
|
||||
|
||||
DateTime = lambda: sqlalchemy.types.DateTime(timezone=False)
|
||||
def DateTime():
|
||||
return sqlalchemy.types.DateTime(timezone=False)
|
||||
|
||||
|
||||
Integer = lambda: sqlalchemy.types.Integer()
|
||||
def Integer():
|
||||
return sqlalchemy.types.Integer()
|
||||
|
||||
|
||||
BigInteger = lambda: sqlalchemy.types.BigInteger()
|
||||
def BigInteger():
|
||||
return sqlalchemy.types.BigInteger()
|
||||
|
||||
|
||||
PickleType = lambda: sqlalchemy.types.PickleType()
|
||||
def PickleType():
|
||||
return sqlalchemy.types.PickleType()
|
||||
|
||||
|
||||
Numeric = lambda: sqlalchemy.types.Numeric()
|
||||
def Numeric():
|
||||
return sqlalchemy.types.Numeric()
|
||||
|
||||
|
||||
def from_migration_import(module_name, fromlist):
|
||||
|
@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from sqlalchemy import * # noqa
|
||||
from sqlalchemy import Column, MetaData, Table, and_, select
|
||||
|
||||
from glance.db.sqlalchemy.migrate_repo.schema import (
|
||||
Boolean, DateTime, Integer, String, Text, from_migration_import) # noqa
|
||||
|
@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from sqlalchemy import * # noqa
|
||||
from sqlalchemy import Column, MetaData, Table
|
||||
|
||||
from glance.db.sqlalchemy.migrate_repo.schema import (
|
||||
Boolean, DateTime, Integer, String, Text, from_migration_import) # noqa
|
||||
|
@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from sqlalchemy import * # noqa
|
||||
from sqlalchemy import Column, MetaData, Table
|
||||
|
||||
from glance.db.sqlalchemy.migrate_repo.schema import (
|
||||
Boolean, DateTime, BigInteger, Integer, String,
|
||||
|
@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from sqlalchemy import * # noqa
|
||||
from sqlalchemy import Index, MetaData
|
||||
|
||||
from glance.db.sqlalchemy.migrate_repo.schema import from_migration_import
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from sqlalchemy import * # noqa
|
||||
from sqlalchemy import Column, MetaData, Table
|
||||
|
||||
from glance.db.sqlalchemy.migrate_repo.schema import (
|
||||
Boolean, DateTime, BigInteger, Integer, String,
|
||||
|
@ -13,7 +13,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from sqlalchemy import * # noqa
|
||||
from sqlalchemy import Column, ForeignKey, Index, MetaData, Table
|
||||
from sqlalchemy import UniqueConstraint
|
||||
|
||||
from glance.db.sqlalchemy.migrate_repo.schema import (
|
||||
Boolean, DateTime, Integer, String, create_tables,
|
||||
|
@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from sqlalchemy import * # noqa
|
||||
from sqlalchemy import Column, MetaData, Table
|
||||
|
||||
from glance.db.sqlalchemy.migrate_repo.schema import (
|
||||
Boolean, DateTime, Integer, String, Text) # noqa
|
||||
|
@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from sqlalchemy import * # noqa
|
||||
from sqlalchemy import MetaData
|
||||
|
||||
from glance.db.sqlalchemy.migrate_repo.schema import from_migration_import
|
||||
|
||||
|
@ -13,14 +13,28 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_i18n import * # noqa
|
||||
import oslo_i18n as i18n
|
||||
|
||||
_translators = TranslatorFactory(domain='glance')
|
||||
DOMAIN = 'glance'
|
||||
|
||||
_translators = i18n.TranslatorFactory(domain=DOMAIN)
|
||||
|
||||
# The primary translation function using the well-known name "_"
|
||||
_ = _translators.primary
|
||||
|
||||
|
||||
def enable_lazy(enable=True):
|
||||
return i18n.enable_lazy(enable)
|
||||
|
||||
|
||||
def translate(value, user_locale=None):
|
||||
return i18n.translate(value, user_locale)
|
||||
|
||||
|
||||
def get_available_languages(domain=DOMAIN):
|
||||
return i18n.get_available_languages(domain)
|
||||
|
||||
|
||||
# i18n log translation functions are deprecated. While removing the invocations
|
||||
# requires a lot of reviewing effort, we decide to make it as no-op functions.
|
||||
def _LI(msg):
|
||||
|
@ -1383,7 +1383,9 @@ class DriverTests(object):
|
||||
return
|
||||
|
||||
def _assertMemberListMatch(list1, list2):
|
||||
_simple = lambda x: set([(o['member'], o['image_id']) for o in x])
|
||||
def _simple(x):
|
||||
return set([(o['member'], o['image_id']) for o in x])
|
||||
|
||||
self.assertEqual(_simple(list1), _simple(list2))
|
||||
|
||||
# NOTE(flaper87): Update auth token, otherwise
|
||||
|
@ -122,7 +122,7 @@ class ResourceTypeController(object):
|
||||
raise exception.NotFound()
|
||||
except exception.Forbidden as e:
|
||||
raise webob.exc.HTTPForbidden(explanation=e.msg)
|
||||
except exception.NotFound as e:
|
||||
except exception.NotFound:
|
||||
msg = (_("Failed to find resource type %(resourcetype)s to "
|
||||
"delete") % {'resourcetype': resource_type})
|
||||
LOG.error(msg)
|
||||
|
@ -394,9 +394,9 @@ class ResourceTest(test_utils.BaseTestCase):
|
||||
|
||||
def test_response_headers_encoded(self):
|
||||
# prepare environment
|
||||
for_openstack_comrades = \
|
||||
u'\u0417\u0430 \u043e\u043f\u0435\u043d\u0441\u0442\u0435\u043a, ' \
|
||||
u'\u0442\u043e\u0432\u0430\u0440\u0438\u0449\u0438'
|
||||
for_openstack_comrades = (
|
||||
u'\u0417\u0430 \u043e\u043f\u0435\u043d\u0441\u0442\u0435\u043a, '
|
||||
u'\u0442\u043e\u0432\u0430\u0440\u0438\u0449\u0438')
|
||||
|
||||
class FakeController(object):
|
||||
def index(self, shirt, pants=None):
|
||||
|
@ -61,6 +61,7 @@ class TestDbUtilities(test_utils.BaseTestCase):
|
||||
import_module.assert_called_once_with('glance.db.sqlalchemy.api')
|
||||
api.configure.assert_called_once_with()
|
||||
|
||||
|
||||
UUID1 = 'c80a1a6c-bd1f-41c5-90ee-81afedb1d58d'
|
||||
UUID2 = 'a85abd86-55b3-4d5b-b0b4-5d0a6e6042fc'
|
||||
UUID3 = '971ec09a-8067-4bc8-a91f-ae3557f1c4c7'
|
||||
|
@ -178,12 +178,11 @@ class ImagePager(object):
|
||||
page_size = image_count
|
||||
self.image_batches = []
|
||||
start = 0
|
||||
l = len(images)
|
||||
while start < l:
|
||||
while start < image_count:
|
||||
self.image_batches.append(images[start: start + page_size])
|
||||
start += page_size
|
||||
if (l - start) < page_size:
|
||||
page_size = l - start
|
||||
if (image_count - start) < page_size:
|
||||
page_size = image_count - start
|
||||
|
||||
def __call__(self):
|
||||
if len(self.image_batches) == 0:
|
||||
|
@ -65,7 +65,7 @@ def sort_url_by_qs_keys(url):
|
||||
def get_fake_request(path='', method='POST', is_admin=False, user=USER1,
|
||||
roles=None, tenant=TENANT1):
|
||||
if roles is None:
|
||||
roles = ['member']
|
||||
roles = ['member']
|
||||
|
||||
req = wsgi.Request.blank(path)
|
||||
req.method = method
|
||||
|
@ -84,6 +84,7 @@ def _domain_fixture(task_id, **kwargs):
|
||||
task = glance.domain.Task(**task_properties)
|
||||
return task
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('task_time_to_live', 'glance.common.config', group='task')
|
||||
|
||||
|
@ -36,7 +36,7 @@ gitdb2==2.0.3
|
||||
GitPython==2.1.8
|
||||
glance-store==1.0.0
|
||||
greenlet==0.4.13
|
||||
hacking==0.12.0
|
||||
hacking==2.0.0
|
||||
httplib2==0.9.1
|
||||
idna==2.6
|
||||
imagesize==1.0.0
|
||||
|
@ -3,7 +3,7 @@
|
||||
# process, which may cause wedges in the gate later.
|
||||
|
||||
# Hacking already pins down pep8, pyflakes and flake8
|
||||
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
|
||||
hacking>=2.0.0 # Apache-2.0
|
||||
|
||||
# For translations processing
|
||||
Babel!=2.4.0,>=2.3.4 # BSD
|
||||
|
5
tox.ini
5
tox.ini
@ -121,11 +121,14 @@ ignore-path = .venv,.git,.tox,*glance/locale*,*lib/python*,glance.egg*,api-ref/b
|
||||
|
||||
[flake8]
|
||||
# TODO(dmllr): Analyze or fix the warnings blacklisted below
|
||||
# E402 module level import not at top of file
|
||||
# E711 comparison to None should be 'if cond is not None:'
|
||||
# E712 comparison to True should be 'if cond is True:' or 'if cond:'
|
||||
# H404 multi line docstring should start with a summary
|
||||
# H405 multi line docstring summary not separated with an empty line
|
||||
ignore = E711,E712,H404,H405
|
||||
# W503 line break before binary operator - conflicting guidance
|
||||
# W504 line break after binary operator - conflicting guidance
|
||||
ignore = E402,E711,E712,H404,H405,W503,W504
|
||||
exclude = .venv,.git,.tox,dist,doc,etc,*glance/locale*,*lib/python*,*egg,build
|
||||
|
||||
[hacking]
|
||||
|
Loading…
Reference in New Issue
Block a user