Remove noqa to enable flake8 checks

When flake8: noqa appears anywhere in a file, the file is skipped
by flake8 checks.  This commit enables those checks for most files.
Note: Most __init__.py files still contain noqa

This commit also cleans up the following flake8 codes:
  H102: license header not found
  E712 comparison to bool should be reworded

Story: 2003499
Task: 26473
Change-Id: I61ffb5384ff7f77596b1af184b3759421bc8e5cf
Signed-off-by: Al Bailey <Al.Bailey@windriver.com>
This commit is contained in:
Al Bailey 2018-09-14 09:14:59 -05:00
parent cb1b85b13f
commit 76a213442d
26 changed files with 35 additions and 93 deletions

View File

@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# flake8: noqa
#
import six
from nfv_common.helpers import Constants, Constant, Singleton
@ -204,6 +202,7 @@ class _EventInitiatedBy(Constants):
INSTANCE = Constant('instance')
INSTANCE_DIRECTOR = Constant('instance-director')
# Constant Instantiation
EVENT_ID = _EventId()
EVENT_TYPE = _EventType()

View File

@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# flake8: noqa
#
class _NfvVimRecordType(object):
@ -122,5 +120,6 @@ class _NfvVimRecordType(object):
INSTANCE_GUEST_SERVICES_POST_NOTIFY_CALLBACK = 'nfv_vim_instance_guest_services_post_notify_callback'
INSTANCE_GUEST_SERVICES_POST_NOTIFY_HEARTBEAT = 'nfv_vim_instance_guest_services_post_notify_heartbeat'
# Constant Instantiation
NFV_VIM = _NfvVimRecordType()

View File

@ -50,7 +50,7 @@ def schedule_initialize():
selobj.selobj_add_read_obj(_receive_socket.fileno(), _schedule_dispatch)
del _pending_function_calls
_pending_function_calls = list() # flake8: noqa
_pending_function_calls = list() # noqa: F841
def schedule_finalize():
@ -67,4 +67,4 @@ def schedule_finalize():
_receive_socket.close()
del _pending_function_calls
_pending_function_calls = list() # flake8: noqa
_pending_function_calls = list() # noqa: F841

View File

@ -94,7 +94,7 @@ def selobj_dispatch(timeout_in_ms):
try:
readable, writeable, in_error = select.select(read_objs, write_objs, [],
timeout_in_ms/1000.0)
timeout_in_ms / 1000.0)
for selobj in readable:
callback = _read_callbacks.get(selobj, None)
@ -150,10 +150,10 @@ def selobj_initialize():
global _read_callbacks, _write_callbacks
del _read_callbacks
_read_callbacks = dict() # flake8: noqa
_read_callbacks = dict() # noqa: F841
del _write_callbacks
_write_callbacks = dict() # flake8: noqa
_write_callbacks = dict() # noqa: F841
def selobj_finalize():
@ -163,6 +163,6 @@ def selobj_finalize():
global _read_callbacks, _write_callbacks
del _read_callbacks
_read_callbacks = dict() # flake8: noqa
_read_callbacks = dict() # noqa: F841
del _write_callbacks
_write_callbacks = dict() # flake8: noqa
_write_callbacks = dict() # noqa: F841

View File

@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# flake8: noqa
#
import six
from nfv_common import debug

View File

@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# flake8: noqa
#
import time
import argparse

View File

@ -111,7 +111,7 @@ def timers_initialize(scheduler_interval_ms, scheduler_max_delay_ms,
_scheduler = TimerScheduler(scheduler_interval_ms,
scheduler_max_delay_ms,
scheduler_delay_debounce_ms) # flake8: noqa
scheduler_delay_debounce_ms)
def timers_finalize():

View File

