From fdcbfb836559751349c7533926a3fd6f6059773b Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Sat, 28 Mar 2020 12:34:21 +0100 Subject: [PATCH] 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 --- bifrost/inventory.py | 33 ++++++++++++++------------- playbooks/library/network_metadata.py | 4 ++-- playbooks/library/os_ironic_facts.py | 10 ++++---- test-requirements.txt | 2 +- tox.ini | 2 +- 5 files changed, 26 insertions(+), 25 deletions(-) diff --git a/bifrost/inventory.py b/bifrost/inventory.py index ae8ed0960..bf9d978e1 100755 --- a/bifrost/inventory.py +++ b/bifrost/inventory.py @@ -15,6 +15,21 @@ # See the License for the specific language governing permissions and # 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 = ''' 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. ''' -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__) opts = [ @@ -239,7 +239,7 @@ def _process_baremetal_csv(data_source, groups, hostvars): for row in csv.reader(file_data, delimiter=','): if not row: break - if len(row) is 1: + if len(row) == 1: LOG.debug("Single entry line found when attempting " "to parse CSV file contents. Breaking " "out of processing loop.") @@ -464,5 +464,6 @@ def main(): else: print(json.dumps(hostvars, indent=2)) + if __name__ == '__main__': main() diff --git a/playbooks/library/network_metadata.py b/playbooks/library/network_metadata.py index 2422e02e1..70ad0b665 100644 --- a/playbooks/library/network_metadata.py +++ b/playbooks/library/network_metadata.py @@ -37,7 +37,7 @@ def main(): 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'] if not network_metadata: @@ -141,7 +141,7 @@ def main(): # 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__': main() diff --git a/playbooks/library/os_ironic_facts.py b/playbooks/library/os_ironic_facts.py index f1fdc2fed..aeca3454b 100644 --- a/playbooks/library/os_ironic_facts.py +++ b/playbooks/library/os_ironic_facts.py @@ -74,7 +74,7 @@ def _choose_id_value(module): def main(): - argument_spec = openstack_full_argument_spec( + argument_spec = openstack_full_argument_spec( # noqa: F405 auth_type=dict(required=False), uuid=dict(required=False), name=dict(required=False), @@ -82,8 +82,8 @@ def main(): ironic_url=dict(required=False), skip_items=dict(required=False, type='list'), ) - module_kwargs = openstack_module_kwargs() - module = AnsibleModule(argument_spec, **module_kwargs) + module_kwargs = openstack_module_kwargs() # noqa: F405 + module = AnsibleModule(argument_spec, **module_kwargs) # noqa: F405 if not HAS_SHADE: 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 -from ansible.module_utils.basic import * -from ansible.module_utils.openstack import * +from ansible.module_utils.basic import * # noqa: E402 +from ansible.module_utils.openstack import * # noqa: E402 main() diff --git a/test-requirements.txt b/test-requirements.txt index 47a5b158a..3edfb0505 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,7 +2,7 @@ # of appearance. Changing the order has an impact on the overall integration # 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 doc8>=0.6.0 # Apache-2.0 diff --git a/tox.ini b/tox.ini index ea6307ce4..3ef55c0e7 100644 --- a/tox.ini +++ b/tox.ini @@ -59,7 +59,7 @@ commands = oslo_debug_helper -t bifrost/tests {posargs} [flake8] show-source = True -ignore = F403,H102,H303 +ignore = F403,H102,H303,W504 # [H106] Don't put vim configuration in source files. 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