Bump hacking min version to 3.1.0

This has introduced a new version of pycodestyle, which has improved its
parser to catch new corner cases and introduced some new tests.

Closes-Bug: #1878317
Change-Id: I853cf4dbd7ad6b7903a7f444f5c1da3f0fb21f77
This commit is contained in:
zhangbailin 2020-05-13 10:15:20 +08:00
parent 382d9b2336
commit 61b99a1295
17 changed files with 53 additions and 52 deletions

View File

@ -76,5 +76,5 @@ class ConsoleAuthTokensController(wsgi.Controller):
@wsgi.Controller.api_version("2.31") # noqa
@wsgi.expected_errors((400, 404))
def show(self, req, id):
def show(self, req, id): # noqa
return self._show(req, id, False)

View File

@ -210,13 +210,13 @@ class HypervisorsController(wsgi.Controller):
@wsgi.Controller.api_version("2.33", "2.52") # noqa
@validation.query_schema(hyper_schema.list_query_schema_v233)
@wsgi.expected_errors(400)
def index(self, req):
def index(self, req): # noqa
limit, marker = common.get_limit_and_marker(req)
return self._index(req, limit=limit, marker=marker, links=True)
@wsgi.Controller.api_version("2.1", "2.32") # noqa
@wsgi.expected_errors(())
def index(self, req):
def index(self, req): # noqa
return self._index(req)
def _index(self, req, limit=None, marker=None, links=False):
@ -242,13 +242,13 @@ class HypervisorsController(wsgi.Controller):
@wsgi.Controller.api_version("2.33", "2.52") # noqa
@validation.query_schema(hyper_schema.list_query_schema_v233)
@wsgi.expected_errors((400))
def detail(self, req):
def detail(self, req): # noqa
limit, marker = common.get_limit_and_marker(req)
return self._detail(req, limit=limit, marker=marker, links=True)
@wsgi.Controller.api_version("2.1", "2.32") # noqa
@wsgi.expected_errors(())
def detail(self, req):
def detail(self, req): # noqa
return self._detail(req)
def _detail(self, req, limit=None, marker=None, links=False):
@ -300,7 +300,7 @@ class HypervisorsController(wsgi.Controller):
@wsgi.Controller.api_version("2.1", "2.52") # noqa F811
@wsgi.expected_errors(404)
def show(self, req, id):
def show(self, req, id): # noqa
return self._show(req, id)
def _show(self, req, id, with_servers=False):

View File

@ -77,7 +77,7 @@ class InstanceActionsController(wsgi.Controller):
return common.get_instance(self.compute_api, context, server_id)
@wsgi.Controller.api_version("2.21") # noqa
def _get_instance(self, req, context, server_id):
def _get_instance(self, req, context, server_id): # noqa
with utils.temporary_mutation(context, read_deleted='yes'):
return common.get_instance(self.compute_api, context, server_id)
@ -100,7 +100,7 @@ class InstanceActionsController(wsgi.Controller):
"2.66")
@validation.query_schema(schema_instance_actions.list_query_params_v258,
"2.58", "2.65")
def index(self, req, server_id):
def index(self, req, server_id): # noqa
"""Returns the list of actions recorded for a given instance."""
context = req.environ["nova.context"]
instance = self._get_instance(req, context, server_id)

View File

