Update flake8 and pyflakes

This commit is contained in:
Brian May 2022-08-05 08:00:56 +10:00
parent 58d72a93d2
commit f8086dfa59
7 changed files with 30 additions and 30 deletions

View File

@ -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

View File

@ -123,14 +123,14 @@ class MultiListener:
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)
@ -145,7 +145,7 @@ class MultiListener:
)
def listen(self, backlog):
assert(self.bind_called)
assert self.bind_called
if self.v6:
self.v6.listen(backlog)
if self.v4:
@ -160,7 +160,7 @@ class MultiListener:
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)
@ -189,7 +189,7 @@ class MultiListener:
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))
@ -374,8 +374,8 @@ class FirewallClient:
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()
@ -973,7 +973,7 @@ def main(listenip_v6, listenip_v4,
raise e
if not bound:
assert(last_e)
assert last_e
raise last_e
tcp_listener.listen(10)
tcp_listener.print_listening("TCP redirector")
@ -1019,7 +1019,7 @@ def main(listenip_v6, listenip_v4,
dns_listener.print_listening("DNS")
if not bound:
assert(last_e)
assert last_e
raise last_e
else:
dnsport_v6 = 0

View File

@ -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))

View File

@ -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()
@ -74,7 +74,7 @@ _changedctls = []
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)

View File

@ -127,7 +127,7 @@ class Method(BaseMethod):
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

View File

@ -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'))
@ -380,7 +380,7 @@ def main(latency_control, latency_buffer_size, auto_hosts, to_nameserver,
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(

View File

@ -227,7 +227,7 @@ class SockWrapper:
return 0
def write(self, buf):
assert(buf)
assert buf
return self.uwrite(buf)
def uread(self):
@ -402,15 +402,15 @@ class Mux(Handler):
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:
@ -482,8 +482,8 @@ class Mux(Handler):
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]