Skip to content

Commit 03e6d24

Browse files
Prevent false positive linter warning in BSDSocket._iter_sockets()
Change logic to prevent: testinfra/modules/socket.py:347:26: E0606: Possibly using variable 'protocol' before assignment (possibly-used-before-assignment)
1 parent dca7b05 commit 03e6d24

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

testinfra/modules/socket.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def _iter_sockets(self, listening):
325325
splitted = line.split()
326326
# FreeBSD: tcp4/tcp6
327327
# OpeNBSD/NetBSD: tcp/tcp6
328-
if splitted[0] in ("tcp", "udp", "udp4", "tcp4", "tcp6", "udp6"):
328+
if splitted[0] in ("tcp", "tcp4", "tcp6", "udp", "udp4", "udp6"):
329329
address = splitted[3]
330330
if address == "*.*":
331331
# On OpenBSD 6.3 (issue #338)
@@ -339,7 +339,7 @@ def _iter_sockets(self, listening):
339339
host = "::" if splitted[0] in ("udp6", "tcp6") else "0.0.0.0"
340340
if splitted[0] in ("udp", "udp6", "udp4"):
341341
protocol = "udp"
342-
elif splitted[0] in ("tcp", "tcp6", "tcp4"):
342+
else:
343343
protocol = "tcp"
344344

345345
remote = splitted[4]

0 commit comments

Comments
 (0)