Skip to content

Commit

Permalink
Update flake8 and pyflakes
Browse files Browse the repository at this point in the history
  • Loading branch information
brianmay committed Aug 4, 2022
1 parent 58d72a9 commit f8086df
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions requirements-tests.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-r requirements.txt
pytest==7.1.2
pytest-cov==3.0.0
flake8==4.0.1
pyflakes==2.4.0
flake8==5.0.4
pyflakes==2.5.0
18 changes: 9 additions & 9 deletions sshuttle/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ def __init__(self, kind=socket.SOCK_STREAM, proto=0):
self.bind_called = False

def setsockopt(self, level, optname, value):
assert(self.bind_called)
assert self.bind_called
if self.v6:
self.v6.setsockopt(level, optname, value)
if self.v4:
self.v4.setsockopt(level, optname, value)

def add_handler(self, handlers, callback, method, mux):
assert(self.bind_called)
assert self.bind_called
socks = []
if self.v6:
socks.append(self.v6)
Expand All @@ -145,7 +145,7 @@ def add_handler(self, handlers, callback, method, mux):
)

def listen(self, backlog):
assert(self.bind_called)
assert self.bind_called
if self.v6:
self.v6.listen(backlog)
if self.v4:
Expand All @@ -160,7 +160,7 @@ def listen(self, backlog):
raise e

def bind(self, address_v6, address_v4):
assert(not self.bind_called)
assert not self.bind_called
self.bind_called = True
if address_v6 is not None:
self.v6 = socket.socket(socket.AF_INET6, self.type, self.proto)
Expand Down Expand Up @@ -189,7 +189,7 @@ def bind(self, address_v6, address_v4):
self.v4 = None

def print_listening(self, what):
assert(self.bind_called)
assert self.bind_called
if self.v6:
listenip = self.v6.getsockname()
debug1('%s listening on %r.' % (what, listenip))
Expand Down Expand Up @@ -374,8 +374,8 @@ def start(self):
raise Fatal('%r expected STARTED, got %r' % (self.argv, line))

def sethostip(self, hostname, ip):
assert(not re.search(br'[^-\w\.]', hostname))
assert(not re.search(br'[^0-9.]', ip))
assert not re.search(br'[^-\w\.]', hostname)
assert not re.search(br'[^0-9.]', ip)
self.pfile.write(b'HOST %s,%s\n' % (hostname, ip))
self.pfile.flush()

Expand Down Expand Up @@ -973,7 +973,7 @@ def feature_status(label, enabled, available):
raise e

if not bound:
assert(last_e)
assert last_e
raise last_e
tcp_listener.listen(10)
tcp_listener.print_listening("TCP redirector")
Expand Down Expand Up @@ -1019,7 +1019,7 @@ def feature_status(label, enabled, available):

dns_listener.print_listening("DNS")
if not bound:
assert(last_e)
assert last_e
raise last_e
else:
dnsport_v6 = 0
Expand Down
16 changes: 8 additions & 8 deletions sshuttle/firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,14 @@ def main(method_name, syslog):
dnsport_v6 = int(ports[2])
dnsport_v4 = int(ports[3])

assert(port_v6 >= 0)
assert(port_v6 <= 65535)
assert(port_v4 >= 0)
assert(port_v4 <= 65535)
assert(dnsport_v6 >= 0)
assert(dnsport_v6 <= 65535)
assert(dnsport_v4 >= 0)
assert(dnsport_v4 <= 65535)
assert port_v6 >= 0
assert port_v6 <= 65535
assert port_v4 >= 0
assert port_v4 <= 65535
assert dnsport_v6 >= 0
assert dnsport_v6 <= 65535
assert dnsport_v4 >= 0
assert dnsport_v4 <= 65535

debug2('Got ports: %d,%d,%d,%d'
% (port_v6, port_v4, dnsport_v6, dnsport_v4))
Expand Down
4 changes: 2 additions & 2 deletions sshuttle/methods/ipfw.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _fill_oldctls(prefix):
p = ssubprocess.Popen(argv, stdout=ssubprocess.PIPE, env=get_env())
for line in p.stdout:
line = line.decode()
assert(line[-1] == '\n')
assert line[-1] == '\n'
(k, v) = line[:-1].split(': ', 1)
_oldctls[k] = v.strip()
rv = p.wait()
Expand All @@ -74,7 +74,7 @@ def _sysctl_set(name, val):

def sysctl_set(name, val, permanent=False):
PREFIX = 'net.inet.ip'
assert(name.startswith(PREFIX + '.'))
assert name.startswith(PREFIX + '.')
val = str(val)
if not _oldctls:
_fill_oldctls(PREFIX)
Expand Down
2 changes: 1 addition & 1 deletion sshuttle/methods/tproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def _ipt(*args):

def _ipt_proto_ports(proto, fport, lport):
return proto + ('--dport', '%d:%d' % (fport, lport)) \
if fport else proto
if fport else proto

mark_chain = 'sshuttle-m-%s' % port
tproxy_chain = 'sshuttle-t-%s' % port
Expand Down
4 changes: 2 additions & 2 deletions sshuttle/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def main(latency_control, latency_buffer_size, auto_hosts, to_nameserver,
hw.leftover = b('')

def hostwatch_ready(sock):
assert(hw.pid)
assert hw.pid
content = hw.sock.recv(4096)
if content:
lines = (hw.leftover + content).split(b('\n'))
Expand Down Expand Up @@ -380,7 +380,7 @@ def udp_open(channel, data):

while mux.ok:
if hw.pid:
assert(hw.pid > 0)
assert hw.pid > 0
(rpid, rv) = os.waitpid(hw.pid, os.WNOHANG)
if rpid:
raise Fatal(
Expand Down
12 changes: 6 additions & 6 deletions sshuttle/ssnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def uwrite(self, buf):
return 0

def write(self, buf):
assert(buf)
assert buf
return self.uwrite(buf)

def uread(self):
Expand Down Expand Up @@ -402,15 +402,15 @@ def got_packet(self, channel, cmd, data):
elif cmd == CMD_EXIT:
self.ok = False
elif cmd == CMD_TCP_CONNECT:
assert(not self.channels.get(channel))
assert not self.channels.get(channel)
if self.new_channel:
self.new_channel(channel, data)
elif cmd == CMD_DNS_REQ:
assert(not self.channels.get(channel))
assert not self.channels.get(channel)
if self.got_dns_req:
self.got_dns_req(channel, data)
elif cmd == CMD_UDP_OPEN:
assert(not self.channels.get(channel))
assert not self.channels.get(channel)
if self.got_udp_open:
self.got_udp_open(channel, data)
elif cmd == CMD_ROUTES:
Expand Down Expand Up @@ -482,8 +482,8 @@ def handle(self):
if len(self.inbuf) >= (self.want or HDR_LEN):
(s1, s2, channel, cmd, datalen) = \
struct.unpack('!ccHHH', self.inbuf[:HDR_LEN])
assert(s1 == b('S'))
assert(s2 == b('S'))
assert s1 == b('S')
assert s2 == b('S')
self.want = datalen + HDR_LEN
if self.want and len(self.inbuf) >= self.want:
data = self.inbuf[HDR_LEN:self.want]
Expand Down

0 comments on commit f8086df

Please sign in to comment.