Update hacking for Python3

The repo is Python 3 now, so update hacking to version 3.0 which
supports Python 3.

Fix problems found.

Update local hacking checks for new flake8.

Remove hacking and friends from lower-constraints, those are not needed
for co-installing.

Change-Id: I926efaef501f190e78da9cab40c1e94203277258
This commit is contained in:
Andreas Jaeger 2020-03-31 17:18:42 +02:00
parent 059bfe5734
commit ae228bb5cc
88 changed files with 219 additions and 215 deletions

View File

@ -32,14 +32,12 @@ eventlet==0.18.2
extras==1.0.0
fasteners==0.14.1
fixtures==3.0.0
flake8==2.5.5
future==0.16.0
futurist==1.6.0
gitdb2==2.0.3
GitPython==2.1.8
google-auth==1.4.1
greenlet==0.4.13
hacking==0.12.0
idna==2.6
imagesize==1.0.0
ipaddress==1.0.19
@ -98,7 +96,6 @@ Paste==2.0.3
PasteDeploy==1.5.2
pbr==2.0.0
pecan==1.0.0
pep8==1.5.7
pika-pool==0.1.3
pika==0.10.0
prettytable==0.7.2
@ -107,7 +104,6 @@ pyasn1-modules==0.2.1
pyasn1==0.4.2
pycadf==1.1.0
pycparser==2.18
pyflakes==0.8.1
Pygments==2.2.0
pyinotify==0.9.6
pyOpenSSL==17.5.0

View File

@ -414,7 +414,7 @@ class ClusterTemplatesController(base.Controller):
new_cluster_template.uuid)
return ClusterTemplate.convert_with_links(new_cluster_template)
@wsme.validate(types.uuid_or_name, [ClusterTemplatePatchType])
@wsme.validate(types.uuid_or_name, [ClusterTemplatePatchType]) # noqa
@expose.expose(ClusterTemplate, types.uuid_or_name,
body=[ClusterTemplatePatchType])
@validation.enforce_network_driver_types_update()

View File

