diff --git a/cloudinit/net/eni.py b/cloudinit/net/eni.py index 92aa83defeb..8c5963181fd 100644 --- a/cloudinit/net/eni.py +++ b/cloudinit/net/eni.py @@ -81,7 +81,7 @@ def _iface_add_subnet(iface, subnet): if key == "address": value = "%s/%s" % (subnet["address"], subnet["prefix"]) if value and key in valid_map: - if type(value) == list: + if isinstance(value, list): value = " ".join(value) if "_" in key: key = key.replace("_", "-") @@ -126,7 +126,7 @@ def _iface_add_attrs(iface, index, ipv4_subnet_mtu): for key, value in iface.items(): # convert bool to string for eni - if type(value) == bool: + if isinstance(value, bool): value = "on" if iface[key] else "off" if not value or key in ignore_map: continue @@ -144,7 +144,7 @@ def _iface_add_attrs(iface, index, ipv4_subnet_mtu): for v in value: content.append(" {0} {1}".format(renames.get(key, key), v)) continue - if type(value) == list: + if isinstance(value, list): value = " ".join(value) content.append(" {0} {1}".format(renames.get(key, key), value)) diff --git a/cloudinit/net/network_state.py b/cloudinit/net/network_state.py index 751c99855d4..d4db7454834 100644 --- a/cloudinit/net/network_state.py +++ b/cloudinit/net/network_state.py @@ -552,7 +552,7 @@ def handle_bridge(self, command): # convert value to boolean bridge_stp = iface.get("bridge_stp") - if bridge_stp is not None and type(bridge_stp) != bool: + if bridge_stp is not None and not isinstance(bridge_stp, bool): if bridge_stp in ["on", "1", 1]: bridge_stp = True elif bridge_stp in ["off", "0", 0]: @@ -575,7 +575,7 @@ def _parse_dns(self, command): search = [] if "address" in command: addrs = command["address"] - if not type(addrs) == list: + if not isinstance(addrs, list): addrs = [addrs] for addr in addrs: nameservers.append(addr) diff --git a/cloudinit/sources/helpers/netlink.py b/cloudinit/sources/helpers/netlink.py index 2953e85859d..68c7a10905c 100644 --- a/cloudinit/sources/helpers/netlink.py +++ b/cloudinit/sources/helpers/netlink.py @@ -137,7 +137,7 @@ def unpack_rta_attr(data, offset): :raises: AssertionError if data is None or offset is not integer. """ assert data is not None, "data is none" - assert type(offset) == int, "offset is not integer" + assert isinstance(offset, int), "offset is not integer" assert ( offset >= RTATTR_START_OFFSET ), "rta offset is less than expected length"