Update hacking for Python3

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

Fix problems found.

Change-Id: I2707a1f2047f89d9f12ea282cec98411454e1f79
This commit is contained in:
Andreas Jaeger 2020-03-28 12:34:21 +01:00 committed by Andreas Jaeger
parent 9440e5489c
commit fdcbfb8365
5 changed files with 26 additions and 25 deletions

View File

@ -15,6 +15,21 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import csv
import json
import os
import sys
import yaml
from oslo_config import cfg
from oslo_log import log
try:
import shade
SHADE_LOADED = True
except ImportError:
SHADE_LOADED = False
DOCUMENTATION = ''' DOCUMENTATION = '''
Bifrost Inventory Module Bifrost Inventory Module
======================== ========================
@ -130,21 +145,6 @@ At present, this module only supports inventory list mode and is not
intended to support specific host queries. intended to support specific host queries.
''' '''
import csv
import json
import os
import sys
import yaml
from oslo_config import cfg
from oslo_log import log
try:
import shade
SHADE_LOADED = True
except ImportError:
SHADE_LOADED = False
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
opts = [ opts = [
@ -239,7 +239,7 @@ def _process_baremetal_csv(data_source, groups, hostvars):
for row in csv.reader(file_data, delimiter=','): for row in csv.reader(file_data, delimiter=','):
if not row: if not row:
break break
if len(row) is 1: if len(row) == 1:
LOG.debug("Single entry line found when attempting " LOG.debug("Single entry line found when attempting "
"to parse CSV file contents. Breaking " "to parse CSV file contents. Breaking "
"out of processing loop.") "out of processing loop.")
@ -464,5 +464,6 @@ def main():
else: else:
print(json.dumps(hostvars, indent=2)) print(json.dumps(hostvars, indent=2))
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View File

@ -37,7 +37,7 @@ def main():
node_network_data=dict(required=False, type='dict') node_network_data=dict(required=False, type='dict')
) )
module = AnsibleModule(argument_spec) module = AnsibleModule(argument_spec) # noqa: F405
network_metadata = module.params['node_network_data'] network_metadata = module.params['node_network_data']
if not network_metadata: if not network_metadata:
@ -141,7 +141,7 @@ def main():
# this is magic, see lib/ansible/module_common.py # this is magic, see lib/ansible/module_common.py
from ansible.module_utils.basic import * from ansible.module_utils.basic import * # noqa: E402
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View File

@ -74,7 +74,7 @@ def _choose_id_value(module):
def main(): def main():
argument_spec = openstack_full_argument_spec( argument_spec = openstack_full_argument_spec( # noqa: F405
auth_type=dict(required=False), auth_type=dict(required=False),
uuid=dict(required=False), uuid=dict(required=False),
name=dict(required=False), name=dict(required=False),
@ -82,8 +82,8 @@ def main():
ironic_url=dict(required=False), ironic_url=dict(required=False),
skip_items=dict(required=False, type='list'), skip_items=dict(required=False, type='list'),
) )
module_kwargs = openstack_module_kwargs() module_kwargs = openstack_module_kwargs() # noqa: F405
module = AnsibleModule(argument_spec, **module_kwargs) module = AnsibleModule(argument_spec, **module_kwargs) # noqa: F405
if not HAS_SHADE: if not HAS_SHADE:
module.fail_json(msg='shade is required for this module') module.fail_json(msg='shade is required for this module')
@ -142,6 +142,6 @@ def main():
# this is magic, see lib/ansible/module_common.py # this is magic, see lib/ansible/module_common.py
from ansible.module_utils.basic import * from ansible.module_utils.basic import * # noqa: E402
from ansible.module_utils.openstack import * from ansible.module_utils.openstack import * # noqa: E402
main() main()

View File

@ -2,7 +2,7 @@
# of appearance. Changing the order has an impact on the overall integration # of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later. # process, which may cause wedges in the gate later.
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0 hacking>=3.0,<4.0.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0
doc8>=0.6.0 # Apache-2.0 doc8>=0.6.0 # Apache-2.0

View File

@ -59,7 +59,7 @@ commands = oslo_debug_helper -t bifrost/tests {posargs}
[flake8] [flake8]
show-source = True show-source = True
ignore = F403,H102,H303 ignore = F403,H102,H303,W504
# [H106] Don't put vim configuration in source files. # [H106] Don't put vim configuration in source files.
enable-extensions=H106 enable-extensions=H106
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,os_ironic.py,os_ironic_node.py,os_ironic_inspect.py,os_keystone_service.py exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,os_ironic.py,os_ironic_node.py,os_ironic_inspect.py,os_keystone_service.py