@ -152,7 +152,7 @@ boolean = BooleanType()
class JsonPatchType(wtypes.Base):
"""A complex type that represents a single json-patch operation."""
path = wtypes.wsattr(wtypes.StringType(pattern='^(/[\w-]+)+$'),
path = wtypes.wsattr(wtypes.StringType(pattern=r'^(/[\w-]+)+$'),
mandatory=True)
op = wtypes.wsattr(wtypes.Enum(wtypes.text, 'add', 'replace', 'remove'),
mandatory=True)

View File

@ -32,7 +32,7 @@ class AuthTokenMiddleware(auth_token.AuthProtocol):
def __init__(self, app, conf, public_api_routes=None):
if public_api_routes is None:
public_api_routes = []
route_pattern_tpl = '%s(\.json)?$'
route_pattern_tpl = r'%s(\.json)?$'
try:
self.public_api_routes = [re.compile(route_pattern_tpl % route_tpl)

View File

@ -103,7 +103,7 @@ class CertManager(cert_manager.CertManager):
return cert_ref
@staticmethod
@staticmethod # noqa: C901
def get_cert(cert_ref, **kwargs):
"""Retrieves the specified cert.

View File

@ -37,7 +37,7 @@ CONF = magnum.conf.CONF
try:
CONF.import_opt('fatal_exception_format_errors',
'oslo_versionedobjects.exception')
except cfg.NoSuchOptError as e:
except cfg.NoSuchOptError:
# Note:work around for magnum run against master branch
# in devstack gate job, as magnum not branched yet
# verisonobjects kilo/master different version can

View File

@ -31,7 +31,8 @@ def _to_byte_string(value, num_bits):
required.
"""
shifts = six.moves.xrange(num_bits - 8, -8, -8)
byte_at = lambda off: (value >> off if off >= 0 else value << -off) & 0xff
byte_at = lambda off: ((value >> off # noqa: E731
if off >= 0 else value << -off) & 0xff)
return ''.join(chr(byte_at(offset)) for offset in shifts)

View File

@ -233,11 +233,11 @@ def delete_certificates_from_cluster(cluster, context=None):
def delete_client_files(cluster, context=None):
cached_cert_dir = os.path.join(CONF.cluster.temp_cache_dir,
cluster.uuid)
try:
if os.path.isdir(cached_cert_dir):
shutil.rmtree(cached_cert_dir)
except Exception:
LOG.warning("Deleting client files failed for Cluster %s",
cluster.uuid)
cached_cert_dir = os.path.join(CONF.cluster.temp_cache_dir,
cluster.uuid)
try:
if os.path.isdir(cached_cert_dir):
shutil.rmtree(cached_cert_dir)
except Exception:
LOG.warning("Deleting client files failed for Cluster %s",
cluster.uuid)

View File

@ -21,8 +21,8 @@ Create Date: 2017-07-31 12:46:00.777841
revision = '041d9a0f1159'
down_revision = '04c625aa95ba'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -25,7 +25,7 @@ Create Date: 2016-02-28 15:27:26.211244
revision = '049f81f6f584'
down_revision = 'ee92b41b8809'
from alembic import op
from alembic import op # noqa: E402
def upgrade():

View File

@ -21,8 +21,8 @@ Create Date: 2017-10-10 15:40:37.553288
revision = '04c625aa95ba'
down_revision = '52bcaf58fecb'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -22,13 +22,13 @@ Create Date: 2016-01-12 06:21:24.880838
revision = '05d3e97de9ee'
down_revision = '57fbdf2327a2'
from alembic import op
from alembic import op # noqa: E402
from oslo_db.sqlalchemy.types import String
from oslo_db.sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa
import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TINYTEXT
from sqlalchemy.dialects.mysql import TINYTEXT # noqa: E402
def upgrade():

View File

@ -21,7 +21,7 @@ Create Date: 2016-05-25 12:05:30.790282
revision = '085e601a39f6'
down_revision = 'a1136d335540'
from alembic import op
from alembic import op # noqa: E402
def upgrade():

View File

@ -23,8 +23,8 @@ Create Date: 2015-07-29 16:00:38.721016
revision = '14328d6a57e3'
down_revision = '53882537ac57'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -21,8 +21,8 @@ Create Date: 2015-09-02 22:34:07.590142
revision = '1481f5b560dd'
down_revision = '3be65537a94a'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -21,8 +21,8 @@ Create Date: 2015-05-30 11:34:57.847071
revision = '156ceb17fb0a'
down_revision = '59e7664a8ba1'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -21,8 +21,8 @@ Create Date: 2015-02-27 14:53:38.042900
revision = '1afee1db6cd0'
down_revision = '35cff7c86221'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -21,8 +21,8 @@ Create Date: 2015-06-18 10:21:40.991734
revision = '1c1ff5e56048'
down_revision = '156ceb17fb0a'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -21,8 +21,8 @@ Create Date: 2015-09-23 18:17:10.195121
revision = '1d045384b966'
down_revision = '1481f5b560dd'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -21,7 +21,7 @@ Create Date: 2016-06-02 11:42:42.200992
revision = '1f196a3dabae'
down_revision = 'e0653b2d5271'
from alembic import op
from alembic import op # noqa: E402
def upgrade():

View File

@ -23,13 +23,13 @@ Create Date: 2014-01-17 12:14:07.754448
revision = '2581ebaf0cb2'
down_revision = None
from alembic import op
from alembic import op # noqa: E402
from oslo_db.sqlalchemy.types import String
from oslo_db.sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa
import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TINYTEXT
from sqlalchemy.dialects.mysql import TINYTEXT # noqa: E402
def upgrade():

View File

@ -22,8 +22,8 @@ Create Date: 2015-09-01 18:27:14.371860
revision = '27ad304554e2'
down_revision = '1d045384b966'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -21,8 +21,8 @@ Create Date: 2015-03-25 16:06:08.148629
revision = '29affeaa2bc2'
down_revision = '2d1354bbf76e'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -21,9 +21,9 @@ Create Date: 2015-03-27 15:15:36.309601
revision = '2ace4006498'
down_revision = '29affeaa2bc2'
from alembic import op
from alembic import op # noqa: E402
from magnum.db.sqlalchemy import models
from magnum.db.sqlalchemy import models # noqa: E402
def upgrade():

View File

@ -24,8 +24,8 @@ Create Date: 2015-09-30 15:33:44.514290
revision = '2ae93c9c6191'
down_revision = '5ad410481b88'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -21,9 +21,9 @@ Create Date: 2015-04-29 05:52:52.204095
revision = '2b5f24dd95de'
down_revision = '3b6c4c42adb4'
from alembic import op
from alembic import op # noqa: E402
from magnum.db.sqlalchemy import models
from magnum.db.sqlalchemy import models # noqa: E402
def upgrade():

View File

@ -25,8 +25,8 @@ Create Date: 2015-03-13 14:05:58.744652
revision = '2d1354bbf76e'
down_revision = '1afee1db6cd0'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -22,8 +22,8 @@ Create Date: 2015-04-22 16:59:06.799384
revision = '2d8657c0cdc'
down_revision = 'e772b2598d9'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -24,8 +24,8 @@ Create Date: 2015-10-03 17:03:47.194253
revision = '33ef79969018'
down_revision = '2ae93c9c6191'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -23,13 +23,13 @@ Create Date: 2015-02-26 05:02:34.260099
revision = '35cff7c86221'
down_revision = '3a938526b35d'
from alembic import op
from alembic import op # noqa: E402
from oslo_db.sqlalchemy.types import String
from oslo_db.sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa
import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TINYTEXT
from sqlalchemy.dialects.mysql import TINYTEXT # noqa: E402
def upgrade():

View File

@ -25,8 +25,8 @@ Create Date: 2015-02-23 14:32:00.086650
revision = '3a938526b35d'
down_revision = '5793cd26898d'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -22,7 +22,7 @@ Create Date: 2015-05-05 09:45:44.657047
revision = '3b6c4c42adb4'
down_revision = '592131657ca1'
from alembic import op
from alembic import op # noqa: E402
def upgrade():

View File

@ -25,13 +25,13 @@ Create Date: 2015-09-03 20:51:54.229436
revision = '3be65537a94a'
down_revision = '4e263f236334'
from alembic import op
from alembic import op # noqa: E402
from oslo_db.sqlalchemy.types import String
from oslo_db.sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa
import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TINYTEXT
from sqlalchemy.dialects.mysql import TINYTEXT # noqa: E402
def upgrade():

View File

@ -22,8 +22,8 @@ Create Date: 2015-01-22 22:22:22.150632
revision = '3bea56f25597'
down_revision = '2581ebaf0cb2'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -22,8 +22,8 @@ Create Date: 2015-12-02 16:38:54.697413
revision = '40f325033343'
down_revision = '5977879072a7'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -22,8 +22,8 @@ Create Date: 2015-10-14 16:21:57.229436
revision = '417917e778f5'
down_revision = '33ef79969018'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -24,8 +24,8 @@ Create Date: 2015-07-17 13:12:12.653241
revision = '421102d1f2d2'
down_revision = '14328d6a57e3'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -22,8 +22,8 @@ Create Date: 2015-04-01 15:04:45.652672
revision = '456126c6c9e9'
down_revision = '2ace4006498'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -25,15 +25,15 @@ Create Date: 2019-02-06 14:32:40.316528
revision = '461d798132c7'
down_revision = 'ac92cbae311c'
from alembic import op
from alembic import op # noqa: E402
import sqlalchemy as sa
import sqlalchemy as sa # noqa: E402
from oslo_db.sqlalchemy.types import String
from oslo_serialization import jsonutils
from oslo_utils import uuidutils
from oslo_db.sqlalchemy.types import String # noqa: E402
from oslo_serialization import jsonutils # noqa: E402
from oslo_utils import uuidutils # noqa: E402
from magnum.db.sqlalchemy import models
from magnum.db.sqlalchemy import models # noqa: E402
def _handle_json_columns(value, default=None):

View File

@ -22,10 +22,10 @@ Create Date: 2019-07-17 13:17:58.760452
revision = '47380964133d'
down_revision = '461d798132c7'
from alembic import op
from oslo_db.sqlalchemy.types import String
import sqlalchemy as sa
from sqlalchemy.dialects.mysql import TINYTEXT
from alembic import op # noqa: E402
from oslo_db.sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TINYTEXT # noqa: E402
def upgrade():

View File

@ -22,13 +22,13 @@ Create Date: 2015-04-25 02:17:51.486547
revision = '4956f03cabad'
down_revision = '2d8657c0cdc'
from alembic import op
from alembic import op # noqa: E402
from oslo_db.sqlalchemy.types import String
from oslo_db.sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa
import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TINYTEXT
from sqlalchemy.dialects.mysql import TINYTEXT # noqa: E402
def upgrade():

View File

@ -21,8 +21,8 @@ Create Date: 2015-09-14 18:39:25.871218
revision = '4e263f236334'
down_revision = '5518af8dbc21'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -21,13 +21,13 @@ Create Date: 2015-04-14 18:56:03.440329
revision = '4ea34a59a64c'
down_revision = '456126c6c9e9'
from alembic import op
from alembic import op # noqa: E402
from oslo_db.sqlalchemy.types import String
from oslo_db.sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa
import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TINYTEXT
from sqlalchemy.dialects.mysql import TINYTEXT # noqa: E402
def upgrade():

View File

@ -21,8 +21,8 @@ Create Date: 2017-08-01 11:22:31.277745
revision = '52bcaf58fecb'
down_revision = 'a0e7c8450ab1'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -23,8 +23,8 @@ Create Date: 2015-06-25 16:52:47.159887
revision = '53882537ac57'
down_revision = '1c1ff5e56048'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -21,13 +21,13 @@ Create Date: 2015-08-28 13:13:19.747625
revision = '5518af8dbc21'
down_revision = '6f21dc920bb'
from alembic import op
from alembic import op # noqa: E402 # noqa: E402
from oslo_db.sqlalchemy.types import String
from oslo_db.sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa
import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TEXT
from sqlalchemy.dialects.mysql import TEXT # noqa: E402
def upgrade():

View File

@ -21,8 +21,8 @@ Create Date: 2015-02-09 12:54:09.449948
revision = '5793cd26898d'
down_revision = '3bea56f25597'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -22,7 +22,7 @@ Create Date: 2015-12-17 09:27:18.429773
revision = '57fbdf2327a2'
down_revision = 'adc3b7679ae'
from alembic import op
from alembic import op # noqa: E402
def upgrade():

View File

@ -22,14 +22,14 @@ Create Date: 2015-04-17 14:20:17.620995
revision = '592131657ca1'
down_revision = '4956f03cabad'
from alembic import op
from alembic import op # noqa: E402
from oslo_db.sqlalchemy.types import String
from oslo_db.sqlalchemy.types import String # noqa: E402
import magnum.conf
import sqlalchemy as sa
import magnum.conf # noqa: E402
import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TINYTEXT
from sqlalchemy.dialects.mysql import TINYTEXT # noqa: E402
CONF = magnum.conf.CONF

View File

@ -22,8 +22,8 @@ Create Date: 2015-11-26 04:10:39.462966
revision = '5977879072a7'
down_revision = '417917e778f5'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -22,8 +22,8 @@ Create Date: 2015-05-11 11:33:23.125790
revision = '59e7664a8ba1'
down_revision = '2b5f24dd95de'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -21,8 +21,8 @@ Create Date: 2015-09-29 17:51:10.195121
revision = '5ad410481b88'
down_revision = '27ad304554e2'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -25,13 +25,13 @@ Create Date: 2016-02-17 14:16:12.927874
revision = '5d4caa6e0a42'
down_revision = 'bb42b7cad130'
from alembic import op
from alembic import op # noqa: E402
from oslo_db.sqlalchemy.types import String
from oslo_db.sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa
import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TINYTEXT
from sqlalchemy.dialects.mysql import TINYTEXT # noqa: E402
def upgrade():

View File

@ -21,8 +21,8 @@ Create Date: 2016-06-23 18:44:55.312413
revision = '68ce16dfd341'
down_revision = '085e601a39f6'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -21,8 +21,8 @@ Create Date: 2015-08-19 13:57:14.863292
revision = '6f21dc920bb'
down_revision = '966a99e70ff'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -22,9 +22,9 @@ Create Date: 2015-08-20 13:57:14.863292
revision = '6f21dc998bb'
down_revision = '421102d1f2d2'
from alembic import op
from magnum.db.sqlalchemy import models
import sqlalchemy as sa
from alembic import op # noqa: E402
from magnum.db.sqlalchemy import models # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -21,8 +21,8 @@ Create Date: 2016-09-02 09:43:41.485934
revision = '720f640f43d1'
down_revision = 'fb03fdef8919'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -21,7 +21,7 @@ Create Date: 2016-08-09 13:46:24.052528
revision = '859fb45df249'
down_revision = '1f196a3dabae'
from alembic import op
from alembic import op # noqa: E402
def upgrade():

View File

@ -21,8 +21,8 @@ Create Date: 2019-02-05 15:35:26.290751
revision = '87e62e3c7abc'
down_revision = 'cbbc65a86986'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -21,13 +21,13 @@ Create Date: 2015-08-24 11:23:24.262921
revision = '966a99e70ff'
down_revision = '6f21dc998bb'
from alembic import op
from alembic import op # noqa: E402
from oslo_db.sqlalchemy.types import String
from oslo_db.sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa
import sqlalchemy as sa # noqa: E402 # noqa: E402
from sqlalchemy.dialects.mysql import TINYTEXT
from sqlalchemy.dialects.mysql import TINYTEXT # noqa: E402
def upgrade():

View File

@ -22,10 +22,10 @@ Create Date: 2017-08-07 11:47:29.865166
revision = '9a1539f1cd2c'
down_revision = '041d9a0f1159'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
from magnum.db.sqlalchemy import models
from magnum.db.sqlalchemy import models # noqa: E402
def upgrade():

View File

@ -21,8 +21,8 @@ Create Date: 2017-06-12 10:08:05.501441
revision = 'a0e7c8450ab1'
down_revision = 'aa0cc27839af'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -21,8 +21,8 @@ Create Date: 2016-03-07 19:00:28.738486
revision = 'a1136d335540'
down_revision = 'd072f58ab240'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
docker_storage_driver_enum = sa.Enum('devicemapper', 'overlay',

View File

@ -21,8 +21,8 @@ Create Date: 2017-06-07 13:08:02.853105
revision = 'aa0cc27839af'
down_revision = 'bc46ba6cf949'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -25,13 +25,13 @@ Create Date: 2018-09-20 15:26:00.869885
revision = 'ac92cbae311c'
down_revision = '87e62e3c7abc'
from alembic import op
from alembic import op # noqa: E402
import sqlalchemy as sa
import sqlalchemy as sa # noqa: E402
from oslo_db.sqlalchemy.types import String
from oslo_db.sqlalchemy.types import String # noqa: E402
from magnum.db.sqlalchemy import models
from magnum.db.sqlalchemy import models # noqa: E402
def upgrade():

View File

@ -22,8 +22,8 @@ Create Date: 2015-12-07 15:49:07.622122
revision = 'adc3b7679ae'
down_revision = '40f325033343'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -21,8 +21,8 @@ Create Date: 2016-08-05 15:31:46.203266
revision = 'b1f612248cab'
down_revision = '859fb45df249'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -22,7 +22,7 @@ Create Date: 2016-02-02 16:04:36.501547
revision = 'bb42b7cad130'
down_revision = '05d3e97de9ee'
from alembic import op
from alembic import op # noqa: E402
def upgrade():

View File

@ -23,8 +23,8 @@ Create Date: 2016-10-03 10:47:08.584635
revision = 'bc46ba6cf949'
down_revision = '720f640f43d1'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -25,11 +25,11 @@ Create Date: 2019-06-14 09:29:58.288671
revision = 'c04e925e65c2'
down_revision = '47380964133d'
from alembic import op
from alembic import op # noqa: E402
import sqlalchemy as sa
import sqlalchemy as sa # noqa: E402
from oslo_db.sqlalchemy.types import String
from oslo_db.sqlalchemy.types import String # noqa: E402
def upgrade():

View File

@ -23,8 +23,8 @@ Create Date: 2018-05-15 22:24:49.527558
revision = 'cbbc65a86986'
down_revision = '9a1539f1cd2c'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -25,8 +25,8 @@ Create Date: 2016-05-27 15:29:22.955268
revision = 'd072f58ab240'
down_revision = 'ef08a5e057bd'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -21,13 +21,13 @@ Create Date: 2016-06-29 14:14:37.862594
revision = 'e0653b2d5271'
down_revision = '68ce16dfd341'
from alembic import op
from alembic import op # noqa: E402
from oslo_db.sqlalchemy.types import String
from oslo_db.sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa
import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TINYTEXT
from sqlalchemy.dialects.mysql import TINYTEXT # noqa: E402
def upgrade():

View File

@ -21,13 +21,13 @@ Create Date: 2016-03-28 09:08:07.467102
revision = 'e647f5931da8'
down_revision = '049f81f6f584'
from alembic import op
from alembic import op # noqa: E402
from oslo_db.sqlalchemy.types import String
from oslo_db.sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa
import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TINYTEXT
from sqlalchemy.dialects.mysql import TINYTEXT # noqa: E402
def upgrade():

View File

@ -21,8 +21,8 @@ Create Date: 2015-04-17 18:59:52.770329
revision = 'e772b2598d9'
down_revision = '4ea34a59a64c'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -24,8 +24,8 @@ Create Date: 2016-02-26 18:32:08.992964
revision = 'ee92b41b8809'
down_revision = '5d4caa6e0a42'
from alembic import op
import sqlalchemy as sa
from alembic import op # noqa: E402
import sqlalchemy as sa # noqa: E402
def upgrade():

View File

@ -21,7 +21,7 @@ Create Date: 2016-05-24 13:52:39.782156
revision = 'ef08a5e057bd'
down_revision = 'e647f5931da8'
from alembic import op
from alembic import op # noqa: E402
def upgrade():

View File

@ -21,7 +21,7 @@ Create Date: 2016-08-31 12:40:31.165817
revision = 'fb03fdef8919'
down_revision = 'fcb4efee8f8b'
from alembic import op
from alembic import op # noqa: E402
def upgrade():

View File

@ -21,13 +21,13 @@ Create Date: 2016-08-22 15:04:32.256811
revision = 'fcb4efee8f8b'
down_revision = 'b1f612248cab'
from alembic import op
from alembic import op # noqa: E402
from oslo_db.sqlalchemy.types import String
from oslo_db.sqlalchemy.types import String # noqa: E402
import sqlalchemy as sa
import sqlalchemy as sa # noqa: E402
from sqlalchemy.dialects.mysql import TINYTEXT
from sqlalchemy.dialects.mysql import TINYTEXT # noqa: E402
def upgrade():

View File

@ -98,6 +98,7 @@ class MagnumBase(models.TimestampMixin,
super(MagnumBase, self).save(session)
Base = declarative_base(cls=MagnumBase)

View File

@ -366,7 +366,7 @@ class FedoraKubernetesDriver(KubernetesDriver):
new_labels.update({'kube_tag': new_kube_tag})
return new_labels
def upgrade_cluster(self, context, cluster, cluster_template,
def upgrade_cluster(self, context, cluster, cluster_template, # noqa: C901
max_batch_size, nodegroup, scale_manager=None,
rollback=False):
osc = clients.OpenStackClients(context)

View File

@ -15,7 +15,7 @@
import re
import pep8 # noqa
from hacking import core
"""
Guidelines for writing new hacking checks
@ -42,7 +42,7 @@ assert_equal_with_is_not_none_re = re.compile(
r"assertEqual\(.*?\s+is+\s+not+\s+None\)$")
assert_true_isinstance_re = re.compile(
r"(.)*assertTrue\(isinstance\((\w|\.|\'|\"|\[|\])+, "
"(\w|\.|\'|\"|\[|\])+\)\)")
r"(\w|\.|\'|\"|\[|\])+\)\)")
dict_constructor_with_list_copy_re = re.compile(r".*\bdict\((\[)?(\(|\[)")
assert_xrange_re = re.compile(
r"\s*xrange\s*\(")
@ -58,16 +58,18 @@ custom_underscore_check = re.compile(r"(.)*_\s*=\s*(.)*")
underscore_import_check = re.compile(r"(.)*import _(.)*")
translated_log = re.compile(
r"(.)*LOG\.(audit|error|info|critical|exception)"
"\(\s*_\(\s*('|\")")
r"\(\s*_\(\s*('|\")")
string_translation = re.compile(r"[^_]*_\(\s*('|\")")
@core.flake8ext
def no_mutable_default_args(logical_line):
msg = "M322: Method's default argument shouldn't be mutable!"
if mutable_default_args.match(logical_line):
yield (0, msg)
@core.flake8ext
def assert_equal_not_none(logical_line):
"""Check for assertEqual(A is not None) sentences M302"""
msg = "M302: assertEqual(A is not None) sentences not allowed."
@ -76,6 +78,7 @@ def assert_equal_not_none(logical_line):
yield (0, msg)
@core.flake8ext
def assert_true_isinstance(logical_line):
"""Check for assertTrue(isinstance(a, b)) sentences
@ -85,6 +88,7 @@ def assert_true_isinstance(logical_line):
yield (0, "M316: assertTrue(isinstance(a, b)) sentences not allowed")
@core.flake8ext
def assert_equal_in(logical_line):
"""Check for assertEqual(True|False, A in B), assertEqual(A in B, True|False)
@ -98,6 +102,7 @@ def assert_equal_in(logical_line):
"contents.")
@core.flake8ext
def no_xrange(logical_line):
"""Disallow 'xrange()'
@ -107,6 +112,7 @@ def no_xrange(logical_line):
yield(0, "M339: Do not use xrange().")
@core.flake8ext
def use_timeutils_utcnow(logical_line, filename):
# tools are OK to use the standard datetime module
if "/tools/" in filename:
@ -120,6 +126,7 @@ def use_timeutils_utcnow(logical_line, filename):
yield (pos, msg % f)
@core.flake8ext
def dict_constructor_with_list_copy(logical_line):
msg = ("M336: Must use a dict comprehension instead of a dict constructor"
" with a sequence of key-value pairs."
@ -128,6 +135,7 @@ def dict_constructor_with_list_copy(logical_line):
yield (0, msg)
@core.flake8ext
def no_log_warn(logical_line):
"""Disallow 'LOG.warn('
@ -142,6 +150,7 @@ def no_log_warn(logical_line):
yield (0, msg)
@core.flake8ext
def check_explicit_underscore_import(logical_line, filename):
"""Check for explicit import of the _ function
@ -161,15 +170,3 @@ def check_explicit_underscore_import(logical_line, filename):
elif (translated_log.match(logical_line) or
string_translation.match(logical_line)):
yield(0, "M340: Found use of _() without explicit import of _ !")
def factory(register):
register(no_mutable_default_args)
register(assert_equal_not_none)
register(assert_true_isinstance)
register(assert_equal_in)
register(use_timeutils_utcnow)
register(dict_constructor_with_list_copy)
register(no_xrange)
register(no_log_warn)
register(check_explicit_underscore_import)

View File

@ -640,7 +640,7 @@ class TestPost(api_base.FunctionalTest):
mock_image_data.return_value = {'name': 'mock_name',
'os_distro': 'fedora-atomic'}
for k, v in baymodel_config_dict.items():
CONF.set_override(k, v, 'cluster_template')
CONF.set_override(k, v, 'cluster_template')
with mock.patch.object(
self.dbapi, 'create_cluster_template',
wraps=self.dbapi.create_cluster_template) as cc_mock:

View File

@ -48,7 +48,6 @@ class TestClusterConductorWithK8s(base.TestCase):
'network_driver': 'network_driver',
'volume_driver': 'volume_driver',
'docker_volume_size': 20,
'master_flavor_id': 'flavor_id',
'docker_storage_driver': 'devicemapper',
'cluster_distro': 'fedora-atomic',
'coe': 'kubernetes',
@ -651,7 +650,6 @@ class TestClusterConductorWithK8s(base.TestCase):
'portal_network_cidr': '10.254.0.0/16',
'project_id': 'project_id',
'max_node_count': 2,
'keystone_auth_default_policy': self.keystone_auth_default_policy,
'boot_volume_size': '60',
'boot_volume_type': 'lvmdriver-1',
'keystone_auth_default_policy': self.keystone_auth_default_policy,

View File

@ -36,6 +36,7 @@ class fake_stack(object):
for key, val in kw.items():
setattr(self, key, val)
# This dictionary will be populated by setUp to help mock
# the nodegroup list magnum.db.api.get_cluster_nodergoups.
cluster_ngs = {}

View File

@ -15,7 +15,7 @@
import textwrap
import mock
import pep8
import pycodestyle
from magnum.hacking import checks
from magnum.tests import base
@ -56,14 +56,14 @@ class HackingTestCase(base.TestCase):
# We are patching pep8 so that only the check under test is actually
# installed.
@mock.patch('pep8._checks',
@mock.patch('pycodestyle._checks',
{'physical_line': {}, 'logical_line': {}, 'tree': {}})
def _run_check(self, code, checker, filename=None):
pep8.register_check(checker)
pycodestyle.register_check(checker)
lines = textwrap.dedent(code).strip().splitlines(True)
checker = pep8.Checker(filename=filename, lines=lines)
checker = pycodestyle.Checker(filename=filename, lines=lines)
checker.check_all()
checker.report._deferred_print.sort()
return checker.report._deferred_print

View File

@ -10,7 +10,7 @@ bashate>=0.5.1 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0
doc8>=0.6.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
hacking>=3.0,<3.1.0 # Apache-2.0
mock>=2.0.0 # BSD
oslotest>=3.2.0 # Apache-2.0
osprofiler>=1.4.0 # Apache-2.0

14
tox.ini
View File

@ -156,8 +156,18 @@ filename = *.py,app.wsgi
enable-extensions = H106,H203,H904
exclude = .venv,.git,.tox,dist,*lib/python*,*egg,build,tools,releasenotes
[hacking]
local-check-factory = magnum.hacking.checks.factory
[flake8:local-plugins]
extension =
M302 = checks:assert_equal_not_none
M310 = checks:use_timeutils_utcnow
M316 = checks:assert_true_isinstance
M322 = checks:no_mutable_default_args
M336 = checks:dict_constructor_with_list_copy
M338 = checks:assert_equal_in
M339 = checks:no_xrange
M340 = checks:check_explicit_underscore_import
M352 = checks:no_log_warn
paths = ./magnum/hacking
[testenv:pip-check-reqs]
# do not install test-requirements as that will pollute the virtualenv for