diff --git a/bin/wsdump.py b/bin/wsdump.py index ea6bbb2..d395419 100755 --- a/bin/wsdump.py +++ b/bin/wsdump.py @@ -63,7 +63,7 @@ def parse_args(): return parser.parse_args() -class RawInput(): +class RawInput: def raw_input(self, prompt): if six.PY3: line = input(prompt) @@ -103,16 +103,16 @@ def main(): if args.verbose > 1: websocket.enableTrace(True) options = {} - if (args.proxy): + if args.proxy: p = urlparse(args.proxy) options["http_proxy_host"] = p.hostname options["http_proxy_port"] = p.port - if (args.origin): + if args.origin: options["origin"] = args.origin - if (args.subprotocols): + if args.subprotocols: options["subprotocols"] = args.subprotocols opts = {} - if (args.nocert): + if args.nocert: opts = { "cert_reqs": websocket.ssl.CERT_NONE, "check_hostname": False } ws = websocket.create_connection(args.url, sslopt=opts, **options) if args.raw: @@ -125,14 +125,14 @@ def main(): try: frame = ws.recv_frame() except websocket.WebSocketException: - return (websocket.ABNF.OPCODE_CLOSE, None) + return websocket.ABNF.OPCODE_CLOSE, None if not frame: raise websocket.WebSocketException("Not a valid frame %s" % frame) elif frame.opcode in OPCODE_DATA: - return (frame.opcode, frame.data) + return frame.opcode, frame.data elif frame.opcode == websocket.ABNF.OPCODE_CLOSE: ws.send_close() - return (frame.opcode, None) + return frame.opcode, None elif frame.opcode == websocket.ABNF.OPCODE_PING: ws.pong(frame.data) return frame.opcode, frame.data @@ -152,7 +152,7 @@ def main(): msg = "%s: %s" % (websocket.ABNF.OPCODE_MAP.get(opcode), data) if msg is not None: - if (args.timings): + if args.timings: console.write(str(time.time() - start_time) + ": " + msg) else: console.write(msg) diff --git a/websocket/_core.py b/websocket/_core.py index 13f7593..7527dbf 100644 --- a/websocket/_core.py +++ b/websocket/_core.py @@ -339,17 +339,17 @@ class WebSocket(object): elif frame.opcode == ABNF.OPCODE_CLOSE: self.send_close() - return (frame.opcode, frame) + return frame.opcode, frame elif frame.opcode == ABNF.OPCODE_PING: if len(frame.data) < 126: self.pong(frame.data) else: raise WebSocketProtocolException("Ping message is too long") if control_frame: - return (frame.opcode, frame) + return frame.opcode, frame elif frame.opcode == ABNF.OPCODE_PONG: if control_frame: - return (frame.opcode, frame) + return frame.opcode, frame def recv_frame(self): """ diff --git a/websocket/_url.py b/websocket/_url.py index dfd2c4b..9d705fd 100644 --- a/websocket/_url.py +++ b/websocket/_url.py @@ -66,7 +66,7 @@ def parse_url(url): if parsed.query: resource += "?" + parsed.query - return (hostname, port, resource, is_secure) + return hostname, port, resource, is_secure DEFAULT_NO_PROXY_HOST = ["localhost", "127.0.0.1"] diff --git a/websocket/_utils.py b/websocket/_utils.py index 58f6950..91be861 100644 --- a/websocket/_utils.py +++ b/websocket/_utils.py @@ -69,7 +69,7 @@ except ImportError: def _decode(state, codep, ch): tp = _UTF8D[ch] - codep = (ch & 0x3f ) | (codep << 6) if (state != _UTF8_ACCEPT) else (0xff >> tp) & (ch) + codep = (ch & 0x3f ) | (codep << 6) if (state != _UTF8_ACCEPT) else (0xff >> tp) & ch state = _UTF8D[256 + state + tp] return state, codep;