@ -64,7 +64,7 @@ class KeypairController(wsgi.Controller):
@wsgi.response(201)
@wsgi.expected_errors((400, 403, 409))
@validation.schema(keypairs.create_v22)
def create(self, req, body):
def create(self, req, body): # noqa
"""Create or import keypair.
Sending name will generate a key and return private_key
@ -85,7 +85,7 @@ class KeypairController(wsgi.Controller):
@wsgi.expected_errors((400, 403, 409))
@validation.schema(keypairs.create_v20, "2.0", "2.0")
@validation.schema(keypairs.create, "2.1", "2.1")
def create(self, req, body):
def create(self, req, body): # noqa
"""Create or import keypair.
Sending name will generate a key and return private_key
@ -142,7 +142,7 @@ class KeypairController(wsgi.Controller):
@validation.query_schema(keypairs.delete_query_schema_v20)
@wsgi.response(204)
@wsgi.expected_errors(404)
def delete(self, req, id):
def delete(self, req, id): # noqa
self._delete(req, id)
@wsgi.Controller.api_version("2.10") # noqa
@ -150,7 +150,7 @@ class KeypairController(wsgi.Controller):
@validation.query_schema(keypairs.delete_query_schema_v210, '2.10', '2.74')
@wsgi.response(204)
@wsgi.expected_errors(404)
def delete(self, req, id):
def delete(self, req, id): # noqa
# handle optional user-id for admin only
user_id = self._get_user_id(req)
self._delete(req, id, user_id=user_id)
@ -184,13 +184,13 @@ class KeypairController(wsgi.Controller):
@wsgi.Controller.api_version("2.2", "2.9") # noqa
@validation.query_schema(keypairs.show_query_schema_v20)
@wsgi.expected_errors(404)
def show(self, req, id):
def show(self, req, id): # noqa
return self._show(req, id, key_type=True)
@wsgi.Controller.api_version("2.1", "2.1") # noqa
@validation.query_schema(keypairs.show_query_schema_v20)
@wsgi.expected_errors(404)
def show(self, req, id):
def show(self, req, id): # noqa
return self._show(req, id)
def _show(self, req, id, key_type=False, user_id=None):
@ -217,7 +217,7 @@ class KeypairController(wsgi.Controller):
@wsgi.Controller.api_version("2.10", "2.34") # noqa
@validation.query_schema(keypairs.index_query_schema_v210)
@wsgi.expected_errors(())
def index(self, req):
def index(self, req): # noqa
# handle optional user-id for admin only
user_id = self._get_user_id(req)
return self._index(req, key_type=True, user_id=user_id)
@ -225,13 +225,13 @@ class KeypairController(wsgi.Controller):
@wsgi.Controller.api_version("2.2", "2.9") # noqa
@validation.query_schema(keypairs.index_query_schema_v20)
@wsgi.expected_errors(())
def index(self, req):
def index(self, req): # noqa
return self._index(req, key_type=True)
@wsgi.Controller.api_version("2.1", "2.1") # noqa
@validation.query_schema(keypairs.index_query_schema_v20)
@wsgi.expected_errors(())
def index(self, req):
def index(self, req): # noqa
return self._index(req)
def _index(self, req, key_type=False, user_id=None, links=False):

View File

@ -51,24 +51,24 @@ class LimitsController(wsgi.Controller):
return self._index(req)
@wsgi.Controller.api_version(MIN_WITHOUT_PROXY_API_SUPPORT_VERSION, # noqa
MAX_IMAGE_META_PROXY_API_VERSION) # noqa
MAX_IMAGE_META_PROXY_API_VERSION)
@wsgi.expected_errors(())
@validation.query_schema(limits.limits_query_schema)
def index(self, req):
def index(self, req): # noqa
return self._index(req, FILTERED_LIMITS_2_36)
@wsgi.Controller.api_version( # noqa
MIN_WITHOUT_IMAGE_META_PROXY_API_VERSION, '2.56') # noqa
MIN_WITHOUT_IMAGE_META_PROXY_API_VERSION, '2.56')
@wsgi.expected_errors(())
@validation.query_schema(limits.limits_query_schema)
def index(self, req):
def index(self, req): # noqa
return self._index(req, FILTERED_LIMITS_2_36, max_image_meta=False)
@wsgi.Controller.api_version('2.57') # noqa
@wsgi.expected_errors(())
@validation.query_schema(limits.limits_query_schema_275, '2.75')
@validation.query_schema(limits.limits_query_schema, '2.57', '2.74')
def index(self, req):
def index(self, req): # noqa
return self._index(req, FILTERED_LIMITS_2_57, max_image_meta=False)
def _index(self, req, filtered_limits=None, max_image_meta=True):

View File

