Browse Source

Fix pycodestyle warnings/errors now visible with hacking 1.1.0

This fixes the warning/errors except for the C901 Function is
too complex in the ironic_inspector/rules.py's create method.

Bump's max-complexity to 18 in tox.ini to workaround the C901.

Story: 2001985
Task: 19604
Change-Id: I6c76a43353b1beb572dbde78dba4b4a839d45ea7
changes/66/567066/2
Harald Jensås 4 years ago
parent
commit
868965c340
  1. 1
      ironic_inspector/cmd/all.py
  2. 1
      ironic_inspector/common/lldp_tlvs.py
  3. 1
      ironic_inspector/introspection_state.py
  4. 2
      ironic_inspector/main.py
  5. 1
      ironic_inspector/migrations/env.py
  6. 12
      ironic_inspector/migrations/versions/18440d0834af_introducing_the_aborting_state.py
  7. 6
      ironic_inspector/migrations/versions/578f84f38d_inital_db_schema.py
  8. 11
      ironic_inspector/migrations/versions/882b2d84cb1b_attribute_constraints_relaxing.py
  9. 11
      ironic_inspector/migrations/versions/d00d6e3f38c4_change_created_finished_at_type.py
  10. 13
      ironic_inspector/migrations/versions/d2e48801c8ef_introducing_node_state_attribute.py
  11. 9
      ironic_inspector/migrations/versions/d588418040d_add_rules.py
  12. 7
      ironic_inspector/migrations/versions/e169a4a81d88_add_invert_field_to_rule_condition.py
  13. 1
      ironic_inspector/plugins/pci_devices.py
  14. 2
      ironic_inspector/test/functional.py
  15. 4
      ironic_inspector/test/unit/test_plugins_base.py
  16. 4
      tox.ini

1
ironic_inspector/cmd/all.py

@ -25,5 +25,6 @@ def main(args=sys.argv[1:]):
server = wsgi_service.WSGIService()
server.run()
if __name__ == '__main__':
sys.exit(main())

1
ironic_inspector/common/lldp_tlvs.py

