From b032e29b649e5d4dc7248ea7fe1e69432501a3f2 Mon Sep 17 00:00:00 2001
From: garciadeblas <gerardo.garciadeblas@telefonica.com>
Date: Thu, 21 Dec 2023 16:28:15 +0100
Subject: [PATCH] Pin flake8 version in tox.ini to 6.1.0

Change-Id: I8b16a5b5bb7f037bc627613303344d51ba6b5672
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
---
 .../osm_rosdn_floodlightof/floodlight_of.py   | 11 ++++-----
 .../osm_rosdn_onosof/onos_of.py               |  4 ++--
 .../osm_rovim_vmware/vimconn_vmware.py        |  2 +-
 .../pin_flake8_version-6816c0e2c7231066.yaml  | 23 +++++++++++++++++++
 tox.ini                                       |  2 +-
 5 files changed, 32 insertions(+), 10 deletions(-)
 create mode 100644 releasenotes/notes/pin_flake8_version-6816c0e2c7231066.yaml

diff --git a/RO-SDN-floodlight_openflow/osm_rosdn_floodlightof/floodlight_of.py b/RO-SDN-floodlight_openflow/osm_rosdn_floodlightof/floodlight_of.py
index c5fec1a1..43b3a302 100644
--- a/RO-SDN-floodlight_openflow/osm_rosdn_floodlightof/floodlight_of.py
+++ b/RO-SDN-floodlight_openflow/osm_rosdn_floodlightof/floodlight_of.py
@@ -241,7 +241,7 @@ class OfConnFloodLight(OpenflowConn):
             self.logger.debug("get_of_rules " + error_text)
             info = of_response.json()
 
-            if type(info) != dict:
+            if not info.isinstance(dict):
                 self.logger.error(
                     "get_of_rules. Unexpected response not a dict %s", str(type(info))
                 )
@@ -445,7 +445,7 @@ class OfConnFloodLight(OpenflowConn):
                     self.logger.debug("obtain_port_correspondence " + error_text)
                     info = of_response.json()
 
-                    if type(info) != dict:
+                    if not info.isinstance(dict):
                         raise OpenflowConnUnexpectedResponse(
                             "unexpected openflow port-desc response, "
                             "not a dict. Wrong version?"
@@ -457,10 +457,9 @@ class OfConnFloodLight(OpenflowConn):
                             "'portDesc' not found. Wrong version?"
                         )
 
-                    if (
-                        type(info["portDesc"]) != list
-                        and type(info["portDesc"]) != tuple
-                    ):
+                    if not info["portDesc"].isinstance(list) and not info[
+                        "portDesc"
+                    ].isinstance(tuple):
                         raise OpenflowConnUnexpectedResponse(
                             "unexpected openflow port-desc response at "
                             "'portDesc', not a list. Wrong version?"
diff --git a/RO-SDN-onos_openflow/osm_rosdn_onosof/onos_of.py b/RO-SDN-onos_openflow/osm_rosdn_onosof/onos_of.py
index 34359ae0..be8fa7d5 100644
--- a/RO-SDN-onos_openflow/osm_rosdn_onosof/onos_of.py
+++ b/RO-SDN-onos_openflow/osm_rosdn_onosof/onos_of.py
@@ -128,7 +128,7 @@ class OfConnOnos(OpenflowConn):
             self.logger.debug("get_of_switches " + error_text)
             info = of_response.json()
 
-            if type(info) != dict:
+            if not info.isinstance(dict):
                 self.logger.error(
                     "get_of_switches. Unexpected response, not a dict: %s", str(info)
                 )
@@ -312,7 +312,7 @@ class OfConnOnos(OpenflowConn):
 
             info = of_response.json()
 
-            if type(info) != dict:
+            if not info.isinstance(dict):
                 self.logger.error(
                     "get_of_rules. Unexpected response, not a dict: %s",
                     str(info),
diff --git a/RO-VIM-vmware/osm_rovim_vmware/vimconn_vmware.py b/RO-VIM-vmware/osm_rovim_vmware/vimconn_vmware.py
index 9ad628bf..68527470 100644
--- a/RO-VIM-vmware/osm_rovim_vmware/vimconn_vmware.py
+++ b/RO-VIM-vmware/osm_rovim_vmware/vimconn_vmware.py
@@ -6330,7 +6330,7 @@ class vimconnector(vimconn.VimConnector):
                         ].spec.ip.ipAddress
 
                         for device in vm_obj.config.hardware.device:
-                            if type(device) == vim.vm.device.VirtualPCIPassthrough:
+                            if device.isinstance(vim.vm.device.VirtualPCIPassthrough):
                                 device_details = {
                                     "devide_id": device.backing.id,
                                     "pciSlotNumber": device.slotInfo.pciSlotNumber,
diff --git a/releasenotes/notes/pin_flake8_version-6816c0e2c7231066.yaml b/releasenotes/notes/pin_flake8_version-6816c0e2c7231066.yaml
new file mode 100644
index 00000000..ea239dff
--- /dev/null
+++ b/releasenotes/notes/pin_flake8_version-6816c0e2c7231066.yaml
@@ -0,0 +1,23 @@
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#######################################################################################
+---
+other:
+  - |
+    This change pins flake8 version in tox.ini to 6.1.0. In addition, all the flake8
+    issues have been properly fixed. All fixes are related to comparisons done with
+    == or != instead of using the keyword isinstance.
+
diff --git a/tox.ini b/tox.ini
index f2d96922..41a09995 100644
--- a/tox.ini
+++ b/tox.ini
@@ -138,7 +138,7 @@ commands =
 #######################################################################################
 [testenv:flake8]
 deps =
-        flake8
+        flake8==6.1.0
         flake8-import-order
 skip_install = true
 commands =
-- 
GitLab