Skip to content

Commit

Permalink
Flake8 fixes (#4340)
Browse files Browse the repository at this point in the history
Address complaints by newer versions of flake8, these are not picked up by ruff
  • Loading branch information
rjschwei authored Aug 14, 2023
1 parent 11a4fd1 commit b1f4a27
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions cloudinit/net/eni.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("_", "-")
Expand Down Expand Up @@ -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
Expand All @@ -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))

Expand Down
4 changes: 2 additions & 2 deletions cloudinit/net/network_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/sources/helpers/netlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit b1f4a27

Please sign in to comment.