@ -153,7 +153,7 @@ class MigrationsController(wsgi.Controller):
@wsgi.expected_errors(())
@validation.query_schema(schema_migrations.list_query_schema_v20,
"2.23", "2.58")
def index(self, req):
def index(self, req): # noqa
"""Return all migrations using the query parameters as filters."""
return self._index(req, add_link=True)
@ -161,7 +161,7 @@ class MigrationsController(wsgi.Controller):
@wsgi.expected_errors(400)
@validation.query_schema(schema_migrations.list_query_params_v259,
"2.59", "2.65")
def index(self, req):
def index(self, req): # noqa
"""Return all migrations using the query parameters as filters."""
limit, marker = common.get_limit_and_marker(req)
return self._index(req, add_link=True, next_link=True, add_uuid=True,
@ -176,7 +176,7 @@ class MigrationsController(wsgi.Controller):
"2.66", "2.79")
@validation.query_schema(schema_migrations.list_query_params_v280,
"2.80")
def index(self, req):
def index(self, req): # noqa
"""Return all migrations using the query parameters as filters."""
limit, marker = common.get_limit_and_marker(req)
return self._index(req, add_link=True, next_link=True, add_uuid=True,

View File

@ -82,12 +82,12 @@ class QuotaClassSetsController(wsgi.Controller):
@wsgi.Controller.api_version('2.50', '2.56') # noqa
@wsgi.expected_errors(())
def show(self, req, id):
def show(self, req, id): # noqa
return self._show(req, id, FILTERED_QUOTAS_2_50)
@wsgi.Controller.api_version('2.57') # noqa
@wsgi.expected_errors(())
def show(self, req, id):
def show(self, req, id): # noqa
return self._show(req, id, FILTERED_QUOTAS_2_57)
def _show(self, req, id, filtered_quotas=None,
@ -107,13 +107,13 @@ class QuotaClassSetsController(wsgi.Controller):
@wsgi.Controller.api_version("2.50", "2.56") # noqa
@wsgi.expected_errors(400)
@validation.schema(quota_classes.update_v250)
def update(self, req, id, body):
def update(self, req, id, body): # noqa
return self._update(req, id, body, FILTERED_QUOTAS_2_50)
@wsgi.Controller.api_version("2.57") # noqa
@wsgi.expected_errors(400)
@validation.schema(quota_classes.update_v257)
def update(self, req, id, body):
def update(self, req, id, body): # noqa
return self._update(req, id, body, FILTERED_QUOTAS_2_57)
def _update(self, req, id, body, filtered_quotas=None,

View File

@ -112,12 +112,12 @@ class QuotaSetsController(wsgi.Controller):
@wsgi.Controller.api_version( # noqa
MIN_WITHOUT_PROXY_API_SUPPORT_VERSION, '2.56')
@wsgi.expected_errors(400)
def show(self, req, id):
def show(self, req, id): # noqa
return self._show(req, id, FILTERED_QUOTAS_2_36)
@wsgi.Controller.api_version('2.57') # noqa
@wsgi.expected_errors(400)
def show(self, req, id):
def show(self, req, id): # noqa
return self._show(req, id, FILTERED_QUOTAS_2_57)
@validation.query_schema(quota_sets.query_schema_275, '2.75')
@ -141,12 +141,12 @@ class QuotaSetsController(wsgi.Controller):
@wsgi.Controller.api_version( # noqa
MIN_WITHOUT_PROXY_API_SUPPORT_VERSION, '2.56')
@wsgi.expected_errors(400)
def detail(self, req, id):
def detail(self, req, id): # noqa
return self._detail(req, id, FILTERED_QUOTAS_2_36)
@wsgi.Controller.api_version('2.57') # noqa
@wsgi.expected_errors(400)
def detail(self, req, id):
def detail(self, req, id): # noqa
return self._detail(req, id, FILTERED_QUOTAS_2_57)
@validation.query_schema(quota_sets.query_schema_275, '2.75')
@ -172,13 +172,13 @@ class QuotaSetsController(wsgi.Controller):
MIN_WITHOUT_PROXY_API_SUPPORT_VERSION, '2.56')
@wsgi.expected_errors(400)
@validation.schema(quota_sets.update_v236)
def update(self, req, id, body):
def update(self, req, id, body): # noqa
return self._update(req, id, body, FILTERED_QUOTAS_2_36)
@wsgi.Controller.api_version('2.57') # noqa
@wsgi.expected_errors(400)
@validation.schema(quota_sets.update_v257)
def update(self, req, id, body):
def update(self, req, id, body): # noqa
return self._update(req, id, body, FILTERED_QUOTAS_2_57)
@validation.query_schema(quota_sets.query_schema_275, '2.75')
@ -247,12 +247,12 @@ class QuotaSetsController(wsgi.Controller):
@wsgi.Controller.api_version( # noqa
MIN_WITHOUT_PROXY_API_SUPPORT_VERSION, '2.56')
@wsgi.expected_errors(400)
def defaults(self, req, id):
def defaults(self, req, id): # noqa
return self._defaults(req, id, FILTERED_QUOTAS_2_36)
@wsgi.Controller.api_version('2.57') # noqa
@wsgi.expected_errors(400)
def defaults(self, req, id):
def defaults(self, req, id): # noqa
return self._defaults(req, id, FILTERED_QUOTAS_2_57)
def _defaults(self, req, id, filtered_quotas):

View File

@ -101,7 +101,8 @@ class ServersController(wsgi.Controller):
if 'server' not in robj.obj:
return robj
link = [l for l in robj.obj['server']['links'] if l['rel'] == 'self']
link = [link for link in robj.obj['server'][
'links'] if link['rel'] == 'self']
if link:
robj['Location'] = link[0]['href']

View File

@ -380,7 +380,7 @@ class ServiceController(wsgi.Controller):
@wsgi.Controller.api_version(UUID_FOR_ID_MIN_VERSION) # noqa F811
@wsgi.expected_errors((400, 404))
@validation.schema(services.service_update_v2_53, UUID_FOR_ID_MIN_VERSION)
def update(self, req, id, body):
def update(self, req, id, body): # noqa
"""Perform service update
Starting with microversion 2.53, the service uuid is passed in on the

View File

@ -273,7 +273,7 @@ class SimpleTenantUsageController(wsgi.Controller):
@wsgi.Controller.api_version("2.1", "2.39") # noqa
@validation.query_schema(schema.index_query)
@wsgi.expected_errors(400)
def index(self, req):
def index(self, req): # noqa
"""Retrieve tenant_usage for all tenants."""
return self._index(req)
@ -288,7 +288,7 @@ class SimpleTenantUsageController(wsgi.Controller):
@wsgi.Controller.api_version("2.1", "2.39") # noqa
@validation.query_schema(schema.show_query)
@wsgi.expected_errors(400)
def show(self, req, id):
def show(self, req, id): # noqa
"""Retrieve tenant_usage for a specified tenant."""
return self._show(req, id)

View File

@ -29,7 +29,7 @@ def upgrade(migrate_engine):
for table in (compute_nodes, aggregates):
count = select([func.count()]).select_from(table).where(and_(
table.c.deleted == 0,
table.c.uuid == None)).execute().scalar() # NOQA
table.c.uuid == None)).execute().scalar() # noqa
if count > 0:
msg = WARNING_MSG % {
'count': count,
@ -45,8 +45,8 @@ def upgrade(migrate_engine):
# if the definition is altered.
count = select([func.count()]).select_from(pci_devices).where(and_(
pci_devices.c.deleted == 0,
pci_devices.c.parent_addr == None,
pci_devices.c.dev_type == 'type-VF')).execute().scalar() # NOQA
pci_devices.c.parent_addr == None, # noqa
pci_devices.c.dev_type == 'type-VF')).execute().scalar()
if count > 0:
msg = WARNING_MSG % {
'count': count,

View File

@ -31,12 +31,12 @@ class MicroversionsController(wsgi.Controller):
return data
@wsgi.Controller.api_version("2.2") # noqa
def index(self, req):
def index(self, req): # noqa
data = {'param': 'val2'}
return data
@wsgi.Controller.api_version("3.0") # noqa
def index(self, req):
def index(self, req): # noqa
raise webob.exc.HTTPBadRequest()
@ -52,7 +52,7 @@ class MicroversionsController2(wsgi.Controller):
@wsgi.Controller.api_version("2.5", "3.1") # noqa
@wsgi.response(202)
def index(self, req):
def index(self, req): # noqa
data = {'param': 'controller2_val2'}
return data
@ -88,7 +88,7 @@ class MicroversionsController4(wsgi.Controller):
return data
@wsgi.Controller.api_version("2.2") # noqa
def _create(self, req):
def _create(self, req): # noqa
data = {'param': 'controller4_val2'}
return data

View File

@ -6261,6 +6261,7 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase):
mock_get_allocations, mock_ins_save, mock_spawn):
accel_info = [{'k1': 'v1', 'k2': 'v2'}]
@contextlib.contextmanager
def fake_build_resources(compute_mgr, *args, **kwargs):
yield {

View File

@ -881,7 +881,7 @@ class TestObjectSerializer(_BaseTestCase):
}
@base.NovaObjectRegistry.register # noqa
class Parent(base.NovaObject):
class Parent(base.NovaObject): # noqa
VERSION = '1.1'
fields = {

View File

@ -123,8 +123,7 @@ class VMwareDriverStartupTestCase(test.NoDBTestCase):
self.flags(**startup_flags)
with mock.patch(
'nova.virt.vmwareapi.driver.VMwareAPISession.__init__'):
e = self.assertRaises(
Exception, driver.VMwareVCDriver, None) # noqa
e = self.assertRaises(Exception, driver.VMwareVCDriver, None) # noqa
self.assertIs(type(e), expected_exception_type)
def test_start_driver_no_user(self):

View File

@ -2,7 +2,7 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
hacking>=3.0.1,<3.1.0 # Apache-2.0
hacking>=3.1.0,<3.2.0 # Apache-2.0
mypy>=0.761 # MIT
coverage!=4.4,>=4.0 # Apache-2.0
ddt>=1.0.1 # MIT