Enable E224/5/6 check

It is enabled globally in OpenStack projects.

Change-Id: I8ebc35617fe882117d036248632435e9d35d4bff
Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
This commit is contained in:
Takashi Kajinami
2025-08-03 23:45:49 +09:00
parent 7bf39b96d5
commit 2fe17758dd
8 changed files with 43 additions and 44 deletions

View File

@@ -92,12 +92,11 @@ max-complexity = 20
enable-extensions=H904
# Ignored extensions, might be enabled again after review:
# E123 closing bracket does not match indentation of opening bracket's line
# E226 missing whitespace around arithmetic operator
# E402 module level import not at top of file
# E731 do not assign a lambda expression, use a def
# W503 line break before binary operator
# W504 line break after binary operator
ignore = E123,E226,E402,E731,W503,W504
ignore = E123,E402,E731,W503,W504
[doc8]
# File extensions to check

View File

@@ -31,24 +31,24 @@ def _Linear_function(minimum_delay, maximum_delay, times):
def _Geometric_function(minimum_delay, maximum_delay, times):
x_max = int((maximum_delay - minimum_delay) / times)
k = math.pow(10, math.log10(maximum_delay/minimum_delay)/(x_max-1))
xarray = range(1, x_max+1)
return [int(minimum_delay*math.pow(k, a-1)) for a in xarray]
k = math.pow(10, math.log10(maximum_delay / minimum_delay) / (x_max - 1))
xarray = range(1, x_max + 1)
return [int(minimum_delay * math.pow(k, a - 1)) for a in xarray]
def _Exponential_function(minimum_delay, maximum_delay, times):
x_max = int((maximum_delay - minimum_delay) / times)
k = math.pow(10, math.log10(maximum_delay/minimum_delay)/(x_max-1))
p = minimum_delay/k
xarray = range(1, x_max+1)
return [int(p*math.pow(k, a)) for a in xarray]
k = math.pow(10, math.log10(maximum_delay / minimum_delay) / (x_max - 1))
p = minimum_delay / k
xarray = range(1, x_max + 1)
return [int(p * math.pow(k, a)) for a in xarray]
def _Arithmetic_function(minimum_delay, maximum_delay, times):
x_max = int((maximum_delay - minimum_delay) / times)
d = 2.0 * (maximum_delay - minimum_delay) / (x_max * (x_max - 1))
xarray = range(1, x_max+1)
return [int(minimum_delay+(a-1)*a*d/2) for a in xarray]
xarray = range(1, x_max + 1)
return [int(minimum_delay + (a - 1) * a * d / 2) for a in xarray]
RETRY_BACKOFF_FUNCTION_MAP = {'linear': _Linear_function,

View File

@@ -54,13 +54,13 @@ class TestPools(base.V1_1FunctionalTestBase):
)
pool_name = params.get('name', "newpool")
self.addCleanup(self.client.delete, url='/'+pool_name)
self.addCleanup(self.client.delete, url='/' + pool_name)
result = self.client.put('/'+pool_name, data=doc)
result = self.client.put('/' + pool_name, data=doc)
self.assertEqual(201, result.status_code)
# Test existence
result = self.client.get('/'+pool_name)
result = self.client.get('/' + pool_name)
self.assertEqual(200, result.status_code)
@ddt.data(
@@ -77,12 +77,12 @@ class TestPools(base.V1_1FunctionalTestBase):
)
pool_name = params.get('name', "newpool")
self.addCleanup(self.client.delete, url='/'+pool_name)
result = self.client.put('/'+pool_name, data=doc)
self.addCleanup(self.client.delete, url='/' + pool_name)
result = self.client.put('/' + pool_name, data=doc)
self.assertEqual(201, result.status_code)
# Test existence
result = self.client.get('/'+pool_name+'?detailed=true')
result = self.client.get('/' + pool_name + '?detailed=true')
self.assertEqual(200, result.status_code)
self.assertSchema(result.json(), 'pool_get_detail')
@@ -105,15 +105,15 @@ class TestPools(base.V1_1FunctionalTestBase):
)
pool_name = params.get('name', "newpool")
result = self.client.put('/'+pool_name, data=doc)
result = self.client.put('/' + pool_name, data=doc)
self.assertEqual(201, result.status_code)
# Make sure it exists
result = self.client.get('/'+pool_name)
result = self.client.get('/' + pool_name)
self.assertEqual(200, result.status_code)
# Delete it
result = self.client.delete('/'+pool_name)
result = self.client.delete('/' + pool_name)
self.assertEqual(204, result.status_code)
@ddt.data(
@@ -132,8 +132,8 @@ class TestPools(base.V1_1FunctionalTestBase):
uri=self.mongodb_url
)
pool_name = params.get('name', "newpool")
self.addCleanup(self.client.delete, url='/'+pool_name)
result = self.client.put('/'+pool_name, data=doc)
self.addCleanup(self.client.delete, url='/' + pool_name)
result = self.client.put('/' + pool_name, data=doc)
self.assertEqual(201, result.status_code)
result = self.client.get()
@@ -157,8 +157,8 @@ class TestPools(base.V1_1FunctionalTestBase):
uri=self.mongodb_url
)
pool_name = params.get('name', "newpool")
self.addCleanup(self.client.delete, url='/'+pool_name)
result = self.client.put('/'+pool_name, data=doc)
self.addCleanup(self.client.delete, url='/' + pool_name)
result = self.client.put('/' + pool_name, data=doc)
self.assertEqual(201, result.status_code)
# Update that pool
@@ -166,11 +166,11 @@ class TestPools(base.V1_1FunctionalTestBase):
weight=5,
uri=self.mongodb_url
)
result = self.client.patch('/'+pool_name, data=patchdoc)
result = self.client.patch('/' + pool_name, data=patchdoc)
self.assertEqual(200, result.status_code)
# Get the pool, check update#
result = self.client.get('/'+pool_name)
result = self.client.get('/' + pool_name)
self.assertEqual(200, result.status_code)
self.assertEqual(5, result.json()["weight"])
@@ -188,12 +188,12 @@ class TestPools(base.V1_1FunctionalTestBase):
uri=self.mongodb_url
)
pool_name = params.get('name', "newpool")
self.addCleanup(self.client.delete, url='/'+pool_name)
result = self.client.put('/'+pool_name, data=doc)
self.addCleanup(self.client.delete, url='/' + pool_name)
result = self.client.put('/' + pool_name, data=doc)
self.assertEqual(201, result.status_code)
# Update pool with bad post data. Ensure 400
result = self.client.patch('/'+pool_name)
result = self.client.patch('/' + pool_name)
self.assertEqual(400, result.status_code)
@ddt.data(
@@ -213,7 +213,7 @@ class TestPools(base.V1_1FunctionalTestBase):
@ddt.data(
{'name': '\u6c49\u5b57\u6f22\u5b57'},
{'name': 'i'*65},
{'name': 'i' * 65},
{'weight': -1}
)
def test_insert_pool_bad_data(self, params):
@@ -224,8 +224,8 @@ class TestPools(base.V1_1FunctionalTestBase):
uri=self.mongodb_url
)
pool_name = params.get('name', "newpool")
self.addCleanup(self.client.delete, url='/'+pool_name)
result = self.client.put('/'+pool_name, data=doc)
self.addCleanup(self.client.delete, url='/' + pool_name)
result = self.client.put('/' + pool_name, data=doc)
self.assertEqual(400, result.status_code)
def test_delete_pool_non_exist(self):