@ -275,6 +275,7 @@ def get_autoneg_cap(pmd):
return sorted(caps_set)
Dot3_MACPhy_Config_Status = core.Struct(
'autoneg' / core.BitStruct(
core.Padding(6),

1
ironic_inspector/introspection_state.py

@ -85,6 +85,7 @@ class Events(object):
return [cls.process, cls.reapply, cls.timeout, cls.wait, cls.abort,
cls.error, cls.finish]
# Error transition is allowed in any state.
State_space = [
{

2
ironic_inspector/main.py

@ -203,7 +203,7 @@ def api_root():
@api('/<version>', rule='introspection:version', is_public_api=True,
methods=['GET'])
def version_root(version):
pat = re.compile("^\/%s\/[^\/]*?$" % version)
pat = re.compile(r'^\/%s\/[^\/]*?$' % version)
resources = []
for url in app.url_map.iter_rules():

1
ironic_inspector/migrations/env.py

@ -76,6 +76,7 @@ def run_migrations_online():
with context.begin_transaction():
context.run_migrations()
if context.is_offline_mode():
run_migrations_offline()
else:

12
ironic_inspector/migrations/versions/18440d0834af_introducing_the_aborting_state.py

@ -18,18 +18,18 @@ Create Date: 2017-12-11 15:40:13.905554
"""
# revision identifiers, used by Alembic.
revision = '18440d0834af'
down_revision = '882b2d84cb1b'
branch_labels = None
depends_on = None
from alembic import op
import sqlalchemy as sa
from sqlalchemy import sql
from ironic_inspector import introspection_state as istate
# revision identifiers, used by Alembic.
revision = '18440d0834af'
down_revision = '882b2d84cb1b'
branch_labels = None
depends_on = None
old_state = sa.Enum(*(set(istate.States.all()) - {istate.States.aborting}),
name='node_state')

6
ironic_inspector/migrations/versions/578f84f38d_inital_db_schema.py

@ -22,15 +22,15 @@ Create Date: 2015-09-15 14:52:22.448944
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '578f84f38d'
down_revision = None
branch_labels = None
depends_on = None
from alembic import op
import sqlalchemy as sa
def upgrade():
op.create_table(

11
ironic_inspector/migrations/versions/882b2d84cb1b_attribute_constraints_relaxing.py

@ -18,17 +18,18 @@ Create Date: 2017-01-13 11:27:00.053286
"""
from alembic import op
from oslo_utils import uuidutils
import sqlalchemy as sa
from sqlalchemy.engine.reflection import Inspector as insp
# revision identifiers, used by Alembic.
revision = '882b2d84cb1b'
down_revision = 'd00d6e3f38c4'
branch_labels = None
depends_on = None
from alembic import op
from oslo_utils import uuidutils
import sqlalchemy as sa
from sqlalchemy.engine.reflection import Inspector as insp
ATTRIBUTES = 'attributes'
NODES = 'nodes'
NAME = 'name'

11
ironic_inspector/migrations/versions/d00d6e3f38c4_change_created_finished_at_type.py

@ -18,17 +18,18 @@ Create Date: 2016-12-15 17:18:10.728695
"""
import datetime
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'd00d6e3f38c4'
down_revision = 'd2e48801c8ef'
branch_labels = None
depends_on = None
import datetime
from alembic import op
import sqlalchemy as sa
def upgrade():
started_at = sa.Column('started_at', sa.types.Float, nullable=True)

13
ironic_inspector/migrations/versions/d2e48801c8ef_introducing_node_state_attribute.py

@ -18,18 +18,19 @@ Create Date: 2016-07-29 10:10:32.351661
"""
# revision identifiers, used by Alembic.
revision = 'd2e48801c8ef'
down_revision = 'e169a4a81d88'
branch_labels = None
depends_on = None
from alembic import op
import sqlalchemy as sa
from sqlalchemy import sql
from ironic_inspector import introspection_state as istate
# revision identifiers, used by Alembic.
revision = 'd2e48801c8ef'
down_revision = 'e169a4a81d88'
branch_labels = None
depends_on = None
Node = sql.table('nodes',
sql.column('error', sa.String),
sql.column('state', sa.Enum(*istate.States.all())))

9
ironic_inspector/migrations/versions/d588418040d_add_rules.py

@ -18,16 +18,17 @@ Create Date: 2015-09-21 14:31:03.048455
"""
from alembic import op
from oslo_db.sqlalchemy import types
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'd588418040d'
down_revision = '578f84f38d'
branch_labels = None
depends_on = None
from alembic import op
from oslo_db.sqlalchemy import types
import sqlalchemy as sa
def upgrade():
op.create_table(

7
ironic_inspector/migrations/versions/e169a4a81d88_add_invert_field_to_rule_condition.py

@ -18,15 +18,16 @@ Create Date: 2016-02-16 11:19:29.715615
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'e169a4a81d88'
down_revision = 'd588418040d'
branch_labels = None
depends_on = None
from alembic import op
import sqlalchemy as sa
def upgrade():
op.add_column('rule_conditions', sa.Column('invert', sa.Boolean(),

1
ironic_inspector/plugins/pci_devices.py

@ -37,6 +37,7 @@ def list_opts():
('pci_devices', PCI_DEVICES_OPTS)
]
CONF = cfg.CONF
CONF.register_opts(PCI_DEVICES_OPTS, group='pci_devices')

2
ironic_inspector/test/functional.py

@ -12,7 +12,6 @@
# limitations under the License.
import eventlet
eventlet.monkey_patch()
import contextlib # noqa
import copy
@ -46,6 +45,7 @@ from ironic_inspector import rules
from ironic_inspector.test import base
from ironic_inspector.test.unit import test_rules
eventlet.monkey_patch()
CONF = """
[ironic]

4
ironic_inspector/test/unit/test_plugins_base.py

@ -36,7 +36,7 @@ class TestWithValidation(test_base.BaseTest):
self.test.validate({'x': 'x', 'y': 42, 'z': False})
def test_required_missing(self):
err_re = 'missing required parameter\(s\): x'
err_re = r'missing required parameter\(s\): x'
self.assertRaisesRegex(ValueError, err_re, self.test.validate, {})
self.assertRaisesRegex(ValueError, err_re, self.test.validate,
{'x': None})
@ -44,7 +44,7 @@ class TestWithValidation(test_base.BaseTest):
{'y': 1, 'z': 2})
def test_unexpected(self):
self.assertRaisesRegex(ValueError, 'unexpected parameter\(s\): foo',
self.assertRaisesRegex(ValueError, r'unexpected parameter\(s\): foo',
self.test.validate, {'foo': 'bar', 'x': 42})

4
tox.ini

@ -62,7 +62,9 @@ deps = {[testenv]deps}
commands = {toxinidir}/tools/states_to_dot.py -f {toxinidir}/doc/source/images/states.svg --format svg
[flake8]
max-complexity=15
# TODO(hjensas): ironic_inspector/rules.py:243:1: C901 'create' is too complex (18)
# That method is to complex, it should be fixed.
max-complexity=18
# [H106] Don't put vim configuration in source files.
# [H203] Use assertIs(Not)None to check for None.
# [H204] Use assert(Not)Equal to check for equality.

Loading…
Cancel
Save