@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# flake8: noqa
#
from setuptools import setup, find_packages
setup(

View File

@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# flake8: noqa
#
import argparse
import config
import time
@ -56,24 +54,6 @@ def sysinv_unit_tests(token, test_config):
hosts = sysinv.get_hosts(token)
print("List of hosts: %s" % hosts)
# for host in hosts['ihosts']:
#host_uuid = host['uuid']
#host_name = host['hostname']
# Needs proper setup since system inventory will reject the disable
# until a lock is really started.
#response = sysinv.notify_host_services_disabled(token, host_uuid)
#print ("Notify host-services-disabled: host_uuid=%s, "
# "host_name=%s, response=%s" % (host_uuid, host_name, response))
#response = sysinv.notify_host_services_disable_failed(token, host_uuid)
#print ("Notify host-services-disable failed: host_uuid=%s, "
# "host_name=%s, response=%s" % (host_uuid, host_name, response))
#response = sysinv.notify_host_services_enabled(token, host_uuid)
#print ("Notify host-services enabled: host_uuid=%s, host_name=%s, "
# "response=%s" % (host_uuid, host_name, response))
def glance_unit_tests(token, test_config):
"""
@ -163,7 +143,7 @@ def neutron_unit_tests(token, test_config):
response = neutron.disable_host_services(token, test_config['host_uuid'])
print("Host-Services disable response: %s" % response)
response = neutron.enable_host_services(token, test_config['host_uuid'])
response = neutron.enable_host_services(token, test_config['host_uuid'])
print("Host-Services enable response: %s" % response)
response = neutron.disable_host_services(token, test_config['host_uuid'])
@ -176,7 +156,7 @@ def neutron_unit_tests(token, test_config):
test_config['host_uuid'])
print("Host-Services create response: %s" % response)
response = neutron.enable_host_services(token, test_config['host_uuid'])
response = neutron.enable_host_services(token, test_config['host_uuid'])
print("Host-Services enable response: %s" % response)
servers = nova.get_servers(token)
@ -243,8 +223,8 @@ def nova_unit_tests(token, test_config):
# NOTE: if you do a delete of the host-services, the hypervisors are
# deleted and will not be populated again until nova-compute is
# restarted even if you re-create and enable the host-services.
#response = nova.delete_host_services(token, test_config['host_name'])
#print "Host-Services delete response: %s" % response
# response = nova.delete_host_services(token, test_config['host_name'])
# print "Host-Services delete response: %s" % response
response = nova.create_host_services(token, test_config['host_name'])
print("Host-Services create response: %s" % response)
@ -368,7 +348,7 @@ def heat_unit_tests(token, test_config):
print("List of stacks: %s" % stacks)
for stack in stacks['stacks']:
heat.delete_stack(token, stack['stack_name'], stack['id'])
heat.delete_stack(token, stack['stack_name'], stack['id'])
stacks = heat.get_stacks(token)
while stacks['stacks']:
@ -450,16 +430,16 @@ def rest_api_unit_tests(token, test_config):
conn.send('PATCH /nfvi-plugins/v1/hosts/compute-0 HTTP/1.1 \r\n')
conn.send('Content-Type: application/json\r\n')
conn.send('Content-Length: 0\r\n')
#conn.send('Content-Length: 20\r\n')
# conn.send('Content-Length: 20\r\n')
conn.send('\r\n')
msg = conn.sock.recv(1)
print(msg)
time.sleep(20)
#fp = conn.sock.makefile('rb')
#line = fp.read(1)
#line = fp.readline()
#print line
# fp = conn.sock.makefile('rb')
# line = fp.read(1)
# line = fp.readline()
# print line
time.sleep(20)
try:
conn.send('\r\n')
@ -538,8 +518,8 @@ if __name__ == '__main__':
args = parser.parse_args()
# TODO: Port this into a unit test config file and
# TODO: fix the config object to handle multiple config files
# TODO(abailey): Port this into a unit test config file and
# TODO(abailey): fix the config object to handle multiple config files
test_config = dict()
test_config['host_name'] = 'compute-101'
test_config['host_uuid'] = '93ad7f54-f31c-44c8-b44f-2e0ccfb62aa7'

View File

@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# flake8: noqa
#
from setuptools import setup, find_packages
setup(

View File

@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# flake8: noqa
#
from setuptools import setup, find_packages
setup(

View File

@ -369,7 +369,7 @@ class TestSwPatchStrategy(object):
compute_hosts=sorted_compute_hosts,
reboot=True)
assert success == True, "Strategy creation failed"
assert success is True, "Strategy creation failed"
apply_phase = strategy.apply_phase.as_dict()
@ -1292,7 +1292,7 @@ class TestSwPatchStrategy(object):
compute_hosts=sorted_compute_hosts,
reboot=True)
assert success == False, "Strategy creation did not fail"
assert success is False, "Strategy creation did not fail"
def test_sw_patch_strategy_compute_stages_parallel_stop_start_host_aggregate(self):
"""
@ -2514,7 +2514,7 @@ class TestSwPatchStrategy(object):
compute_hosts=sorted_compute_hosts,
reboot=True)
assert success == False, "Strategy creation did not fail"
assert success is False, "Strategy creation did not fail"
# Test no reboot patches
strategy = create_sw_patch_strategy(
@ -2611,7 +2611,7 @@ class TestSwPatchStrategy(object):
storage_hosts=sorted_storage_hosts,
reboot=True)
assert success == True, "Strategy creation failed"
assert success is True, "Strategy creation failed"
apply_phase = strategy.apply_phase.as_dict()
@ -2902,7 +2902,7 @@ class TestSwPatchStrategy(object):
success, reason = strategy._add_controller_strategy_stages(
controllers=controller_hosts,
reboot=True)
assert success == True, "Strategy creation failed"
assert success is True, "Strategy creation failed"
apply_phase = strategy.apply_phase.as_dict()
@ -3343,7 +3343,7 @@ class TestSwPatchStrategy(object):
compute_hosts=compute_hosts,
reboot=True)
assert success == False, "Strategy creation did not fail"
assert success is False, "Strategy creation did not fail"
def test_sw_patch_strategy_cpe_simplex_stages_serial_stop_start(self):
"""

View File

@ -376,7 +376,7 @@ class TestSwUpgradeStrategy(object):
compute_hosts=sorted_compute_hosts,
reboot=True)
assert success == True, "Strategy creation failed"
assert success is True, "Strategy creation failed"
apply_phase = strategy.apply_phase.as_dict()
@ -869,7 +869,7 @@ class TestSwUpgradeStrategy(object):
compute_hosts=sorted_compute_hosts,
reboot=True)
assert success == False, "Strategy creation did not fail"
assert success is False, "Strategy creation did not fail"
@mock.patch('nfv_vim.strategy._strategy.get_local_host_name',
fake_host_name_controller_1)
@ -907,7 +907,7 @@ class TestSwUpgradeStrategy(object):
storage_hosts=sorted_storage_hosts,
reboot=True)
assert success == True, "Strategy creation failed"
assert success is True, "Strategy creation failed"
apply_phase = strategy.apply_phase.as_dict()
@ -1250,7 +1250,7 @@ class TestSwUpgradeStrategy(object):
controllers=controller_hosts,
reboot=True)
assert success == False, "Strategy creation did not fail"
assert success is False, "Strategy creation did not fail"
assert reason == "cannot apply software upgrades to CPE configuration", \
"Invalid failure reason"

View File

@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# flake8: noqa
#
import uuid
from nfv_common import alarm

View File

@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# flake8: noqa
#
import uuid
from nfv_common import alarm

View File

@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# flake8: noqa
#
import uuid
from nfv_common import alarm

View File

@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# flake8: noqa
#
import uuid
from nfv_common import alarm

View File

@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# flake8: noqa
#
import uuid
from nfv_common import alarm

View File

@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# flake8: noqa
#
from nfv_common import event_log
# Log Template Definitions

View File

@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# flake8: noqa
#
from nfv_common import event_log
# Log Template Definitions

View File

@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# flake8: noqa
#
import six
from nfv_common import event_log

View File

@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# flake8: noqa
#
import six
from nfv_common import event_log

View File

@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# flake8: noqa
#
import six
from nfv_common.helpers import Constants, Constant, Singleton

View File

@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# flake8: noqa
#
import json
from nfv_common import debug

View File

@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# flake8: noqa
#
from setuptools import setup, find_packages
setup(

View File

@ -63,9 +63,7 @@ verbosity=2
# E128 continuation line under-indented for visual indent
# E129 visually indented line with same indent as next logical line
# E501 line too long
# E712 comparison to bool should be reworded
# - hacking codes -
# H102: license header not found
# H104: File contains nothing but comments
# H301: one import per line
# H306: imports not in alphabetical order
@ -78,8 +76,8 @@ verbosity=2
# - bugbear codes -
# B007 Loop control variable 'X' not used within the loop body. If this is intended, start the name with an underscore.
# B301 Python 3 does not include `.iter*` methods on dictionaries.
ignore = E121,E122,E123,E124,E126,E127,E128,E129,E501,E712,
H102,H104,H301,H306,H401,H404,H405,H501,
ignore = E121,E122,E123,E124,E126,E127,E128,E129,E501,
H104,H301,H306,H401,H404,H405,H501,
F821,
B007, B301
# H106 Dont put vim configuration in source files (off by default).
@ -124,7 +122,7 @@ exclude = nfv-docs,nfv-tests,nfv-debug-tools,unit_test
deps = {[nfv]deps}
bandit
basepython = python2.7
commands = bandit --ini tox.ini -f txt -r {[nfv]nfv_base_dir}
commands = bandit --ini tox.ini -f txt -r {[nfv]nfv_base_dir}
[testenv:py27]
basepython = python2.7