View File

@@ -134,7 +134,7 @@ class TestFlavorsMongoDB(base.V2Base):
body=jsonutils.dumps({'capabilities': {}}))
self.assertEqual(falcon.HTTP_400, self.srmock.status)
@ddt.data(1, 2**32+1, [])
@ddt.data(1, 2**32 + 1, [])
def test_put_raises_if_invalid_pool(self, pool_list):
path = self.url_prefix + '/flavors/' + str(uuid.uuid1())
self.simulate_put(path,
@@ -234,7 +234,7 @@ class TestFlavorsMongoDB(base.V2Base):
'location': 100, 'partition': 'taco'}
self._patch_test(doc)
@ddt.data(-1, 2**32+1, [])
@ddt.data(-1, 2**32 + 1, [])
def test_patch_raises_400_on_invalid_pool_list(self, pool_list):
self.simulate_patch(self.flavor_path,
body=jsonutils.dumps({'pool_list': pool_list}))
@@ -294,7 +294,7 @@ class TestFlavorsMongoDB(base.V2Base):
self.assertEqual(falcon.HTTP_200, self.srmock.status)
self.assertIn('links', next_flavors)
if limit < count:
self.assertEqual(min(limit, count-limit),
self.assertEqual(min(limit, count - limit),
len(next_flavors_list))
else:
self.assertEqual(0, len(next_flavors_list))

View File

@@ -121,7 +121,7 @@ class TestPoolsMongoDB(base.V2Base):
{'uri': self.mongodb_url}))
self.assertEqual(falcon.HTTP_400, self.srmock.status)
@ddt.data(-1, 2**32+1, 'big')
@ddt.data(-1, 2**32 + 1, 'big')
def test_put_raises_if_invalid_weight(self, weight):
path = self.url_prefix + '/pools/' + uuidutils.generate_uuid()
doc = {'weight': weight, 'uri': 'a'}
@@ -129,7 +129,7 @@ class TestPoolsMongoDB(base.V2Base):
body=jsonutils.dumps(doc))
self.assertEqual(falcon.HTTP_400, self.srmock.status)
@ddt.data(-1, 2**32+1, [], 'localhost:27017')
@ddt.data(-1, 2**32 + 1, [], 'localhost:27017')
def test_put_raises_if_invalid_uri(self, uri):
path = self.url_prefix + '/pools/' + uuidutils.generate_uuid()
self.simulate_put(path,
@@ -254,13 +254,13 @@ class TestPoolsMongoDB(base.V2Base):
'partition': 'taco'}
self._patch_test(doc)
@ddt.data(-1, 2**32+1, 'big')
@ddt.data(-1, 2**32 + 1, 'big')
def test_patch_raises_400_on_invalid_weight(self, weight):
self.simulate_patch(self.pool,
body=jsonutils.dumps({'weight': weight}))
self.assertEqual(falcon.HTTP_400, self.srmock.status)
@ddt.data(-1, 2**32+1, [], 'localhost:27017')
@ddt.data(-1, 2**32 + 1, [], 'localhost:27017')
def test_patch_raises_400_on_invalid_uri(self, uri):
self.simulate_patch(self.pool,
body=jsonutils.dumps({'uri': uri}))
@@ -326,7 +326,7 @@ class TestPoolsMongoDB(base.V2Base):
self.assertIn('links', next_pool)
if limit < count:
self.assertEqual(min(limit, count-limit),
self.assertEqual(min(limit, count - limit),
len(next_pool_list))
else:
# NOTE(jeffrey4l): when limit >= count, there will be no

View File

@@ -70,7 +70,7 @@ class TestPurge(base.V2Base):
# Purge queue
purge_body = jsonutils.dumps({'resource_types': ['messages']})
self.simulate_post(self.queue_path+"/purge", body=purge_body)
self.simulate_post(self.queue_path + "/purge", body=purge_body)
for msg_id in msg_ids:
target = self.messages_path + '/' + msg_id
@@ -105,7 +105,7 @@ class TestPurge(base.V2Base):
# Purge queue
purge_body = jsonutils.dumps({'resource_types': ['messages',
'subscriptions']})
self.simulate_post(self.queue_path+"/purge", body=purge_body)
self.simulate_post(self.queue_path + "/purge", body=purge_body)
for msg_id in msg_ids:
target = self.messages_path + '/' + msg_id

View File

@@ -214,7 +214,7 @@ class TestSubscriptionsMongoDB(base.V2Base):
self.assertEqual(falcon.HTTP_200, self.srmock.status)
self.assertIn('links', next_subscriptions)
if limit < count:
self.assertEqual(min(limit, count-limit),
self.assertEqual(min(limit, count - limit),
len(next_subscriptions_list))
else:
self.assertEqual(0, len(next_subscriptions_list))

View File

@@ -210,7 +210,7 @@ class Validator(object):
if max_delay < min_delay:
msg = _('minimum_delay must less than maximum_delay.')
raise ValidationFailed(msg)
if ((max_delay - min_delay) < 2*consts.LINEAR_INTERVAL):
if ((max_delay - min_delay) < 2 * consts.LINEAR_INTERVAL):
msg = _('invalid minimum_delay and maximum_delay.')
raise ValidationFailed(msg)