From fb22f2ff4f75783ba786935c93b75f372ede21f5 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Mon, 17 Oct 2016 17:11:21 +1300 Subject: [PATCH 1/3] Zap object base class --- examples/mitmproxywrapper.py | 2 +- examples/tls_passthrough.py | 2 +- mitmproxy/addons.py | 2 +- mitmproxy/builtins/dumper.py | 2 +- mitmproxy/builtins/serverplayback.py | 2 +- mitmproxy/console/grideditor/base.py | 2 +- mitmproxy/console/grideditor/col_text.py | 5 +++-- mitmproxy/contentviews.py | 2 +- mitmproxy/controller.py | 10 +++++----- mitmproxy/flow/modules.py | 2 +- mitmproxy/flow/state.py | 2 +- mitmproxy/flowfilter.py | 2 +- mitmproxy/optmanager.py | 2 +- mitmproxy/platform/linux.py | 2 +- mitmproxy/platform/osx.py | 2 +- mitmproxy/platform/windows.py | 4 ++-- mitmproxy/protocol/base.py | 4 ++-- mitmproxy/protocol/http.py | 2 +- mitmproxy/protocol/tls.py | 2 +- mitmproxy/proxy/config.py | 2 +- mitmproxy/proxy/root_context.py | 2 +- mitmproxy/proxy/server.py | 2 +- mitmproxy/web/app.py | 2 +- netlib/certutils.py | 4 ++-- netlib/exceptions.py | 2 +- netlib/http/authentication.py | 4 ++-- netlib/http/message.py | 2 +- netlib/socks.py | 10 +++++----- netlib/tcp.py | 10 +++++----- netlib/tutils.py | 2 +- netlib/utils.py | 4 ++-- netlib/websockets/frame.py | 4 ++-- netlib/websockets/masker.py | 2 +- netlib/wsgi.py | 8 ++++---- pathod/language/base.py | 4 ++-- pathod/language/generators.py | 6 +++--- pathod/language/http.py | 2 +- pathod/language/http2.py | 2 +- pathod/language/message.py | 2 +- pathod/log.py | 2 +- pathod/pathoc.py | 2 +- pathod/pathod.py | 2 +- pathod/protocols/http.py | 2 +- pathod/protocols/http2.py | 6 +++--- pathod/utils.py | 2 +- test/mitmproxy/protocol/test_http1.py | 2 +- test/mitmproxy/protocol/test_http2.py | 2 +- test/mitmproxy/protocol/test_websockets.py | 2 +- test/mitmproxy/test_controller.py | 10 +++++----- test/mitmproxy/test_flow.py | 2 +- test/mitmproxy/test_proxy.py | 2 +- test/mitmproxy/tservers.py | 2 +- test/netlib/http/http1/test_read.py | 4 ++-- test/netlib/http/test_headers.py | 2 +- test/netlib/http/test_message.py | 8 ++++---- test/netlib/http/test_request.py | 6 +++--- test/netlib/http/test_response.py | 6 +++--- test/netlib/test_multidict.py | 10 +++++----- test/netlib/tservers.py | 2 +- test/netlib/websockets/test_frame.py | 4 ++-- test/netlib/websockets/test_masker.py | 2 +- test/netlib/websockets/test_utils.py | 2 +- test/pathod/test_pathod.py | 2 +- test/pathod/test_protocols_http2.py | 12 ++++++------ test/pathod/tutils.py | 2 +- 65 files changed, 115 insertions(+), 114 deletions(-) diff --git a/examples/mitmproxywrapper.py b/examples/mitmproxywrapper.py index 6841d05f3..a3d831acd 100644 --- a/examples/mitmproxywrapper.py +++ b/examples/mitmproxywrapper.py @@ -15,7 +15,7 @@ import os import sys -class Wrapper(object): +class Wrapper(): def __init__(self, port, extra_arguments=None): self.port = port self.extra_arguments = extra_arguments diff --git a/examples/tls_passthrough.py b/examples/tls_passthrough.py index 20e8f9bec..eaf780268 100644 --- a/examples/tls_passthrough.py +++ b/examples/tls_passthrough.py @@ -38,7 +38,7 @@ class InterceptionResult(Enum): skipped = None -class _TlsStrategy(object): +class _TlsStrategy(): """ Abstract base class for interception strategies. """ diff --git a/mitmproxy/addons.py b/mitmproxy/addons.py index b575b6071..1d4f38351 100644 --- a/mitmproxy/addons.py +++ b/mitmproxy/addons.py @@ -7,7 +7,7 @@ def _get_name(itm): return getattr(itm, "name", itm.__class__.__name__.lower()) -class Addons(object): +class Addons(): def __init__(self, master): self.chain = [] self.master = master diff --git a/mitmproxy/builtins/dumper.py b/mitmproxy/builtins/dumper.py index 109059b85..e5d6e04d8 100644 --- a/mitmproxy/builtins/dumper.py +++ b/mitmproxy/builtins/dumper.py @@ -20,7 +20,7 @@ def indent(n, text): return "\n".join(pad + i for i in l) -class Dumper(object): +class Dumper(): def __init__(self): self.filter = None # type: flowfilter.TFilter self.flow_detail = None # type: int diff --git a/mitmproxy/builtins/serverplayback.py b/mitmproxy/builtins/serverplayback.py index b495bc27e..5ace1afe3 100644 --- a/mitmproxy/builtins/serverplayback.py +++ b/mitmproxy/builtins/serverplayback.py @@ -6,7 +6,7 @@ from netlib import strutils from mitmproxy import exceptions, flow, ctx -class ServerPlayback(object): +class ServerPlayback(): def __init__(self): self.options = None diff --git a/mitmproxy/console/grideditor/base.py b/mitmproxy/console/grideditor/base.py index de1c0cf6f..ecbbd0f9e 100644 --- a/mitmproxy/console/grideditor/base.py +++ b/mitmproxy/console/grideditor/base.py @@ -35,7 +35,7 @@ class Cell(urwid.WidgetWrap): return True -class Column(object, metaclass=abc.ABCMeta): +class Column(metaclass=abc.ABCMeta): subeditor = None def __init__(self, heading): diff --git a/mitmproxy/console/grideditor/col_text.py b/mitmproxy/console/grideditor/col_text.py index 29c1abacc..d94e41f98 100644 --- a/mitmproxy/console/grideditor/col_text.py +++ b/mitmproxy/console/grideditor/col_text.py @@ -26,8 +26,9 @@ class Column(col_bytes.Column): # This is the same for both edit and display. -class EncodingMixin(object): - def __init__(self, data: str, encoding_args): +class EncodingMixin(): + def __init__(self, data, encoding_args): + # type: (str) -> TDisplay self.encoding_args = encoding_args data = data.encode(*self.encoding_args) super(EncodingMixin, self).__init__(data) diff --git a/mitmproxy/contentviews.py b/mitmproxy/contentviews.py index 24c4d3964..38f6c094e 100644 --- a/mitmproxy/contentviews.py +++ b/mitmproxy/contentviews.py @@ -93,7 +93,7 @@ def format_text(text): yield [("text", line)] -class View(object): +class View(): name = None prompt = () content_types = [] diff --git a/mitmproxy/controller.py b/mitmproxy/controller.py index 579cf92dc..397c906d8 100644 --- a/mitmproxy/controller.py +++ b/mitmproxy/controller.py @@ -41,13 +41,13 @@ Events = frozenset([ ]) -class LogEntry(object): +class LogEntry(): def __init__(self, msg, level): self.msg = msg self.level = level -class Log(object): +class Log(): """ The central logger, exposed to scripts as mitmproxy.ctx.log. """ @@ -82,7 +82,7 @@ class Log(object): self.master.add_log(text, level) -class Master(object): +class Master(): """ The master handles mitmproxy's main event loop. """ @@ -185,7 +185,7 @@ class ServerThread(basethread.BaseThread): self.server.serve_forever() -class Channel(object): +class Channel(): """ The only way for the proxy server to communicate with the master is to use the channel it has been given. @@ -272,7 +272,7 @@ def handler(f): NO_REPLY = object() # special object we can distinguish from a valid "None" reply. -class Reply(object): +class Reply(): """ Messages sent through a channel are decorated with a "reply" attribute. This object is used to respond to the message through the return diff --git a/mitmproxy/flow/modules.py b/mitmproxy/flow/modules.py index 7d8a282eb..40c5a3a59 100644 --- a/mitmproxy/flow/modules.py +++ b/mitmproxy/flow/modules.py @@ -32,7 +32,7 @@ class AppRegistry: return self.apps.get((host, request.port), None) -class StreamLargeBodies(object): +class StreamLargeBodies(): def __init__(self, max_size): self.max_size = max_size diff --git a/mitmproxy/flow/state.py b/mitmproxy/flow/state.py index f6395c79d..5f8e94043 100644 --- a/mitmproxy/flow/state.py +++ b/mitmproxy/flow/state.py @@ -177,7 +177,7 @@ class FlowStore(FlowList): f.kill(master) -class State(object): +class State(): def __init__(self): self.flows = FlowStore() self.view = FlowView(self.flows, None) diff --git a/mitmproxy/flowfilter.py b/mitmproxy/flowfilter.py index cdbaf3161..fca81c9bf 100644 --- a/mitmproxy/flowfilter.py +++ b/mitmproxy/flowfilter.py @@ -58,7 +58,7 @@ def only(*types): return decorator -class _Token(object): +class _Token(): def dump(self, indent=0, fp=sys.stdout): print("{spacing}{name}{expr}".format( diff --git a/mitmproxy/optmanager.py b/mitmproxy/optmanager.py index 92d32b2d4..7b9a22ae9 100644 --- a/mitmproxy/optmanager.py +++ b/mitmproxy/optmanager.py @@ -11,7 +11,7 @@ from mitmproxy import exceptions """ -class OptManager(object): +class OptManager(): """ .changed is a blinker Signal that triggers whenever options are updated. If any handler in the chain raises an exceptions.OptionsError diff --git a/mitmproxy/platform/linux.py b/mitmproxy/platform/linux.py index 38bfbe42d..4c206a50f 100644 --- a/mitmproxy/platform/linux.py +++ b/mitmproxy/platform/linux.py @@ -5,7 +5,7 @@ import struct SO_ORIGINAL_DST = 80 -class Resolver(object): +class Resolver(): def original_addr(self, csock): odestdata = csock.getsockopt(socket.SOL_IP, SO_ORIGINAL_DST, 16) diff --git a/mitmproxy/platform/osx.py b/mitmproxy/platform/osx.py index 6a555f32e..97b74a12e 100644 --- a/mitmproxy/platform/osx.py +++ b/mitmproxy/platform/osx.py @@ -15,7 +15,7 @@ from . import pf """ -class Resolver(object): +class Resolver(): STATECMD = ("sudo", "-n", "/sbin/pfctl", "-s", "state") def original_addr(self, csock): diff --git a/mitmproxy/platform/windows.py b/mitmproxy/platform/windows.py index 54d29c72d..e1d2ef7ca 100644 --- a/mitmproxy/platform/windows.py +++ b/mitmproxy/platform/windows.py @@ -16,7 +16,7 @@ import socketserver PROXY_API_PORT = 8085 -class Resolver(object): +class Resolver(): def __init__(self): TransparentProxy.setup() @@ -111,7 +111,7 @@ def MIB_TCPTABLE2(size): return _MIB_TCPTABLE2() -class TransparentProxy(object): +class TransparentProxy(): """ Transparent Windows Proxy for mitmproxy based on WinDivert/PyDivert. diff --git a/mitmproxy/protocol/base.py b/mitmproxy/protocol/base.py index b280ec35a..d635e4f75 100644 --- a/mitmproxy/protocol/base.py +++ b/mitmproxy/protocol/base.py @@ -5,7 +5,7 @@ from mitmproxy import exceptions from mitmproxy import models -class _LayerCodeCompletion(object): +class _LayerCodeCompletion(): """ Dummy class that provides type hinting in PyCharm, which simplifies development a lot. @@ -88,7 +88,7 @@ class Layer(_LayerCodeCompletion): return type(self).__name__ -class ServerConnectionMixin(object): +class ServerConnectionMixin(): """ Mixin that provides a layer with the capabilities to manage a server connection. diff --git a/mitmproxy/protocol/http.py b/mitmproxy/protocol/http.py index 54b611993..49faee29b 100644 --- a/mitmproxy/protocol/http.py +++ b/mitmproxy/protocol/http.py @@ -61,7 +61,7 @@ class _HttpTransmissionLayer(base.Layer): raise NotImplementedError() -class ConnectServerConnection(object): +class ConnectServerConnection(): """ "Fake" ServerConnection to represent state after a CONNECT request to an upstream proxy. diff --git a/mitmproxy/protocol/tls.py b/mitmproxy/protocol/tls.py index 203d9c297..3e1659a16 100644 --- a/mitmproxy/protocol/tls.py +++ b/mitmproxy/protocol/tls.py @@ -248,7 +248,7 @@ def get_client_hello(client_conn): return client_hello -class TlsClientHello(object): +class TlsClientHello(): def __init__(self, raw_client_hello): self._client_hello = _constructs.ClientHello.parse(raw_client_hello) diff --git a/mitmproxy/proxy/config.py b/mitmproxy/proxy/config.py index bd1c3f626..467cbe566 100644 --- a/mitmproxy/proxy/config.py +++ b/mitmproxy/proxy/config.py @@ -20,7 +20,7 @@ from netlib.http import url CONF_BASENAME = "mitmproxy" -class HostMatcher(object): +class HostMatcher(): def __init__(self, patterns=tuple()): self.patterns = list(patterns) diff --git a/mitmproxy/proxy/root_context.py b/mitmproxy/proxy/root_context.py index d3f3c6df8..e6715c66d 100644 --- a/mitmproxy/proxy/root_context.py +++ b/mitmproxy/proxy/root_context.py @@ -7,7 +7,7 @@ from mitmproxy import protocol from mitmproxy.proxy import modes -class RootContext(object): +class RootContext(): """ The outermost context provided to the root layer. diff --git a/mitmproxy/proxy/server.py b/mitmproxy/proxy/server.py index 0fedaa747..4edbe9a09 100644 --- a/mitmproxy/proxy/server.py +++ b/mitmproxy/proxy/server.py @@ -62,7 +62,7 @@ class ProxyServer(tcp.TCPServer): h.handle() -class ConnectionHandler(object): +class ConnectionHandler(): def __init__(self, client_conn, client_address, config, channel): self.config = config diff --git a/mitmproxy/web/app.py b/mitmproxy/web/app.py index ea2203ee3..570a6c56c 100644 --- a/mitmproxy/web/app.py +++ b/mitmproxy/web/app.py @@ -73,7 +73,7 @@ class APIError(tornado.web.HTTPError): pass -class BasicAuth(object): +class BasicAuth(): def set_auth_headers(self): self.set_status(401) diff --git a/netlib/certutils.py b/netlib/certutils.py index 23836cb50..6f834466e 100644 --- a/netlib/certutils.py +++ b/netlib/certutils.py @@ -155,7 +155,7 @@ def dummy_cert(privkey, cacert, commonname, sans): # return current.value -class CertStoreEntry(object): +class CertStoreEntry(): def __init__(self, cert, privatekey, chain_file): self.cert = cert @@ -163,7 +163,7 @@ class CertStoreEntry(object): self.chain_file = chain_file -class CertStore(object): +class CertStore(): """ Implements an in-memory certificate store. diff --git a/netlib/exceptions.py b/netlib/exceptions.py index dec79c22a..2cef77cb0 100644 --- a/netlib/exceptions.py +++ b/netlib/exceptions.py @@ -16,7 +16,7 @@ class NetlibException(Exception): super(NetlibException, self).__init__(message) -class Disconnect(object): +class Disconnect(): """Immediate EOF""" diff --git a/netlib/http/authentication.py b/netlib/http/authentication.py index 58fc9bdcb..ea24f7544 100644 --- a/netlib/http/authentication.py +++ b/netlib/http/authentication.py @@ -23,7 +23,7 @@ def assemble_http_basic_auth(scheme, username, password): return scheme + " " + v -class NullProxyAuth(object): +class NullProxyAuth(): """ No proxy auth at all (returns empty challange headers) @@ -90,7 +90,7 @@ class BasicProxyAuth(BasicAuth): AUTH_HEADER = 'Proxy-Authorization' -class PassMan(object): +class PassMan(): def test(self, username_, password_token_): return False diff --git a/netlib/http/message.py b/netlib/http/message.py index e44faf185..9927daeeb 100644 --- a/netlib/http/message.py +++ b/netlib/http/message.py @@ -283,7 +283,7 @@ class Message(basetypes.Serializable): self.content = body -class decoded(object): +class decoded(): """ Deprecated: You can now directly use :py:attr:`content`. :py:attr:`raw_content` has the encoded content. diff --git a/netlib/socks.py b/netlib/socks.py index 8d7c5279f..41fde1cc9 100644 --- a/netlib/socks.py +++ b/netlib/socks.py @@ -52,7 +52,7 @@ USERNAME_PASSWORD_VERSION = utils.BiDi( ) -class ClientGreeting(object): +class ClientGreeting(): __slots__ = ("ver", "methods") def __init__(self, ver, methods): @@ -89,7 +89,7 @@ class ClientGreeting(object): f.write(self.methods.tostring()) -class ServerGreeting(object): +class ServerGreeting(): __slots__ = ("ver", "method") def __init__(self, ver, method): @@ -117,7 +117,7 @@ class ServerGreeting(object): f.write(struct.pack("!BB", self.ver, self.method)) -class UsernamePasswordAuth(object): +class UsernamePasswordAuth(): __slots__ = ("ver", "username", "password") def __init__(self, ver, username, password): @@ -147,7 +147,7 @@ class UsernamePasswordAuth(object): f.write(self.password.encode()) -class UsernamePasswordAuthResponse(object): +class UsernamePasswordAuthResponse(): __slots__ = ("ver", "status") def __init__(self, ver, status): @@ -170,7 +170,7 @@ class UsernamePasswordAuthResponse(object): f.write(struct.pack("!BB", self.ver, self.status)) -class Message(object): +class Message(): __slots__ = ("ver", "msg", "atyp", "addr") def __init__(self, ver, msg, atyp, addr): diff --git a/netlib/tcp.py b/netlib/tcp.py index e4e134c44..a0e0b69d5 100644 --- a/netlib/tcp.py +++ b/netlib/tcp.py @@ -72,7 +72,7 @@ sslversion_choices = { } -class SSLKeyLogger(object): +class SSLKeyLogger(): def __init__(self, filename): self.filename = filename @@ -111,7 +111,7 @@ log_ssl_key = SSLKeyLogger.create_logfun( os.getenv("MITMPROXY_SSLKEYLOGFILE") or os.getenv("SSLKEYLOGFILE")) -class _FileLike(object): +class _FileLike(): BLOCKSIZE = 1024 * 32 def __init__(self, o): @@ -426,7 +426,7 @@ def close_socket(sock): sock.close() -class _Connection(object): +class _Connection(): rbufsize = -1 wbufsize = -1 @@ -574,7 +574,7 @@ class _Connection(object): return context -class ConnectionCloser(object): +class ConnectionCloser(): def __init__(self, conn): self.conn = conn self._canceled = False @@ -888,7 +888,7 @@ class Counter: self._count -= 1 -class TCPServer(object): +class TCPServer(): request_queue_size = 20 def __init__(self, address): diff --git a/netlib/tutils.py b/netlib/tutils.py index 5f598fa96..3fbe58b98 100644 --- a/netlib/tutils.py +++ b/netlib/tutils.py @@ -72,7 +72,7 @@ def raises(expected_exception, obj=None, *args, **kwargs): raise AssertionError("No exception raised. Return value: {}".format(ret)) -class RaisesContext(object): +class RaisesContext(): def __init__(self, expected_exception): self.expected_exception = expected_exception diff --git a/netlib/utils.py b/netlib/utils.py index 8a8b15ea5..190dda833 100644 --- a/netlib/utils.py +++ b/netlib/utils.py @@ -20,7 +20,7 @@ def getbit(byte, offset): return bool(byte & mask) -class BiDi(object): +class BiDi(): """ A wee utility class for keeping bi-directional mappings, like field @@ -49,7 +49,7 @@ class BiDi(object): return self.values.get(n, default) -class Data(object): +class Data(): def __init__(self, name): m = importlib.import_module(name) diff --git a/netlib/websockets/frame.py b/netlib/websockets/frame.py index 2b36d461d..e2ff89066 100644 --- a/netlib/websockets/frame.py +++ b/netlib/websockets/frame.py @@ -43,7 +43,7 @@ CLOSE_REASON = utils.BiDi( ) -class FrameHeader(object): +class FrameHeader(): def __init__( self, @@ -193,7 +193,7 @@ class FrameHeader(object): return False -class Frame(object): +class Frame(): """ Represents a single WebSockets frame. Constructor takes human readable forms of the frame components. diff --git a/netlib/websockets/masker.py b/netlib/websockets/masker.py index 03b8f4353..66407df64 100644 --- a/netlib/websockets/masker.py +++ b/netlib/websockets/masker.py @@ -1,7 +1,7 @@ from __future__ import absolute_import -class Masker(object): +class Masker(): """ Data sent from the server must be masked to prevent malicious clients from sending data over the wire in predictable patterns. diff --git a/netlib/wsgi.py b/netlib/wsgi.py index 17cbbf00e..86b5ce40d 100644 --- a/netlib/wsgi.py +++ b/netlib/wsgi.py @@ -8,20 +8,20 @@ import io from netlib import http, tcp, strutils -class ClientConn(object): +class ClientConn(): def __init__(self, address): self.address = tcp.Address.wrap(address) -class Flow(object): +class Flow(): def __init__(self, address, request): self.client_conn = ClientConn(address) self.request = request -class Request(object): +class Request(): def __init__(self, scheme, method, path, http_version, headers, content): self.scheme, self.method, self.path = scheme, method, path @@ -47,7 +47,7 @@ def date_time_string(): return s -class WSGIAdaptor(object): +class WSGIAdaptor(): def __init__(self, app, domain, port, sversion): self.app, self.domain, self.port, self.sversion = app, domain, port, sversion diff --git a/pathod/language/base.py b/pathod/language/base.py index bdcc6d2fa..4483c3df1 100644 --- a/pathod/language/base.py +++ b/pathod/language/base.py @@ -10,7 +10,7 @@ from netlib import human from . import generators, exceptions -class Settings(object): +class Settings(): def __init__( self, @@ -60,7 +60,7 @@ v_naked_literal = pp.MatchFirst( ) -class Token(object): +class Token(): """ A token in the specification language. Tokens are immutable. The token diff --git a/pathod/language/generators.py b/pathod/language/generators.py index 4040e099f..6a543907b 100644 --- a/pathod/language/generators.py +++ b/pathod/language/generators.py @@ -18,7 +18,7 @@ DATATYPES = dict( ) -class TransformGenerator(object): +class TransformGenerator(): """ Perform a byte-by-byte transform another generator - that is, for each @@ -54,7 +54,7 @@ def rand_byte(chars): return bytes([random.choice(chars)]) -class RandomGenerator(object): +class RandomGenerator(): def __init__(self, dtype, length): self.dtype = dtype @@ -73,7 +73,7 @@ class RandomGenerator(object): return "%s random from %s" % (self.length, self.dtype) -class FileGenerator(object): +class FileGenerator(): def __init__(self, path): self.path = path diff --git a/pathod/language/http.py b/pathod/language/http.py index 46027ca35..1f1a3db38 100644 --- a/pathod/language/http.py +++ b/pathod/language/http.py @@ -53,7 +53,7 @@ class Method(base.OptionsOrValue): ] -class _HeaderMixin(object): +class _HeaderMixin(): unique_name = None def format_header(self, key, value): diff --git a/pathod/language/http2.py b/pathod/language/http2.py index 519ee6999..7cb829169 100644 --- a/pathod/language/http2.py +++ b/pathod/language/http2.py @@ -40,7 +40,7 @@ def get_header(val, headers): return None -class _HeaderMixin(object): +class _HeaderMixin(): unique_name = None def values(self, settings): diff --git a/pathod/language/message.py b/pathod/language/message.py index fea4f4de3..7a8594d6d 100644 --- a/pathod/language/message.py +++ b/pathod/language/message.py @@ -5,7 +5,7 @@ from netlib import strutils LOG_TRUNCATE = 1024 -class Message(object): +class Message(): __metaclass__ = abc.ABCMeta logattrs = [] diff --git a/pathod/log.py b/pathod/log.py index 1a709dc60..05934fd33 100644 --- a/pathod/log.py +++ b/pathod/log.py @@ -13,7 +13,7 @@ def write_raw(fp, lines, timestamp=True): fp.flush() -class LogCtx(object): +class LogCtx(): def __init__(self, fp, hex, timestamp, rfile, wfile): self.lines = [] diff --git a/pathod/pathoc.py b/pathod/pathoc.py index f122c14f8..008308ca7 100644 --- a/pathod/pathoc.py +++ b/pathod/pathoc.py @@ -34,7 +34,7 @@ class PathocError(Exception): pass -class SSLInfo(object): +class SSLInfo(): def __init__(self, certchain, cipher, alp): self.certchain, self.cipher, self.alp = certchain, cipher, alp diff --git a/pathod/pathod.py b/pathod/pathod.py index e882b73ef..f67ad04eb 100644 --- a/pathod/pathod.py +++ b/pathod/pathod.py @@ -30,7 +30,7 @@ class PathodError(Exception): pass -class SSLOptions(object): +class SSLOptions(): def __init__( self, confdir=CONFDIR, diff --git a/pathod/protocols/http.py b/pathod/protocols/http.py index 2ede25911..5ac8516fa 100644 --- a/pathod/protocols/http.py +++ b/pathod/protocols/http.py @@ -4,7 +4,7 @@ from netlib.http import http1 from .. import language -class HTTPProtocol(object): +class HTTPProtocol(): def __init__(self, pathod_handler): self.pathod_handler = pathod_handler diff --git a/pathod/protocols/http2.py b/pathod/protocols/http2.py index 78fe61118..42f1a1a0c 100644 --- a/pathod/protocols/http2.py +++ b/pathod/protocols/http2.py @@ -15,14 +15,14 @@ import netlib.http.request from .. import language -class TCPHandler(object): +class TCPHandler(): def __init__(self, rfile, wfile=None): self.rfile = rfile self.wfile = wfile -class HTTP2StateProtocol(object): +class HTTP2StateProtocol(): ERROR_CODES = utils.BiDi( NO_ERROR=0x0, @@ -403,7 +403,7 @@ class HTTP2StateProtocol(object): return stream_id, headers, body -class HTTP2Protocol(object): +class HTTP2Protocol(): def __init__(self, pathod_handler): self.pathod_handler = pathod_handler diff --git a/pathod/utils.py b/pathod/utils.py index 9b220e9af..07b6933e7 100644 --- a/pathod/utils.py +++ b/pathod/utils.py @@ -3,7 +3,7 @@ import sys import netlib.utils -class MemBool(object): +class MemBool(): """ Truth-checking with a memory, for use in chained if statements. diff --git a/test/mitmproxy/protocol/test_http1.py b/test/mitmproxy/protocol/test_http1.py index 2fc4ac635..3bf1210ee 100644 --- a/test/mitmproxy/protocol/test_http1.py +++ b/test/mitmproxy/protocol/test_http1.py @@ -6,7 +6,7 @@ from netlib.tutils import treq from .. import tutils, tservers -class TestHTTPFlow(object): +class TestHTTPFlow(): def test_repr(self): f = tutils.tflow(resp=True, err=True) diff --git a/test/mitmproxy/protocol/test_http2.py b/test/mitmproxy/protocol/test_http2.py index c4bd20495..c0f7007d4 100644 --- a/test/mitmproxy/protocol/test_http2.py +++ b/test/mitmproxy/protocol/test_http2.py @@ -89,7 +89,7 @@ class _Http2ServerBase(netlib_tservers.ServerTestBase): raise NotImplementedError() -class _Http2TestBase(object): +class _Http2TestBase(): @classmethod def setup_class(cls): diff --git a/test/mitmproxy/protocol/test_websockets.py b/test/mitmproxy/protocol/test_websockets.py index e2361d899..f7756f25a 100644 --- a/test/mitmproxy/protocol/test_websockets.py +++ b/test/mitmproxy/protocol/test_websockets.py @@ -44,7 +44,7 @@ class _WebSocketsServerBase(netlib_tservers.ServerTestBase): traceback.print_exc() -class _WebSocketsTestBase(object): +class _WebSocketsTestBase(): @classmethod def setup_class(cls): diff --git a/test/mitmproxy/test_controller.py b/test/mitmproxy/test_controller.py index 660ce1118..bd3dfe4ee 100644 --- a/test/mitmproxy/test_controller.py +++ b/test/mitmproxy/test_controller.py @@ -15,7 +15,7 @@ class TMsg: pass -class TestMaster(object): +class TestMaster(): def test_simple(self): class DummyMaster(controller.Master): @controller.handler @@ -44,7 +44,7 @@ class TestMaster(object): m.shutdown() -class TestServerThread(object): +class TestServerThread(): def test_simple(self): m = Mock() t = controller.ServerThread(m) @@ -52,7 +52,7 @@ class TestServerThread(object): assert m.serve_forever.called -class TestChannel(object): +class TestChannel(): def test_tell(self): q = queue.Queue() channel = controller.Channel(q, Event()) @@ -86,7 +86,7 @@ class TestChannel(object): channel.ask("test", Mock(name="test_ask_shutdown")) -class TestReply(object): +class TestReply(): def test_simple(self): reply = controller.Reply(42) assert reply.state == "unhandled" @@ -179,7 +179,7 @@ class TestReply(object): reply.commit() -class TestDummyReply(object): +class TestDummyReply(): def test_simple(self): reply = controller.DummyReply() for _ in range(2): diff --git a/test/mitmproxy/test_flow.py b/test/mitmproxy/test_flow.py index cc9d26919..b4052c622 100644 --- a/test/mitmproxy/test_flow.py +++ b/test/mitmproxy/test_flow.py @@ -37,7 +37,7 @@ def test_app_registry(): assert ar.get(r) -class TestHTTPFlow(object): +class TestHTTPFlow(): def test_copy(self): f = tutils.tflow(resp=True) diff --git a/test/mitmproxy/test_proxy.py b/test/mitmproxy/test_proxy.py index f7c64e506..48bb94ca1 100644 --- a/test/mitmproxy/test_proxy.py +++ b/test/mitmproxy/test_proxy.py @@ -14,7 +14,7 @@ from netlib.http import http1 from . import tutils -class TestServerConnection(object): +class TestServerConnection(): def test_simple(self): self.d = test.Daemon() diff --git a/test/mitmproxy/tservers.py b/test/mitmproxy/tservers.py index d3806a997..e597570e7 100644 --- a/test/mitmproxy/tservers.py +++ b/test/mitmproxy/tservers.py @@ -74,7 +74,7 @@ class ProxyThread(threading.Thread): self.tmaster.shutdown() -class ProxyTestBase(object): +class ProxyTestBase(): # Test Configuration ssl = None ssloptions = False diff --git a/test/netlib/http/http1/test_read.py b/test/netlib/http/http1/test_read.py index 44eff2eed..fb27857b9 100644 --- a/test/netlib/http/http1/test_read.py +++ b/test/netlib/http/http1/test_read.py @@ -104,7 +104,7 @@ def test_read_response_head(): assert rfile.read() == b"skip" -class TestReadBody(object): +class TestReadBody(): def test_chunked(self): rfile = BytesIO(b"3\r\nfoo\r\n0\r\n\r\nbar") body = b"".join(read_body(rfile, None)) @@ -289,7 +289,7 @@ def test_check_http_version(): _check_http_version(b"HTTP/1.b") -class TestReadHeaders(object): +class TestReadHeaders(): @staticmethod def _read(data): return _read_headers(BytesIO(data)) diff --git a/test/netlib/http/test_headers.py b/test/netlib/http/test_headers.py index e8752c52f..d214ca026 100644 --- a/test/netlib/http/test_headers.py +++ b/test/netlib/http/test_headers.py @@ -4,7 +4,7 @@ from netlib.http.headers import Headers, parse_content_type, assemble_content_ty from netlib.tutils import raises -class TestHeaders(object): +class TestHeaders(): def _2host(self): return Headers( ( diff --git a/test/netlib/http/test_message.py b/test/netlib/http/test_message.py index 5d533ad77..9a5b80eda 100644 --- a/test/netlib/http/test_message.py +++ b/test/netlib/http/test_message.py @@ -36,7 +36,7 @@ def _test_decoded_attr(message, attr): assert getattr(message.data, attr) == b"FOO\xBF\x00BAR" -class TestMessageData(object): +class TestMessageData(): def test_eq_ne(self): data = tresp(timestamp_start=42, timestamp_end=42).data same = tresp(timestamp_start=42, timestamp_end=42).data @@ -50,7 +50,7 @@ class TestMessageData(object): assert data != 0 -class TestMessage(object): +class TestMessage(): def test_init(self): resp = tresp() @@ -108,7 +108,7 @@ class TestMessage(object): assert r.content == b"ggfootoo" -class TestMessageContentEncoding(object): +class TestMessageContentEncoding(): def test_simple(self): r = tresp() assert r.raw_content == b"message" @@ -186,7 +186,7 @@ class TestMessageContentEncoding(object): assert "content-encoding" not in r.headers -class TestMessageText(object): +class TestMessageText(): def test_simple(self): r = tresp(content=b'\xfc') assert r.raw_content == b"\xfc" diff --git a/test/netlib/http/test_request.py b/test/netlib/http/test_request.py index 1f01d29d0..bcb1cc43b 100644 --- a/test/netlib/http/test_request.py +++ b/test/netlib/http/test_request.py @@ -6,7 +6,7 @@ from netlib.tutils import treq, raises from .test_message import _test_decoded_attr, _test_passthrough_attr -class TestRequestData(object): +class TestRequestData(): def test_init(self): with raises(ValueError): treq(headers="foobar") @@ -14,7 +14,7 @@ class TestRequestData(object): assert isinstance(treq(headers=()).headers, Headers) -class TestRequestCore(object): +class TestRequestCore(): """ Tests for builtins and the attributes that are directly proxied from the data structure """ @@ -92,7 +92,7 @@ class TestRequestCore(object): assert request.headers["Host"] == "example.org" -class TestRequestUtils(object): +class TestRequestUtils(): """ Tests for additional convenience methods. """ diff --git a/test/netlib/http/test_response.py b/test/netlib/http/test_response.py index e97cc419a..6ab043c19 100644 --- a/test/netlib/http/test_response.py +++ b/test/netlib/http/test_response.py @@ -11,7 +11,7 @@ from netlib.tutils import raises, tresp from .test_message import _test_passthrough_attr, _test_decoded_attr -class TestResponseData(object): +class TestResponseData(): def test_init(self): with raises(ValueError): tresp(headers="foobar") @@ -19,7 +19,7 @@ class TestResponseData(object): assert isinstance(tresp(headers=()).headers, Headers) -class TestResponseCore(object): +class TestResponseCore(): """ Tests for builtins and the attributes that are directly proxied from the data structure """ @@ -60,7 +60,7 @@ class TestResponseCore(object): _test_decoded_attr(tresp(), "reason") -class TestResponseUtils(object): +class TestResponseUtils(): """ Tests for additional convenience methods. """ diff --git a/test/netlib/test_multidict.py b/test/netlib/test_multidict.py index 58ae0f98a..bad5e2b4b 100644 --- a/test/netlib/test_multidict.py +++ b/test/netlib/test_multidict.py @@ -2,7 +2,7 @@ from netlib import tutils from netlib.multidict import MultiDict, ImmutableMultiDict, MultiDictView -class _TMulti(object): +class _TMulti(): @staticmethod def _kconv(key): return key.lower() @@ -16,7 +16,7 @@ class TImmutableMultiDict(_TMulti, ImmutableMultiDict): pass -class TestMultiDict(object): +class TestMultiDict(): @staticmethod def _multi(): return TMultiDict(( @@ -194,7 +194,7 @@ class TestMultiDict(object): assert md == md2 -class TestImmutableMultiDict(object): +class TestImmutableMultiDict(): def test_modify(self): md = TImmutableMultiDict() with tutils.raises(TypeError): @@ -224,7 +224,7 @@ class TestImmutableMultiDict(object): assert md.with_insert(0, "foo", "bar").fields == (("foo", "bar"),) -class TParent(object): +class TParent(): def __init__(self): self.vals = tuple() @@ -235,7 +235,7 @@ class TParent(object): return self.vals -class TestMultiDictView(object): +class TestMultiDictView(): def test_modify(self): p = TParent() tv = MultiDictView(p.getter, p.setter) diff --git a/test/netlib/tservers.py b/test/netlib/tservers.py index 10a6f70a5..d22be413f 100644 --- a/test/netlib/tservers.py +++ b/test/netlib/tservers.py @@ -85,7 +85,7 @@ class _TServer(tcp.TCPServer): self.q.put(s.getvalue()) -class ServerTestBase(object): +class ServerTestBase(): ssl = None handler = None addr = ("localhost", 0) diff --git a/test/netlib/websockets/test_frame.py b/test/netlib/websockets/test_frame.py index cce394546..265d2513f 100644 --- a/test/netlib/websockets/test_frame.py +++ b/test/netlib/websockets/test_frame.py @@ -6,7 +6,7 @@ from netlib import websockets from netlib import tutils -class TestFrameHeader(object): +class TestFrameHeader(): @pytest.mark.parametrize("input,expected", [ (0, '0100'), @@ -123,7 +123,7 @@ class TestFrameHeader(object): assert f.masking_key -class TestFrame(object): +class TestFrame(): def test_equality(self): f = websockets.Frame(payload=b'1234') f2 = websockets.Frame(payload=b'1234') diff --git a/test/netlib/websockets/test_masker.py b/test/netlib/websockets/test_masker.py index 528fce716..a06fd0795 100644 --- a/test/netlib/websockets/test_masker.py +++ b/test/netlib/websockets/test_masker.py @@ -4,7 +4,7 @@ import pytest from netlib import websockets -class TestMasker(object): +class TestMasker(): @pytest.mark.parametrize("input,expected", [ ([b"a"], '00'), diff --git a/test/netlib/websockets/test_utils.py b/test/netlib/websockets/test_utils.py index 34765e04e..7e3f02f9c 100644 --- a/test/netlib/websockets/test_utils.py +++ b/test/netlib/websockets/test_utils.py @@ -4,7 +4,7 @@ from netlib import http from netlib import websockets -class TestUtils(object): +class TestUtils(): def test_client_handshake_headers(self): h = websockets.client_handshake_headers(version='42') diff --git a/test/pathod/test_pathod.py b/test/pathod/test_pathod.py index d119348aa..69b7a6042 100644 --- a/test/pathod/test_pathod.py +++ b/test/pathod/test_pathod.py @@ -7,7 +7,7 @@ from netlib.exceptions import HttpException, TlsException from . import tutils -class TestPathod(object): +class TestPathod(): def test_logging(self): s = io.StringIO() diff --git a/test/pathod/test_protocols_http2.py b/test/pathod/test_protocols_http2.py index 7f65c0eb8..243539275 100644 --- a/test/pathod/test_protocols_http2.py +++ b/test/pathod/test_protocols_http2.py @@ -169,7 +169,7 @@ class TestPerformClientConnectionPreface(netlib_tservers.ServerTestBase): assert protocol.connection_preface_performed -class TestClientStreamIds(object): +class TestClientStreamIds(): c = tcp.TCPClient(("127.0.0.1", 0)) protocol = HTTP2StateProtocol(c) @@ -183,7 +183,7 @@ class TestClientStreamIds(object): assert self.protocol.current_stream_id == 5 -class TestserverstreamIds(object): +class TestserverstreamIds(): c = tcp.TCPClient(("127.0.0.1", 0)) protocol = HTTP2StateProtocol(c, is_server=True) @@ -230,7 +230,7 @@ class TestApplySettings(netlib_tservers.ServerTestBase): hyperframe.frame.SettingsFrame.INITIAL_WINDOW_SIZE] == 'deadbeef' -class TestCreateHeaders(object): +class TestCreateHeaders(): c = tcp.TCPClient(("127.0.0.1", 0)) def test_create_headers(self): @@ -267,7 +267,7 @@ class TestCreateHeaders(object): assert bytes[2] == codecs.decode('00000209040000000163d5', 'hex_codec') -class TestCreateBody(object): +class TestCreateBody(): c = tcp.TCPClient(("127.0.0.1", 0)) def test_create_body_empty(self): @@ -422,7 +422,7 @@ class TestReadEmptyResponse(netlib_tservers.ServerTestBase): assert resp.content == b'' -class TestAssembleRequest(object): +class TestAssembleRequest(): c = tcp.TCPClient(("127.0.0.1", 0)) def test_request_simple(self): @@ -476,7 +476,7 @@ class TestAssembleRequest(object): codecs.decode('000006000100000001666f6f626172', 'hex_codec') -class TestAssembleResponse(object): +class TestAssembleResponse(): c = tcp.TCPClient(("127.0.0.1", 0)) def test_simple(self): diff --git a/test/pathod/tutils.py b/test/pathod/tutils.py index 518485ba1..6ebf25a8b 100644 --- a/test/pathod/tutils.py +++ b/test/pathod/tutils.py @@ -23,7 +23,7 @@ def treader(bytes): return tcp.Reader(fp) -class DaemonTests(object): +class DaemonTests(): nohang = False ssl = False timeout = None From a647b30365593a4a3056fcf6936f5441ab9eda88 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Mon, 17 Oct 2016 17:29:45 +1300 Subject: [PATCH 2/3] python3: clean up class brackets --- examples/mitmproxywrapper.py | 2 +- examples/tls_passthrough.py | 2 +- mitmproxy/addons.py | 2 +- mitmproxy/builtins/dumper.py | 2 +- mitmproxy/builtins/script.py | 2 +- mitmproxy/builtins/serverplayback.py | 2 +- mitmproxy/console/grideditor/col_text.py | 2 +- mitmproxy/contentviews.py | 2 +- mitmproxy/controller.py | 10 +++++----- mitmproxy/flow/modules.py | 2 +- mitmproxy/flow/state.py | 2 +- mitmproxy/flowfilter.py | 2 +- mitmproxy/optmanager.py | 2 +- mitmproxy/platform/linux.py | 2 +- mitmproxy/platform/osx.py | 2 +- mitmproxy/platform/windows.py | 4 ++-- mitmproxy/protocol/base.py | 4 ++-- mitmproxy/protocol/http.py | 2 +- mitmproxy/protocol/tls.py | 2 +- mitmproxy/proxy/config.py | 2 +- mitmproxy/proxy/root_context.py | 2 +- mitmproxy/proxy/server.py | 2 +- mitmproxy/web/app.py | 2 +- netlib/certutils.py | 4 ++-- netlib/exceptions.py | 2 +- netlib/http/authentication.py | 4 ++-- netlib/http/message.py | 2 +- netlib/socks.py | 10 +++++----- netlib/tcp.py | 10 +++++----- netlib/tutils.py | 2 +- netlib/utils.py | 4 ++-- netlib/websockets/frame.py | 4 ++-- netlib/websockets/masker.py | 2 +- netlib/wsgi.py | 8 ++++---- pathod/language/base.py | 4 ++-- pathod/language/generators.py | 6 +++--- pathod/language/http.py | 2 +- pathod/language/http2.py | 2 +- pathod/language/message.py | 2 +- pathod/log.py | 2 +- pathod/pathoc.py | 2 +- pathod/pathod.py | 2 +- pathod/protocols/http.py | 2 +- pathod/protocols/http2.py | 6 +++--- pathod/utils.py | 2 +- test/mitmproxy/console/test_pathedit.py | 2 +- test/mitmproxy/protocol/test_http1.py | 2 +- test/mitmproxy/protocol/test_http2.py | 2 +- test/mitmproxy/protocol/test_websockets.py | 2 +- test/mitmproxy/test_controller.py | 10 +++++----- test/mitmproxy/test_examples.py | 2 +- test/mitmproxy/test_flow.py | 2 +- test/mitmproxy/test_flow_export.py | 12 ++++++------ test/mitmproxy/test_proxy.py | 2 +- test/mitmproxy/tservers.py | 2 +- test/netlib/http/http1/test_read.py | 4 ++-- test/netlib/http/test_headers.py | 2 +- test/netlib/http/test_message.py | 8 ++++---- test/netlib/http/test_request.py | 6 +++--- test/netlib/http/test_response.py | 6 +++--- test/netlib/test_multidict.py | 10 +++++----- test/netlib/tservers.py | 2 +- test/netlib/websockets/test_frame.py | 4 ++-- test/netlib/websockets/test_masker.py | 2 +- test/netlib/websockets/test_utils.py | 2 +- test/pathod/test_language_base.py | 2 +- test/pathod/test_pathod.py | 2 +- test/pathod/test_protocols_http2.py | 12 ++++++------ test/pathod/tutils.py | 2 +- 69 files changed, 122 insertions(+), 122 deletions(-) diff --git a/examples/mitmproxywrapper.py b/examples/mitmproxywrapper.py index a3d831acd..eade0fe2f 100644 --- a/examples/mitmproxywrapper.py +++ b/examples/mitmproxywrapper.py @@ -15,7 +15,7 @@ import os import sys -class Wrapper(): +class Wrapper: def __init__(self, port, extra_arguments=None): self.port = port self.extra_arguments = extra_arguments diff --git a/examples/tls_passthrough.py b/examples/tls_passthrough.py index eaf780268..79d5fa001 100644 --- a/examples/tls_passthrough.py +++ b/examples/tls_passthrough.py @@ -38,7 +38,7 @@ class InterceptionResult(Enum): skipped = None -class _TlsStrategy(): +class _TlsStrategy: """ Abstract base class for interception strategies. """ diff --git a/mitmproxy/addons.py b/mitmproxy/addons.py index 1d4f38351..1802da684 100644 --- a/mitmproxy/addons.py +++ b/mitmproxy/addons.py @@ -7,7 +7,7 @@ def _get_name(itm): return getattr(itm, "name", itm.__class__.__name__.lower()) -class Addons(): +class Addons: def __init__(self, master): self.chain = [] self.master = master diff --git a/mitmproxy/builtins/dumper.py b/mitmproxy/builtins/dumper.py index e5d6e04d8..ecaa05ec3 100644 --- a/mitmproxy/builtins/dumper.py +++ b/mitmproxy/builtins/dumper.py @@ -20,7 +20,7 @@ def indent(n, text): return "\n".join(pad + i for i in l) -class Dumper(): +class Dumper: def __init__(self): self.filter = None # type: flowfilter.TFilter self.flow_detail = None # type: int diff --git a/mitmproxy/builtins/script.py b/mitmproxy/builtins/script.py index 9bf25703e..a77ca32a7 100644 --- a/mitmproxy/builtins/script.py +++ b/mitmproxy/builtins/script.py @@ -215,7 +215,7 @@ class Script: self.dead = True -class ScriptLoader(): +class ScriptLoader: """ An addon that manages loading scripts from options. """ diff --git a/mitmproxy/builtins/serverplayback.py b/mitmproxy/builtins/serverplayback.py index 5ace1afe3..9d551511c 100644 --- a/mitmproxy/builtins/serverplayback.py +++ b/mitmproxy/builtins/serverplayback.py @@ -6,7 +6,7 @@ from netlib import strutils from mitmproxy import exceptions, flow, ctx -class ServerPlayback(): +class ServerPlayback: def __init__(self): self.options = None diff --git a/mitmproxy/console/grideditor/col_text.py b/mitmproxy/console/grideditor/col_text.py index d94e41f98..9962c7b17 100644 --- a/mitmproxy/console/grideditor/col_text.py +++ b/mitmproxy/console/grideditor/col_text.py @@ -26,7 +26,7 @@ class Column(col_bytes.Column): # This is the same for both edit and display. -class EncodingMixin(): +class EncodingMixin: def __init__(self, data, encoding_args): # type: (str) -> TDisplay self.encoding_args = encoding_args diff --git a/mitmproxy/contentviews.py b/mitmproxy/contentviews.py index 38f6c094e..8569067f8 100644 --- a/mitmproxy/contentviews.py +++ b/mitmproxy/contentviews.py @@ -93,7 +93,7 @@ def format_text(text): yield [("text", line)] -class View(): +class View: name = None prompt = () content_types = [] diff --git a/mitmproxy/controller.py b/mitmproxy/controller.py index 397c906d8..09b7abed4 100644 --- a/mitmproxy/controller.py +++ b/mitmproxy/controller.py @@ -41,13 +41,13 @@ Events = frozenset([ ]) -class LogEntry(): +class LogEntry: def __init__(self, msg, level): self.msg = msg self.level = level -class Log(): +class Log: """ The central logger, exposed to scripts as mitmproxy.ctx.log. """ @@ -82,7 +82,7 @@ class Log(): self.master.add_log(text, level) -class Master(): +class Master: """ The master handles mitmproxy's main event loop. """ @@ -185,7 +185,7 @@ class ServerThread(basethread.BaseThread): self.server.serve_forever() -class Channel(): +class Channel: """ The only way for the proxy server to communicate with the master is to use the channel it has been given. @@ -272,7 +272,7 @@ def handler(f): NO_REPLY = object() # special object we can distinguish from a valid "None" reply. -class Reply(): +class Reply: """ Messages sent through a channel are decorated with a "reply" attribute. This object is used to respond to the message through the return diff --git a/mitmproxy/flow/modules.py b/mitmproxy/flow/modules.py index 40c5a3a59..d6d45ce66 100644 --- a/mitmproxy/flow/modules.py +++ b/mitmproxy/flow/modules.py @@ -32,7 +32,7 @@ class AppRegistry: return self.apps.get((host, request.port), None) -class StreamLargeBodies(): +class StreamLargeBodies: def __init__(self, max_size): self.max_size = max_size diff --git a/mitmproxy/flow/state.py b/mitmproxy/flow/state.py index 5f8e94043..69dcd1d2a 100644 --- a/mitmproxy/flow/state.py +++ b/mitmproxy/flow/state.py @@ -177,7 +177,7 @@ class FlowStore(FlowList): f.kill(master) -class State(): +class State: def __init__(self): self.flows = FlowStore() self.view = FlowView(self.flows, None) diff --git a/mitmproxy/flowfilter.py b/mitmproxy/flowfilter.py index fca81c9bf..64c0a9fc8 100644 --- a/mitmproxy/flowfilter.py +++ b/mitmproxy/flowfilter.py @@ -58,7 +58,7 @@ def only(*types): return decorator -class _Token(): +class _Token: def dump(self, indent=0, fp=sys.stdout): print("{spacing}{name}{expr}".format( diff --git a/mitmproxy/optmanager.py b/mitmproxy/optmanager.py index 7b9a22ae9..c62dc4482 100644 --- a/mitmproxy/optmanager.py +++ b/mitmproxy/optmanager.py @@ -11,7 +11,7 @@ from mitmproxy import exceptions """ -class OptManager(): +class OptManager: """ .changed is a blinker Signal that triggers whenever options are updated. If any handler in the chain raises an exceptions.OptionsError diff --git a/mitmproxy/platform/linux.py b/mitmproxy/platform/linux.py index 4c206a50f..8dfd2f819 100644 --- a/mitmproxy/platform/linux.py +++ b/mitmproxy/platform/linux.py @@ -5,7 +5,7 @@ import struct SO_ORIGINAL_DST = 80 -class Resolver(): +class Resolver: def original_addr(self, csock): odestdata = csock.getsockopt(socket.SOL_IP, SO_ORIGINAL_DST, 16) diff --git a/mitmproxy/platform/osx.py b/mitmproxy/platform/osx.py index 97b74a12e..4b74f62b0 100644 --- a/mitmproxy/platform/osx.py +++ b/mitmproxy/platform/osx.py @@ -15,7 +15,7 @@ from . import pf """ -class Resolver(): +class Resolver: STATECMD = ("sudo", "-n", "/sbin/pfctl", "-s", "state") def original_addr(self, csock): diff --git a/mitmproxy/platform/windows.py b/mitmproxy/platform/windows.py index e1d2ef7ca..01f20dc10 100644 --- a/mitmproxy/platform/windows.py +++ b/mitmproxy/platform/windows.py @@ -16,7 +16,7 @@ import socketserver PROXY_API_PORT = 8085 -class Resolver(): +class Resolver: def __init__(self): TransparentProxy.setup() @@ -111,7 +111,7 @@ def MIB_TCPTABLE2(size): return _MIB_TCPTABLE2() -class TransparentProxy(): +class TransparentProxy: """ Transparent Windows Proxy for mitmproxy based on WinDivert/PyDivert. diff --git a/mitmproxy/protocol/base.py b/mitmproxy/protocol/base.py index d635e4f75..dea6b3d11 100644 --- a/mitmproxy/protocol/base.py +++ b/mitmproxy/protocol/base.py @@ -5,7 +5,7 @@ from mitmproxy import exceptions from mitmproxy import models -class _LayerCodeCompletion(): +class _LayerCodeCompletion: """ Dummy class that provides type hinting in PyCharm, which simplifies development a lot. @@ -88,7 +88,7 @@ class Layer(_LayerCodeCompletion): return type(self).__name__ -class ServerConnectionMixin(): +class ServerConnectionMixin: """ Mixin that provides a layer with the capabilities to manage a server connection. diff --git a/mitmproxy/protocol/http.py b/mitmproxy/protocol/http.py index 49faee29b..3c17670e6 100644 --- a/mitmproxy/protocol/http.py +++ b/mitmproxy/protocol/http.py @@ -61,7 +61,7 @@ class _HttpTransmissionLayer(base.Layer): raise NotImplementedError() -class ConnectServerConnection(): +class ConnectServerConnection: """ "Fake" ServerConnection to represent state after a CONNECT request to an upstream proxy. diff --git a/mitmproxy/protocol/tls.py b/mitmproxy/protocol/tls.py index 3e1659a16..dbc834012 100644 --- a/mitmproxy/protocol/tls.py +++ b/mitmproxy/protocol/tls.py @@ -248,7 +248,7 @@ def get_client_hello(client_conn): return client_hello -class TlsClientHello(): +class TlsClientHello: def __init__(self, raw_client_hello): self._client_hello = _constructs.ClientHello.parse(raw_client_hello) diff --git a/mitmproxy/proxy/config.py b/mitmproxy/proxy/config.py index 467cbe566..e2dc5d262 100644 --- a/mitmproxy/proxy/config.py +++ b/mitmproxy/proxy/config.py @@ -20,7 +20,7 @@ from netlib.http import url CONF_BASENAME = "mitmproxy" -class HostMatcher(): +class HostMatcher: def __init__(self, patterns=tuple()): self.patterns = list(patterns) diff --git a/mitmproxy/proxy/root_context.py b/mitmproxy/proxy/root_context.py index e6715c66d..fe981f500 100644 --- a/mitmproxy/proxy/root_context.py +++ b/mitmproxy/proxy/root_context.py @@ -7,7 +7,7 @@ from mitmproxy import protocol from mitmproxy.proxy import modes -class RootContext(): +class RootContext: """ The outermost context provided to the root layer. diff --git a/mitmproxy/proxy/server.py b/mitmproxy/proxy/server.py index 4edbe9a09..3719ae625 100644 --- a/mitmproxy/proxy/server.py +++ b/mitmproxy/proxy/server.py @@ -62,7 +62,7 @@ class ProxyServer(tcp.TCPServer): h.handle() -class ConnectionHandler(): +class ConnectionHandler: def __init__(self, client_conn, client_address, config, channel): self.config = config diff --git a/mitmproxy/web/app.py b/mitmproxy/web/app.py index 570a6c56c..82ccf3fb5 100644 --- a/mitmproxy/web/app.py +++ b/mitmproxy/web/app.py @@ -73,7 +73,7 @@ class APIError(tornado.web.HTTPError): pass -class BasicAuth(): +class BasicAuth: def set_auth_headers(self): self.set_status(401) diff --git a/netlib/certutils.py b/netlib/certutils.py index 6f834466e..340376d71 100644 --- a/netlib/certutils.py +++ b/netlib/certutils.py @@ -155,7 +155,7 @@ def dummy_cert(privkey, cacert, commonname, sans): # return current.value -class CertStoreEntry(): +class CertStoreEntry: def __init__(self, cert, privatekey, chain_file): self.cert = cert @@ -163,7 +163,7 @@ class CertStoreEntry(): self.chain_file = chain_file -class CertStore(): +class CertStore: """ Implements an in-memory certificate store. diff --git a/netlib/exceptions.py b/netlib/exceptions.py index 2cef77cb0..1787cb727 100644 --- a/netlib/exceptions.py +++ b/netlib/exceptions.py @@ -16,7 +16,7 @@ class NetlibException(Exception): super(NetlibException, self).__init__(message) -class Disconnect(): +class Disconnect: """Immediate EOF""" diff --git a/netlib/http/authentication.py b/netlib/http/authentication.py index ea24f7544..efaa7f532 100644 --- a/netlib/http/authentication.py +++ b/netlib/http/authentication.py @@ -23,7 +23,7 @@ def assemble_http_basic_auth(scheme, username, password): return scheme + " " + v -class NullProxyAuth(): +class NullProxyAuth: """ No proxy auth at all (returns empty challange headers) @@ -90,7 +90,7 @@ class BasicProxyAuth(BasicAuth): AUTH_HEADER = 'Proxy-Authorization' -class PassMan(): +class PassMan: def test(self, username_, password_token_): return False diff --git a/netlib/http/message.py b/netlib/http/message.py index 9927daeeb..e693db1df 100644 --- a/netlib/http/message.py +++ b/netlib/http/message.py @@ -283,7 +283,7 @@ class Message(basetypes.Serializable): self.content = body -class decoded(): +class decoded: """ Deprecated: You can now directly use :py:attr:`content`. :py:attr:`raw_content` has the encoded content. diff --git a/netlib/socks.py b/netlib/socks.py index 41fde1cc9..5b28a8cd0 100644 --- a/netlib/socks.py +++ b/netlib/socks.py @@ -52,7 +52,7 @@ USERNAME_PASSWORD_VERSION = utils.BiDi( ) -class ClientGreeting(): +class ClientGreeting: __slots__ = ("ver", "methods") def __init__(self, ver, methods): @@ -89,7 +89,7 @@ class ClientGreeting(): f.write(self.methods.tostring()) -class ServerGreeting(): +class ServerGreeting: __slots__ = ("ver", "method") def __init__(self, ver, method): @@ -117,7 +117,7 @@ class ServerGreeting(): f.write(struct.pack("!BB", self.ver, self.method)) -class UsernamePasswordAuth(): +class UsernamePasswordAuth: __slots__ = ("ver", "username", "password") def __init__(self, ver, username, password): @@ -147,7 +147,7 @@ class UsernamePasswordAuth(): f.write(self.password.encode()) -class UsernamePasswordAuthResponse(): +class UsernamePasswordAuthResponse: __slots__ = ("ver", "status") def __init__(self, ver, status): @@ -170,7 +170,7 @@ class UsernamePasswordAuthResponse(): f.write(struct.pack("!BB", self.ver, self.status)) -class Message(): +class Message: __slots__ = ("ver", "msg", "atyp", "addr") def __init__(self, ver, msg, atyp, addr): diff --git a/netlib/tcp.py b/netlib/tcp.py index a0e0b69d5..05ceef5a1 100644 --- a/netlib/tcp.py +++ b/netlib/tcp.py @@ -72,7 +72,7 @@ sslversion_choices = { } -class SSLKeyLogger(): +class SSLKeyLogger: def __init__(self, filename): self.filename = filename @@ -111,7 +111,7 @@ log_ssl_key = SSLKeyLogger.create_logfun( os.getenv("MITMPROXY_SSLKEYLOGFILE") or os.getenv("SSLKEYLOGFILE")) -class _FileLike(): +class _FileLike: BLOCKSIZE = 1024 * 32 def __init__(self, o): @@ -426,7 +426,7 @@ def close_socket(sock): sock.close() -class _Connection(): +class _Connection: rbufsize = -1 wbufsize = -1 @@ -574,7 +574,7 @@ class _Connection(): return context -class ConnectionCloser(): +class ConnectionCloser: def __init__(self, conn): self.conn = conn self._canceled = False @@ -888,7 +888,7 @@ class Counter: self._count -= 1 -class TCPServer(): +class TCPServer: request_queue_size = 20 def __init__(self, address): diff --git a/netlib/tutils.py b/netlib/tutils.py index 3fbe58b98..d22fdd1c7 100644 --- a/netlib/tutils.py +++ b/netlib/tutils.py @@ -72,7 +72,7 @@ def raises(expected_exception, obj=None, *args, **kwargs): raise AssertionError("No exception raised. Return value: {}".format(ret)) -class RaisesContext(): +class RaisesContext: def __init__(self, expected_exception): self.expected_exception = expected_exception diff --git a/netlib/utils.py b/netlib/utils.py index 190dda833..1a18dfcd4 100644 --- a/netlib/utils.py +++ b/netlib/utils.py @@ -20,7 +20,7 @@ def getbit(byte, offset): return bool(byte & mask) -class BiDi(): +class BiDi: """ A wee utility class for keeping bi-directional mappings, like field @@ -49,7 +49,7 @@ class BiDi(): return self.values.get(n, default) -class Data(): +class Data: def __init__(self, name): m = importlib.import_module(name) diff --git a/netlib/websockets/frame.py b/netlib/websockets/frame.py index e2ff89066..eb7d9ccdf 100644 --- a/netlib/websockets/frame.py +++ b/netlib/websockets/frame.py @@ -43,7 +43,7 @@ CLOSE_REASON = utils.BiDi( ) -class FrameHeader(): +class FrameHeader: def __init__( self, @@ -193,7 +193,7 @@ class FrameHeader(): return False -class Frame(): +class Frame: """ Represents a single WebSockets frame. Constructor takes human readable forms of the frame components. diff --git a/netlib/websockets/masker.py b/netlib/websockets/masker.py index 66407df64..f4f489a61 100644 --- a/netlib/websockets/masker.py +++ b/netlib/websockets/masker.py @@ -1,7 +1,7 @@ from __future__ import absolute_import -class Masker(): +class Masker: """ Data sent from the server must be masked to prevent malicious clients from sending data over the wire in predictable patterns. diff --git a/netlib/wsgi.py b/netlib/wsgi.py index 86b5ce40d..07e0c9db6 100644 --- a/netlib/wsgi.py +++ b/netlib/wsgi.py @@ -8,20 +8,20 @@ import io from netlib import http, tcp, strutils -class ClientConn(): +class ClientConn: def __init__(self, address): self.address = tcp.Address.wrap(address) -class Flow(): +class Flow: def __init__(self, address, request): self.client_conn = ClientConn(address) self.request = request -class Request(): +class Request: def __init__(self, scheme, method, path, http_version, headers, content): self.scheme, self.method, self.path = scheme, method, path @@ -47,7 +47,7 @@ def date_time_string(): return s -class WSGIAdaptor(): +class WSGIAdaptor: def __init__(self, app, domain, port, sversion): self.app, self.domain, self.port, self.sversion = app, domain, port, sversion diff --git a/pathod/language/base.py b/pathod/language/base.py index 4483c3df1..11f0899d4 100644 --- a/pathod/language/base.py +++ b/pathod/language/base.py @@ -10,7 +10,7 @@ from netlib import human from . import generators, exceptions -class Settings(): +class Settings: def __init__( self, @@ -60,7 +60,7 @@ v_naked_literal = pp.MatchFirst( ) -class Token(): +class Token: """ A token in the specification language. Tokens are immutable. The token diff --git a/pathod/language/generators.py b/pathod/language/generators.py index 6a543907b..4e19ecd91 100644 --- a/pathod/language/generators.py +++ b/pathod/language/generators.py @@ -18,7 +18,7 @@ DATATYPES = dict( ) -class TransformGenerator(): +class TransformGenerator: """ Perform a byte-by-byte transform another generator - that is, for each @@ -54,7 +54,7 @@ def rand_byte(chars): return bytes([random.choice(chars)]) -class RandomGenerator(): +class RandomGenerator: def __init__(self, dtype, length): self.dtype = dtype @@ -73,7 +73,7 @@ class RandomGenerator(): return "%s random from %s" % (self.length, self.dtype) -class FileGenerator(): +class FileGenerator: def __init__(self, path): self.path = path diff --git a/pathod/language/http.py b/pathod/language/http.py index 1f1a3db38..8b5fa8283 100644 --- a/pathod/language/http.py +++ b/pathod/language/http.py @@ -53,7 +53,7 @@ class Method(base.OptionsOrValue): ] -class _HeaderMixin(): +class _HeaderMixin: unique_name = None def format_header(self, key, value): diff --git a/pathod/language/http2.py b/pathod/language/http2.py index 7cb829169..35fc5ba80 100644 --- a/pathod/language/http2.py +++ b/pathod/language/http2.py @@ -40,7 +40,7 @@ def get_header(val, headers): return None -class _HeaderMixin(): +class _HeaderMixin: unique_name = None def values(self, settings): diff --git a/pathod/language/message.py b/pathod/language/message.py index 7a8594d6d..03b4a2cf6 100644 --- a/pathod/language/message.py +++ b/pathod/language/message.py @@ -5,7 +5,7 @@ from netlib import strutils LOG_TRUNCATE = 1024 -class Message(): +class Message: __metaclass__ = abc.ABCMeta logattrs = [] diff --git a/pathod/log.py b/pathod/log.py index 05934fd33..37100bb1d 100644 --- a/pathod/log.py +++ b/pathod/log.py @@ -13,7 +13,7 @@ def write_raw(fp, lines, timestamp=True): fp.flush() -class LogCtx(): +class LogCtx: def __init__(self, fp, hex, timestamp, rfile, wfile): self.lines = [] diff --git a/pathod/pathoc.py b/pathod/pathoc.py index 008308ca7..1f81ed598 100644 --- a/pathod/pathoc.py +++ b/pathod/pathoc.py @@ -34,7 +34,7 @@ class PathocError(Exception): pass -class SSLInfo(): +class SSLInfo: def __init__(self, certchain, cipher, alp): self.certchain, self.cipher, self.alp = certchain, cipher, alp diff --git a/pathod/pathod.py b/pathod/pathod.py index f67ad04eb..fe8635ea8 100644 --- a/pathod/pathod.py +++ b/pathod/pathod.py @@ -30,7 +30,7 @@ class PathodError(Exception): pass -class SSLOptions(): +class SSLOptions: def __init__( self, confdir=CONFDIR, diff --git a/pathod/protocols/http.py b/pathod/protocols/http.py index 5ac8516fa..179303206 100644 --- a/pathod/protocols/http.py +++ b/pathod/protocols/http.py @@ -4,7 +4,7 @@ from netlib.http import http1 from .. import language -class HTTPProtocol(): +class HTTPProtocol: def __init__(self, pathod_handler): self.pathod_handler = pathod_handler diff --git a/pathod/protocols/http2.py b/pathod/protocols/http2.py index 42f1a1a0c..dcd17ebab 100644 --- a/pathod/protocols/http2.py +++ b/pathod/protocols/http2.py @@ -15,14 +15,14 @@ import netlib.http.request from .. import language -class TCPHandler(): +class TCPHandler: def __init__(self, rfile, wfile=None): self.rfile = rfile self.wfile = wfile -class HTTP2StateProtocol(): +class HTTP2StateProtocol: ERROR_CODES = utils.BiDi( NO_ERROR=0x0, @@ -403,7 +403,7 @@ class HTTP2StateProtocol(): return stream_id, headers, body -class HTTP2Protocol(): +class HTTP2Protocol: def __init__(self, pathod_handler): self.pathod_handler = pathod_handler diff --git a/pathod/utils.py b/pathod/utils.py index 07b6933e7..2d077c480 100644 --- a/pathod/utils.py +++ b/pathod/utils.py @@ -3,7 +3,7 @@ import sys import netlib.utils -class MemBool(): +class MemBool: """ Truth-checking with a memory, for use in chained if statements. diff --git a/test/mitmproxy/console/test_pathedit.py b/test/mitmproxy/console/test_pathedit.py index ff6ef8467..45c69a385 100644 --- a/test/mitmproxy/console/test_pathedit.py +++ b/test/mitmproxy/console/test_pathedit.py @@ -51,7 +51,7 @@ class TestPathCompleter: assert c.final == s -class TestPathEdit(): +class TestPathEdit: def test_keypress(self): diff --git a/test/mitmproxy/protocol/test_http1.py b/test/mitmproxy/protocol/test_http1.py index 3bf1210ee..d2c473d73 100644 --- a/test/mitmproxy/protocol/test_http1.py +++ b/test/mitmproxy/protocol/test_http1.py @@ -6,7 +6,7 @@ from netlib.tutils import treq from .. import tutils, tservers -class TestHTTPFlow(): +class TestHTTPFlow: def test_repr(self): f = tutils.tflow(resp=True, err=True) diff --git a/test/mitmproxy/protocol/test_http2.py b/test/mitmproxy/protocol/test_http2.py index c0f7007d4..3a222c109 100644 --- a/test/mitmproxy/protocol/test_http2.py +++ b/test/mitmproxy/protocol/test_http2.py @@ -89,7 +89,7 @@ class _Http2ServerBase(netlib_tservers.ServerTestBase): raise NotImplementedError() -class _Http2TestBase(): +class _Http2TestBase: @classmethod def setup_class(cls): diff --git a/test/mitmproxy/protocol/test_websockets.py b/test/mitmproxy/protocol/test_websockets.py index f7756f25a..094d9298b 100644 --- a/test/mitmproxy/protocol/test_websockets.py +++ b/test/mitmproxy/protocol/test_websockets.py @@ -44,7 +44,7 @@ class _WebSocketsServerBase(netlib_tservers.ServerTestBase): traceback.print_exc() -class _WebSocketsTestBase(): +class _WebSocketsTestBase: @classmethod def setup_class(cls): diff --git a/test/mitmproxy/test_controller.py b/test/mitmproxy/test_controller.py index bd3dfe4ee..84f762e6e 100644 --- a/test/mitmproxy/test_controller.py +++ b/test/mitmproxy/test_controller.py @@ -15,7 +15,7 @@ class TMsg: pass -class TestMaster(): +class TestMaster: def test_simple(self): class DummyMaster(controller.Master): @controller.handler @@ -44,7 +44,7 @@ class TestMaster(): m.shutdown() -class TestServerThread(): +class TestServerThread: def test_simple(self): m = Mock() t = controller.ServerThread(m) @@ -52,7 +52,7 @@ class TestServerThread(): assert m.serve_forever.called -class TestChannel(): +class TestChannel: def test_tell(self): q = queue.Queue() channel = controller.Channel(q, Event()) @@ -86,7 +86,7 @@ class TestChannel(): channel.ask("test", Mock(name="test_ask_shutdown")) -class TestReply(): +class TestReply: def test_simple(self): reply = controller.Reply(42) assert reply.state == "unhandled" @@ -179,7 +179,7 @@ class TestReply(): reply.commit() -class TestDummyReply(): +class TestDummyReply: def test_simple(self): reply = controller.DummyReply() for _ in range(2): diff --git a/test/mitmproxy/test_examples.py b/test/mitmproxy/test_examples.py index 81e8801c9..05b7544f5 100644 --- a/test/mitmproxy/test_examples.py +++ b/test/mitmproxy/test_examples.py @@ -99,7 +99,7 @@ class TestScripts(mastertest.MasterTest): assert f.request.host == "mitmproxy.org" -class TestHARDump(): +class TestHARDump: def flow(self, resp_content=b'message'): times = dict( diff --git a/test/mitmproxy/test_flow.py b/test/mitmproxy/test_flow.py index b4052c622..38d61afe4 100644 --- a/test/mitmproxy/test_flow.py +++ b/test/mitmproxy/test_flow.py @@ -37,7 +37,7 @@ def test_app_registry(): assert ar.get(r) -class TestHTTPFlow(): +class TestHTTPFlow: def test_copy(self): f = tutils.tflow(resp=True) diff --git a/test/mitmproxy/test_flow_export.py b/test/mitmproxy/test_flow_export.py index 86ff937d3..920f538b7 100644 --- a/test/mitmproxy/test_flow_export.py +++ b/test/mitmproxy/test_flow_export.py @@ -31,7 +31,7 @@ def req_patch(): return netlib.tutils.treq(method=b'PATCH', path=b"/path?query=param") -class TestExportCurlCommand(): +class TestExportCurlCommand: def test_get(self): flow = tutils.tflow(req=req_get()) result = """curl -H 'header:qvalue' -H 'content-length:7' 'http://address/path?a=foo&a=bar&b=baz'""" @@ -48,7 +48,7 @@ class TestExportCurlCommand(): assert export.curl_command(flow) == result -class TestExportPythonCode(): +class TestExportPythonCode: def test_get(self): flow = tutils.tflow(req=req_get()) python_equals("data/test_flow_export/python_get.py", export.python_code(flow)) @@ -69,7 +69,7 @@ class TestExportPythonCode(): python_equals("data/test_flow_export/python_patch.py", export.python_code(flow)) -class TestExportLocustCode(): +class TestExportLocustCode: def test_get(self): flow = tutils.tflow(req=req_get()) python_equals("data/test_flow_export/locust_get.py", export.locust_code(flow)) @@ -86,7 +86,7 @@ class TestExportLocustCode(): python_equals("data/test_flow_export/locust_patch.py", export.locust_code(flow)) -class TestExportLocustTask(): +class TestExportLocustTask: def test_get(self): flow = tutils.tflow(req=req_get()) python_equals("data/test_flow_export/locust_task_get.py", export.locust_task(flow)) @@ -100,7 +100,7 @@ class TestExportLocustTask(): python_equals("data/test_flow_export/locust_task_patch.py", export.locust_task(flow)) -class TestIsJson(): +class TestIsJson: def test_empty(self): assert export.is_json(None, None) is False @@ -119,7 +119,7 @@ class TestIsJson(): assert isinstance(j, dict) -class TestURL(): +class TestURL: def test_url(self): flow = tutils.tflow() assert export.url(flow) == "http://address:22/path" diff --git a/test/mitmproxy/test_proxy.py b/test/mitmproxy/test_proxy.py index 48bb94ca1..5904ce5b3 100644 --- a/test/mitmproxy/test_proxy.py +++ b/test/mitmproxy/test_proxy.py @@ -14,7 +14,7 @@ from netlib.http import http1 from . import tutils -class TestServerConnection(): +class TestServerConnection: def test_simple(self): self.d = test.Daemon() diff --git a/test/mitmproxy/tservers.py b/test/mitmproxy/tservers.py index e597570e7..6796e2430 100644 --- a/test/mitmproxy/tservers.py +++ b/test/mitmproxy/tservers.py @@ -74,7 +74,7 @@ class ProxyThread(threading.Thread): self.tmaster.shutdown() -class ProxyTestBase(): +class ProxyTestBase: # Test Configuration ssl = None ssloptions = False diff --git a/test/netlib/http/http1/test_read.py b/test/netlib/http/http1/test_read.py index fb27857b9..a768a722a 100644 --- a/test/netlib/http/http1/test_read.py +++ b/test/netlib/http/http1/test_read.py @@ -104,7 +104,7 @@ def test_read_response_head(): assert rfile.read() == b"skip" -class TestReadBody(): +class TestReadBody: def test_chunked(self): rfile = BytesIO(b"3\r\nfoo\r\n0\r\n\r\nbar") body = b"".join(read_body(rfile, None)) @@ -289,7 +289,7 @@ def test_check_http_version(): _check_http_version(b"HTTP/1.b") -class TestReadHeaders(): +class TestReadHeaders: @staticmethod def _read(data): return _read_headers(BytesIO(data)) diff --git a/test/netlib/http/test_headers.py b/test/netlib/http/test_headers.py index d214ca026..63f168977 100644 --- a/test/netlib/http/test_headers.py +++ b/test/netlib/http/test_headers.py @@ -4,7 +4,7 @@ from netlib.http.headers import Headers, parse_content_type, assemble_content_ty from netlib.tutils import raises -class TestHeaders(): +class TestHeaders: def _2host(self): return Headers( ( diff --git a/test/netlib/http/test_message.py b/test/netlib/http/test_message.py index 9a5b80eda..dd08e0188 100644 --- a/test/netlib/http/test_message.py +++ b/test/netlib/http/test_message.py @@ -36,7 +36,7 @@ def _test_decoded_attr(message, attr): assert getattr(message.data, attr) == b"FOO\xBF\x00BAR" -class TestMessageData(): +class TestMessageData: def test_eq_ne(self): data = tresp(timestamp_start=42, timestamp_end=42).data same = tresp(timestamp_start=42, timestamp_end=42).data @@ -50,7 +50,7 @@ class TestMessageData(): assert data != 0 -class TestMessage(): +class TestMessage: def test_init(self): resp = tresp() @@ -108,7 +108,7 @@ class TestMessage(): assert r.content == b"ggfootoo" -class TestMessageContentEncoding(): +class TestMessageContentEncoding: def test_simple(self): r = tresp() assert r.raw_content == b"message" @@ -186,7 +186,7 @@ class TestMessageContentEncoding(): assert "content-encoding" not in r.headers -class TestMessageText(): +class TestMessageText: def test_simple(self): r = tresp(content=b'\xfc') assert r.raw_content == b"\xfc" diff --git a/test/netlib/http/test_request.py b/test/netlib/http/test_request.py index bcb1cc43b..e091f280b 100644 --- a/test/netlib/http/test_request.py +++ b/test/netlib/http/test_request.py @@ -6,7 +6,7 @@ from netlib.tutils import treq, raises from .test_message import _test_decoded_attr, _test_passthrough_attr -class TestRequestData(): +class TestRequestData: def test_init(self): with raises(ValueError): treq(headers="foobar") @@ -14,7 +14,7 @@ class TestRequestData(): assert isinstance(treq(headers=()).headers, Headers) -class TestRequestCore(): +class TestRequestCore: """ Tests for builtins and the attributes that are directly proxied from the data structure """ @@ -92,7 +92,7 @@ class TestRequestCore(): assert request.headers["Host"] == "example.org" -class TestRequestUtils(): +class TestRequestUtils: """ Tests for additional convenience methods. """ diff --git a/test/netlib/http/test_response.py b/test/netlib/http/test_response.py index 6ab043c19..66d6e307d 100644 --- a/test/netlib/http/test_response.py +++ b/test/netlib/http/test_response.py @@ -11,7 +11,7 @@ from netlib.tutils import raises, tresp from .test_message import _test_passthrough_attr, _test_decoded_attr -class TestResponseData(): +class TestResponseData: def test_init(self): with raises(ValueError): tresp(headers="foobar") @@ -19,7 +19,7 @@ class TestResponseData(): assert isinstance(tresp(headers=()).headers, Headers) -class TestResponseCore(): +class TestResponseCore: """ Tests for builtins and the attributes that are directly proxied from the data structure """ @@ -60,7 +60,7 @@ class TestResponseCore(): _test_decoded_attr(tresp(), "reason") -class TestResponseUtils(): +class TestResponseUtils: """ Tests for additional convenience methods. """ diff --git a/test/netlib/test_multidict.py b/test/netlib/test_multidict.py index bad5e2b4b..a9523fd93 100644 --- a/test/netlib/test_multidict.py +++ b/test/netlib/test_multidict.py @@ -2,7 +2,7 @@ from netlib import tutils from netlib.multidict import MultiDict, ImmutableMultiDict, MultiDictView -class _TMulti(): +class _TMulti: @staticmethod def _kconv(key): return key.lower() @@ -16,7 +16,7 @@ class TImmutableMultiDict(_TMulti, ImmutableMultiDict): pass -class TestMultiDict(): +class TestMultiDict: @staticmethod def _multi(): return TMultiDict(( @@ -194,7 +194,7 @@ class TestMultiDict(): assert md == md2 -class TestImmutableMultiDict(): +class TestImmutableMultiDict: def test_modify(self): md = TImmutableMultiDict() with tutils.raises(TypeError): @@ -224,7 +224,7 @@ class TestImmutableMultiDict(): assert md.with_insert(0, "foo", "bar").fields == (("foo", "bar"),) -class TParent(): +class TParent: def __init__(self): self.vals = tuple() @@ -235,7 +235,7 @@ class TParent(): return self.vals -class TestMultiDictView(): +class TestMultiDictView: def test_modify(self): p = TParent() tv = MultiDictView(p.getter, p.setter) diff --git a/test/netlib/tservers.py b/test/netlib/tservers.py index d22be413f..fdf40ff30 100644 --- a/test/netlib/tservers.py +++ b/test/netlib/tservers.py @@ -85,7 +85,7 @@ class _TServer(tcp.TCPServer): self.q.put(s.getvalue()) -class ServerTestBase(): +class ServerTestBase: ssl = None handler = None addr = ("localhost", 0) diff --git a/test/netlib/websockets/test_frame.py b/test/netlib/websockets/test_frame.py index 265d2513f..a039dcb19 100644 --- a/test/netlib/websockets/test_frame.py +++ b/test/netlib/websockets/test_frame.py @@ -6,7 +6,7 @@ from netlib import websockets from netlib import tutils -class TestFrameHeader(): +class TestFrameHeader: @pytest.mark.parametrize("input,expected", [ (0, '0100'), @@ -123,7 +123,7 @@ class TestFrameHeader(): assert f.masking_key -class TestFrame(): +class TestFrame: def test_equality(self): f = websockets.Frame(payload=b'1234') f2 = websockets.Frame(payload=b'1234') diff --git a/test/netlib/websockets/test_masker.py b/test/netlib/websockets/test_masker.py index a06fd0795..23a9b8763 100644 --- a/test/netlib/websockets/test_masker.py +++ b/test/netlib/websockets/test_masker.py @@ -4,7 +4,7 @@ import pytest from netlib import websockets -class TestMasker(): +class TestMasker: @pytest.mark.parametrize("input,expected", [ ([b"a"], '00'), diff --git a/test/netlib/websockets/test_utils.py b/test/netlib/websockets/test_utils.py index 7e3f02f9c..f6f1e40a7 100644 --- a/test/netlib/websockets/test_utils.py +++ b/test/netlib/websockets/test_utils.py @@ -4,7 +4,7 @@ from netlib import http from netlib import websockets -class TestUtils(): +class TestUtils: def test_client_handshake_headers(self): h = websockets.client_handshake_headers(version='42') diff --git a/test/pathod/test_language_base.py b/test/pathod/test_language_base.py index 12a235e40..b8abc9ba2 100644 --- a/test/pathod/test_language_base.py +++ b/test/pathod/test_language_base.py @@ -343,7 +343,7 @@ def test_unique_name(): assert b.unique_name -class test_boolean(): +class test_boolean: e = TBoolean.expr() assert e.parseString("test")[0].value assert not e.parseString("-test")[0].value diff --git a/test/pathod/test_pathod.py b/test/pathod/test_pathod.py index 69b7a6042..89d7c562d 100644 --- a/test/pathod/test_pathod.py +++ b/test/pathod/test_pathod.py @@ -7,7 +7,7 @@ from netlib.exceptions import HttpException, TlsException from . import tutils -class TestPathod(): +class TestPathod: def test_logging(self): s = io.StringIO() diff --git a/test/pathod/test_protocols_http2.py b/test/pathod/test_protocols_http2.py index 243539275..7300cc1dd 100644 --- a/test/pathod/test_protocols_http2.py +++ b/test/pathod/test_protocols_http2.py @@ -169,7 +169,7 @@ class TestPerformClientConnectionPreface(netlib_tservers.ServerTestBase): assert protocol.connection_preface_performed -class TestClientStreamIds(): +class TestClientStreamIds: c = tcp.TCPClient(("127.0.0.1", 0)) protocol = HTTP2StateProtocol(c) @@ -183,7 +183,7 @@ class TestClientStreamIds(): assert self.protocol.current_stream_id == 5 -class TestserverstreamIds(): +class TestserverstreamIds: c = tcp.TCPClient(("127.0.0.1", 0)) protocol = HTTP2StateProtocol(c, is_server=True) @@ -230,7 +230,7 @@ class TestApplySettings(netlib_tservers.ServerTestBase): hyperframe.frame.SettingsFrame.INITIAL_WINDOW_SIZE] == 'deadbeef' -class TestCreateHeaders(): +class TestCreateHeaders: c = tcp.TCPClient(("127.0.0.1", 0)) def test_create_headers(self): @@ -267,7 +267,7 @@ class TestCreateHeaders(): assert bytes[2] == codecs.decode('00000209040000000163d5', 'hex_codec') -class TestCreateBody(): +class TestCreateBody: c = tcp.TCPClient(("127.0.0.1", 0)) def test_create_body_empty(self): @@ -422,7 +422,7 @@ class TestReadEmptyResponse(netlib_tservers.ServerTestBase): assert resp.content == b'' -class TestAssembleRequest(): +class TestAssembleRequest: c = tcp.TCPClient(("127.0.0.1", 0)) def test_request_simple(self): @@ -476,7 +476,7 @@ class TestAssembleRequest(): codecs.decode('000006000100000001666f6f626172', 'hex_codec') -class TestAssembleResponse(): +class TestAssembleResponse: c = tcp.TCPClient(("127.0.0.1", 0)) def test_simple(self): diff --git a/test/pathod/tutils.py b/test/pathod/tutils.py index 6ebf25a8b..c22435787 100644 --- a/test/pathod/tutils.py +++ b/test/pathod/tutils.py @@ -23,7 +23,7 @@ def treader(bytes): return tcp.Reader(fp) -class DaemonTests(): +class DaemonTests: nohang = False ssl = False timeout = None From c774a9fec93feedc37a450400a03b83f5f4cb4b9 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Mon, 17 Oct 2016 17:34:46 +1300 Subject: [PATCH 3/3] python3: clean up super and __future__ --- examples/tls_passthrough.py | 1 - mitmproxy/addons.py | 1 - mitmproxy/builtins/__init__.py | 1 - mitmproxy/builtins/anticache.py | 1 - mitmproxy/builtins/anticomp.py | 1 - mitmproxy/builtins/dumper.py | 1 - mitmproxy/builtins/filestreamer.py | 1 - mitmproxy/builtins/script.py | 1 - mitmproxy/builtins/serverplayback.py | 1 - mitmproxy/builtins/stickyauth.py | 1 - mitmproxy/builtins/termlog.py | 1 - mitmproxy/cmdline.py | 1 - mitmproxy/console/common.py | 1 - mitmproxy/console/flowdetailview.py | 1 - mitmproxy/console/flowlist.py | 3 +-- mitmproxy/console/flowview.py | 5 ++-- mitmproxy/console/grideditor/base.py | 9 +++---- mitmproxy/console/grideditor/col_bytes.py | 5 ++-- mitmproxy/console/grideditor/col_subgrid.py | 5 ++-- mitmproxy/console/grideditor/col_text.py | 7 +++-- mitmproxy/console/grideditor/editors.py | 5 ++-- mitmproxy/console/help.py | 1 - mitmproxy/console/master.py | 21 +++++++-------- mitmproxy/console/options.py | 5 ++-- mitmproxy/console/palettepicker.py | 1 - mitmproxy/console/palettes.py | 1 - mitmproxy/console/pathedit.py | 1 - mitmproxy/console/searchable.py | 3 +-- mitmproxy/console/select.py | 3 +-- mitmproxy/console/signals.py | 1 - mitmproxy/console/statusbar.py | 3 +-- mitmproxy/console/tabs.py | 3 +-- mitmproxy/console/window.py | 5 ++-- mitmproxy/contentviews.py | 4 --- mitmproxy/contrib/tls/__init__.py | 1 - mitmproxy/contrib/tls/_constructs.py | 1 - mitmproxy/contrib/tls/utils.py | 1 - mitmproxy/contrib/wbxml/ASWBXMLCodePage.py | 2 +- mitmproxy/contrib/wbxml/GlobalTokens.py | 2 +- .../contrib/wbxml/InvalidDataException.py | 2 +- mitmproxy/controller.py | 5 ++-- mitmproxy/dump.py | 5 ++-- mitmproxy/exceptions.py | 5 ++-- mitmproxy/flow/__init__.py | 1 - mitmproxy/flow/export.py | 1 - mitmproxy/flow/io.py | 1 - mitmproxy/flow/io_compat.py | 1 - mitmproxy/flow/master.py | 3 +-- mitmproxy/flow/modules.py | 1 - mitmproxy/flow/state.py | 5 ++-- mitmproxy/flowfilter.py | 7 +++-- mitmproxy/main.py | 1 - mitmproxy/models/__init__.py | 1 - mitmproxy/models/connections.py | 7 +++-- mitmproxy/models/flow.py | 5 ++-- mitmproxy/models/http.py | 9 +++---- mitmproxy/models/tcp.py | 3 +-- mitmproxy/onboarding/app.py | 1 - mitmproxy/options.py | 3 +-- mitmproxy/optmanager.py | 3 +-- mitmproxy/protocol/__init__.py | 1 - mitmproxy/protocol/base.py | 7 +++-- mitmproxy/protocol/http.py | 5 ++-- mitmproxy/protocol/http1.py | 3 +-- mitmproxy/protocol/http2.py | 7 +++-- mitmproxy/protocol/http_replay.py | 3 +-- mitmproxy/protocol/rawtcp.py | 3 +-- mitmproxy/protocol/tls.py | 3 +-- mitmproxy/protocol/websockets.py | 3 +-- mitmproxy/proxy/__init__.py | 1 - mitmproxy/proxy/config.py | 1 - mitmproxy/proxy/modes/__init__.py | 1 - mitmproxy/proxy/modes/http_proxy.py | 3 +-- mitmproxy/proxy/modes/reverse_proxy.py | 3 +-- mitmproxy/proxy/modes/socks_proxy.py | 3 +-- mitmproxy/proxy/modes/transparent_proxy.py | 3 +-- mitmproxy/proxy/root_context.py | 1 - mitmproxy/proxy/server.py | 3 +-- mitmproxy/script/concurrent.py | 1 - mitmproxy/stateobject.py | 1 - mitmproxy/utils.py | 1 - mitmproxy/web/app.py | 7 +++-- mitmproxy/web/master.py | 27 +++++++++---------- netlib/__init__.py | 1 - netlib/basethread.py | 2 +- netlib/certutils.py | 1 - netlib/debug.py | 1 - netlib/encoding.py | 1 - netlib/exceptions.py | 3 +-- netlib/http/__init__.py | 1 - netlib/http/authentication.py | 1 - netlib/http/headers.py | 15 +++++------ netlib/http/http1/__init__.py | 1 - netlib/http/http1/assemble.py | 1 - netlib/http/http1/read.py | 1 - netlib/http/http2/__init__.py | 1 - netlib/http/message.py | 1 - netlib/http/request.py | 5 ++-- netlib/http/response.py | 3 +-- netlib/http/status_codes.py | 1 - netlib/http/user_agents.py | 1 - netlib/multidict.py | 10 ++++--- netlib/socks.py | 3 +-- netlib/strutils.py | 1 - netlib/tcp.py | 5 ++-- netlib/utils.py | 1 - netlib/version.py | 1 - netlib/version_check.py | 1 - netlib/websockets/__init__.py | 1 - netlib/websockets/frame.py | 1 - netlib/websockets/masker.py | 1 - netlib/websockets/utils.py | 1 - netlib/wsgi.py | 1 - pathod/language/__init__.py | 1 - pathod/pathoc.py | 1 - pathod/pathoc_cmdline.py | 1 - pathod/pathod.py | 1 - pathod/protocols/http2.py | 1 - release/rtool.py | 1 - test/mitmproxy/__init__.py | 1 - test/mitmproxy/builtins/test_filestreamer.py | 1 - test/mitmproxy/protocol/test_http1.py | 1 - test/mitmproxy/protocol/test_http2.py | 1 - test/mitmproxy/protocol/test_websockets.py | 1 - test/mitmproxy/test_addons.py | 1 - test/mitmproxy/test_controller.py | 2 +- test/mitmproxy/test_optmanager.py | 3 +-- test/mitmproxy/test_server.py | 20 +++++++------- test/mitmproxy/tools/bench.py | 1 - test/mitmproxy/tools/benchtool.py | 2 +- test/mitmproxy/tservers.py | 12 ++++----- test/mitmproxy/tutils.py | 2 +- test/netlib/http/http1/test_assemble.py | 1 - test/netlib/http/http1/test_read.py | 1 - test/netlib/http/test_message.py | 1 - test/netlib/http/test_request.py | 1 - test/netlib/http/test_response.py | 1 - test/netlib/test_debug.py | 1 - test/netlib/tservers.py | 1 - test/pathod/__init__.py | 1 - 140 files changed, 136 insertions(+), 267 deletions(-) diff --git a/examples/tls_passthrough.py b/examples/tls_passthrough.py index 79d5fa001..445ea5c31 100644 --- a/examples/tls_passthrough.py +++ b/examples/tls_passthrough.py @@ -20,7 +20,6 @@ Example: Authors: Maximilian Hils, Matthew Tuusberg """ -from __future__ import absolute_import, print_function, division import collections import random diff --git a/mitmproxy/addons.py b/mitmproxy/addons.py index 1802da684..5b0781291 100644 --- a/mitmproxy/addons.py +++ b/mitmproxy/addons.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division from mitmproxy import exceptions import pprint diff --git a/mitmproxy/builtins/__init__.py b/mitmproxy/builtins/__init__.py index 26e9dfbdd..1071f2e7f 100644 --- a/mitmproxy/builtins/__init__.py +++ b/mitmproxy/builtins/__init__.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division from mitmproxy.builtins import anticache from mitmproxy.builtins import anticomp diff --git a/mitmproxy/builtins/anticache.py b/mitmproxy/builtins/anticache.py index 41a5ed959..05192f12a 100644 --- a/mitmproxy/builtins/anticache.py +++ b/mitmproxy/builtins/anticache.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division class AntiCache: diff --git a/mitmproxy/builtins/anticomp.py b/mitmproxy/builtins/anticomp.py index 823e960cf..9283d9c9e 100644 --- a/mitmproxy/builtins/anticomp.py +++ b/mitmproxy/builtins/anticomp.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division class AntiComp: diff --git a/mitmproxy/builtins/dumper.py b/mitmproxy/builtins/dumper.py index ecaa05ec3..ddf84889d 100644 --- a/mitmproxy/builtins/dumper.py +++ b/mitmproxy/builtins/dumper.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import itertools diff --git a/mitmproxy/builtins/filestreamer.py b/mitmproxy/builtins/filestreamer.py index bf5eedee4..b1643b212 100644 --- a/mitmproxy/builtins/filestreamer.py +++ b/mitmproxy/builtins/filestreamer.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import os.path from mitmproxy import exceptions diff --git a/mitmproxy/builtins/script.py b/mitmproxy/builtins/script.py index a77ca32a7..aef8e4808 100644 --- a/mitmproxy/builtins/script.py +++ b/mitmproxy/builtins/script.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import contextlib import os diff --git a/mitmproxy/builtins/serverplayback.py b/mitmproxy/builtins/serverplayback.py index 9d551511c..383e27547 100644 --- a/mitmproxy/builtins/serverplayback.py +++ b/mitmproxy/builtins/serverplayback.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import urllib import hashlib diff --git a/mitmproxy/builtins/stickyauth.py b/mitmproxy/builtins/stickyauth.py index 18b439673..540b717ab 100644 --- a/mitmproxy/builtins/stickyauth.py +++ b/mitmproxy/builtins/stickyauth.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division from mitmproxy import exceptions from mitmproxy import flowfilter diff --git a/mitmproxy/builtins/termlog.py b/mitmproxy/builtins/termlog.py index c8259f0c1..3dbb869be 100644 --- a/mitmproxy/builtins/termlog.py +++ b/mitmproxy/builtins/termlog.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import click diff --git a/mitmproxy/cmdline.py b/mitmproxy/cmdline.py index e97be5d47..705aed741 100644 --- a/mitmproxy/cmdline.py +++ b/mitmproxy/cmdline.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import configargparse import os diff --git a/mitmproxy/console/common.py b/mitmproxy/console/common.py index e1366c1e1..5e335c715 100644 --- a/mitmproxy/console/common.py +++ b/mitmproxy/console/common.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, division import os diff --git a/mitmproxy/console/flowdetailview.py b/mitmproxy/console/flowdetailview.py index 0a03e1c46..64fdd40b2 100644 --- a/mitmproxy/console/flowdetailview.py +++ b/mitmproxy/console/flowdetailview.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import urwid diff --git a/mitmproxy/console/flowlist.py b/mitmproxy/console/flowlist.py index 73c8ade58..70ce6cb63 100644 --- a/mitmproxy/console/flowlist.py +++ b/mitmproxy/console/flowlist.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import urwid @@ -297,7 +296,7 @@ class FlowListBox(urwid.ListBox): def __init__(self, master: "mitmproxy.console.master.ConsoleMaster"): self.master = master - super(FlowListBox, self).__init__(FlowListWalker(master, master.state)) + super().__init__(FlowListWalker(master, master.state)) def get_method_raw(self, k): if k: diff --git a/mitmproxy/console/flowview.py b/mitmproxy/console/flowview.py index 3b43fd496..8e0414058 100644 --- a/mitmproxy/console/flowview.py +++ b/mitmproxy/console/flowview.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import math import os @@ -134,7 +133,7 @@ class FlowView(tabs.Tabs): def __init__(self, master, state, flow, tab_offset): self.master, self.state, self.flow = master, state, flow - super(FlowView, self).__init__( + super().__init__( [ (self.tab_request, self.view_request), (self.tab_response, self.view_response), @@ -508,7 +507,7 @@ class FlowView(tabs.Tabs): elif self.tab_offset == TAB_RESP: conn = self.flow.response - key = super(self.__class__, self).keypress(size, key) + key = super().keypress(size, key) # Special case: Space moves over to the next flow. # We need to catch that before applying common.shortcuts() diff --git a/mitmproxy/console/grideditor/base.py b/mitmproxy/console/grideditor/base.py index ecbbd0f9e..5825e50cd 100644 --- a/mitmproxy/console/grideditor/base.py +++ b/mitmproxy/console/grideditor/base.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import abc import copy @@ -95,7 +94,7 @@ class GridRow(urwid.WidgetWrap): ) if focused is not None: w.set_focus_column(focused) - super(GridRow, self).__init__(w) + super().__init__(w) def keypress(self, s, k): if self.edit_col: @@ -127,7 +126,7 @@ class GridWalker(urwid.ListWalker): def _modified(self): self.editor.show_empty_msg() - return super(GridWalker, self)._modified() + return super()._modified() def add_value(self, lst): self.lst.append( @@ -245,7 +244,7 @@ class GridWalker(urwid.ListWalker): class GridListBox(urwid.ListBox): def __init__(self, lw): - super(GridListBox, self).__init__(lw) + super().__init__(lw) FIRST_WIDTH_MAX = 40 @@ -301,7 +300,7 @@ class GridEditor(urwid.WidgetWrap): self.lb, header=urwid.Pile([title, h]) ) - super(GridEditor, self).__init__(w) + super().__init__(w) self.master.loop.widget.footer.update("") self.show_empty_msg() diff --git a/mitmproxy/console/grideditor/col_bytes.py b/mitmproxy/console/grideditor/col_bytes.py index 43d813be5..51ce5a500 100644 --- a/mitmproxy/console/grideditor/col_bytes.py +++ b/mitmproxy/console/grideditor/col_bytes.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import os from typing import Callable, Optional @@ -74,7 +73,7 @@ class Display(base.Cell): self.data = data escaped = strutils.bytes_to_escaped_str(data) w = urwid.Text(escaped, wrap="any") - super(Display, self).__init__(w) + super().__init__(w) def get_data(self) -> bytes: return self.data @@ -85,7 +84,7 @@ class Edit(base.Cell): data = strutils.bytes_to_escaped_str(data) w = urwid.Edit(edit_text=data, wrap="any", multiline=True) w = urwid.AttrWrap(w, "editfield") - super(Edit, self).__init__(w) + super().__init__(w) def get_data(self) -> bytes: txt = self._w.get_text()[0].strip() diff --git a/mitmproxy/console/grideditor/col_subgrid.py b/mitmproxy/console/grideditor/col_subgrid.py index 1dec80327..8a08f8388 100644 --- a/mitmproxy/console/grideditor/col_subgrid.py +++ b/mitmproxy/console/grideditor/col_subgrid.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import urwid from mitmproxy.console.grideditor import base from mitmproxy.console import signals @@ -7,7 +6,7 @@ from netlib.http import cookies class Column(base.Column): def __init__(self, heading, subeditor): - super(Column, self).__init__(heading) + super().__init__(heading) self.subeditor = subeditor def Edit(self, data): @@ -45,7 +44,7 @@ class Display(base.Cell): def __init__(self, data): p = cookies._format_pairs(data, sep="\n") w = urwid.Text(p) - super(Display, self).__init__(w) + super().__init__(w) def get_data(self): pass diff --git a/mitmproxy/console/grideditor/col_text.py b/mitmproxy/console/grideditor/col_text.py index 9962c7b17..ae15374c8 100644 --- a/mitmproxy/console/grideditor/col_text.py +++ b/mitmproxy/console/grideditor/col_text.py @@ -4,7 +4,6 @@ Welcome to the encoding dance! In a nutshell, text columns are actually a proxy class for byte columns, which just encode/decodes contents. """ -from __future__ import absolute_import, print_function, division from mitmproxy.console import signals from mitmproxy.console.grideditor import col_bytes @@ -12,7 +11,7 @@ from mitmproxy.console.grideditor import col_bytes class Column(col_bytes.Column): def __init__(self, heading, encoding="utf8", errors="surrogateescape"): - super(Column, self).__init__(heading) + super().__init__(heading) self.encoding_args = encoding, errors def Display(self, data): @@ -31,10 +30,10 @@ class EncodingMixin: # type: (str) -> TDisplay self.encoding_args = encoding_args data = data.encode(*self.encoding_args) - super(EncodingMixin, self).__init__(data) + super().__init__(data) def get_data(self) -> str: - data = super(EncodingMixin, self).get_data() + data = super().get_data() try: return data.decode(*self.encoding_args) except ValueError: diff --git a/mitmproxy/console/grideditor/editors.py b/mitmproxy/console/grideditor/editors.py index 0c9a2a025..7a1ef0978 100644 --- a/mitmproxy/console/grideditor/editors.py +++ b/mitmproxy/console/grideditor/editors.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import re import urwid from mitmproxy import exceptions @@ -29,7 +28,7 @@ class HeaderEditor(base.GridEditor): ] def make_help(self): - h = super(HeaderEditor, self).make_help() + h = super().make_help() text = [ urwid.Text([("text", "Special keys:\n")]) ] @@ -106,7 +105,7 @@ class SetHeadersEditor(base.GridEditor): return False def make_help(self): - h = super(SetHeadersEditor, self).make_help() + h = super().make_help() text = [ urwid.Text([("text", "Special keys:\n")]) ] diff --git a/mitmproxy/console/help.py b/mitmproxy/console/help.py index 7393d7c46..065792065 100644 --- a/mitmproxy/console/help.py +++ b/mitmproxy/console/help.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import platform diff --git a/mitmproxy/console/master.py b/mitmproxy/console/master.py index e7d74e2ef..5f31cb747 100644 --- a/mitmproxy/console/master.py +++ b/mitmproxy/console/master.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import mailcap import mimetypes @@ -65,19 +64,19 @@ class ConsoleState(flow.State): return d.get(key, default) def add_flow(self, f): - super(ConsoleState, self).add_flow(f) + super().add_flow(f) signals.flowlist_change.send(self) self.update_focus() return f def update_flow(self, f): - super(ConsoleState, self).update_flow(f) + super().update_flow(f) signals.flowlist_change.send(self) self.update_focus() return f def set_view_filter(self, txt): - ret = super(ConsoleState, self).set_view_filter(txt) + ret = super().set_view_filter(txt) self.set_focus(self.focus) return ret @@ -121,7 +120,7 @@ class ConsoleState(flow.State): self.focus -= 1 if self.focus < 0: self.focus = None - ret = super(ConsoleState, self).delete_flow(f) + ret = super().delete_flow(f) self.set_focus(self.focus) return ret @@ -185,7 +184,7 @@ class ConsoleState(flow.State): def clear(self): marked_flows = [f for f in self.view if f.marked] - super(ConsoleState, self).clear() + super().clear() for f in marked_flows: self.add_flow(f) @@ -217,7 +216,7 @@ class Options(mitmproxy.options.Options): self.palette = palette self.palette_transparent = palette_transparent self.no_mouse = no_mouse - super(Options, self).__init__(**kwargs) + super().__init__(**kwargs) class ConsoleMaster(flow.FlowMaster): @@ -679,22 +678,22 @@ class ConsoleMaster(flow.FlowMaster): # Handlers @controller.handler def error(self, f): - super(ConsoleMaster, self).error(f) + super().error(f) self.process_flow(f) @controller.handler def request(self, f): - super(ConsoleMaster, self).request(f) + super().request(f) self.process_flow(f) @controller.handler def response(self, f): - super(ConsoleMaster, self).response(f) + super().response(f) self.process_flow(f) @controller.handler def tcp_message(self, f): - super(ConsoleMaster, self).tcp_message(f) + super().tcp_message(f) message = f.messages[-1] direction = "->" if message.from_client else "<-" self.add_log("{client} {direction} tcp {direction} {server}".format( diff --git a/mitmproxy/console/options.py b/mitmproxy/console/options.py index 97313bf4b..c4d9d8727 100644 --- a/mitmproxy/console/options.py +++ b/mitmproxy/console/options.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import urwid @@ -144,7 +143,7 @@ class Options(urwid.WidgetWrap): self.lb, header = title ) - super(Options, self).__init__(w) + super().__init__(w) self.master.loop.widget.footer.update("") signals.update_settings.connect(self.sig_update_settings) @@ -157,7 +156,7 @@ class Options(urwid.WidgetWrap): if key == "C": self.clearall() return None - return super(self.__class__, self).keypress(size, key) + return super().keypress(size, key) def clearall(self): self.master.options.update( diff --git a/mitmproxy/console/palettepicker.py b/mitmproxy/console/palettepicker.py index f2acba0ac..2bcb73873 100644 --- a/mitmproxy/console/palettepicker.py +++ b/mitmproxy/console/palettepicker.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import urwid diff --git a/mitmproxy/console/palettes.py b/mitmproxy/console/palettes.py index 2e12338f9..7b15f98f8 100644 --- a/mitmproxy/console/palettes.py +++ b/mitmproxy/console/palettes.py @@ -3,7 +3,6 @@ # # http://urwid.org/manual/displayattributes.html # -from __future__ import absolute_import, print_function, division class Palette: diff --git a/mitmproxy/console/pathedit.py b/mitmproxy/console/pathedit.py index 0eae91231..2255c679d 100644 --- a/mitmproxy/console/pathedit.py +++ b/mitmproxy/console/pathedit.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import glob import os.path diff --git a/mitmproxy/console/searchable.py b/mitmproxy/console/searchable.py index d58d3d13f..0fd6debc5 100644 --- a/mitmproxy/console/searchable.py +++ b/mitmproxy/console/searchable.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import urwid @@ -44,7 +43,7 @@ class Searchable(urwid.ListBox): self.set_focus(len(self.walker) - 1) self.walker._modified() else: - return super(self.__class__, self).keypress(size, key) + return super().keypress(size, key) def set_search(self, text): self.state.last_search = text diff --git a/mitmproxy/console/select.py b/mitmproxy/console/select.py index 091f07a23..d5a3c42a7 100644 --- a/mitmproxy/console/select.py +++ b/mitmproxy/console/select.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import urwid @@ -120,4 +119,4 @@ class Select(urwid.ListBox): self.keymap[key].activate() self.set_focus(self.options.index(self.keymap[key])) return None - return super(self.__class__, self).keypress(size, key) + return super().keypress(size, key) diff --git a/mitmproxy/console/signals.py b/mitmproxy/console/signals.py index 93eb399f4..b5d3111f5 100644 --- a/mitmproxy/console/signals.py +++ b/mitmproxy/console/signals.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import blinker diff --git a/mitmproxy/console/statusbar.py b/mitmproxy/console/statusbar.py index 9536abe7c..c43f68add 100644 --- a/mitmproxy/console/statusbar.py +++ b/mitmproxy/console/statusbar.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import os.path @@ -120,7 +119,7 @@ class StatusBar(urwid.WidgetWrap): self.master = master self.helptext = helptext self.ib = urwid.WidgetWrap(urwid.Text("")) - super(StatusBar, self).__init__(urwid.Pile([self.ib, self.master.ab])) + super().__init__(urwid.Pile([self.ib, self.master.ab])) signals.update_settings.connect(self.sig_update_settings) signals.flowlist_change.connect(self.sig_update_settings) master.options.changed.connect(self.sig_update_settings) diff --git a/mitmproxy/console/tabs.py b/mitmproxy/console/tabs.py index a5e9c5102..e2c2f6b98 100644 --- a/mitmproxy/console/tabs.py +++ b/mitmproxy/console/tabs.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import urwid @@ -25,7 +24,7 @@ class Tab(urwid.WidgetWrap): class Tabs(urwid.WidgetWrap): def __init__(self, tabs, tab_offset=0): - super(Tabs, self).__init__("") + super().__init__("") self.tab_offset = tab_offset self.tabs = tabs self.show() diff --git a/mitmproxy/console/window.py b/mitmproxy/console/window.py index ab2c80ade..a3a949332 100644 --- a/mitmproxy/console/window.py +++ b/mitmproxy/console/window.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import urwid @@ -23,7 +22,7 @@ class Window(urwid.Frame): def mouse_event(self, *args, **kwargs): # args: (size, event, button, col, row) - k = super(self.__class__, self).mouse_event(*args, **kwargs) + k = super().mouse_event(*args, **kwargs) if not k: if args[1] == "mouse drag": signals.status_message.send( @@ -83,7 +82,7 @@ class Window(urwid.Frame): ) def keypress(self, size, k): - k = super(self.__class__, self).keypress(size, k) + k = super().keypress(size, k) if k == "?": self.master.view_help(self.helpctx) elif k == "i": diff --git a/mitmproxy/contentviews.py b/mitmproxy/contentviews.py index 8569067f8..9a70b1042 100644 --- a/mitmproxy/contentviews.py +++ b/mitmproxy/contentviews.py @@ -12,7 +12,6 @@ use. For HTTP, the message headers are passed as the ``headers`` keyword argumen requests, the query parameters are passed as the ``query`` keyword argument. """ -from __future__ import absolute_import, print_function, division import datetime import io @@ -309,7 +308,6 @@ if pyamf: data = input.readObject() self["data"] = data - def pyamf_class_loader(s): for i in pyamf.CLASS_LOADERS: if i != pyamf_class_loader: @@ -318,10 +316,8 @@ if pyamf: return v return DummyObject - pyamf.register_class_loader(pyamf_class_loader) - class ViewAMF(View): name = "AMF" prompt = ("amf", "f") diff --git a/mitmproxy/contrib/tls/__init__.py b/mitmproxy/contrib/tls/__init__.py index 4b540884d..450986f7a 100644 --- a/mitmproxy/contrib/tls/__init__.py +++ b/mitmproxy/contrib/tls/__init__.py @@ -2,4 +2,3 @@ # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. -from __future__ import absolute_import, division, print_function diff --git a/mitmproxy/contrib/tls/_constructs.py b/mitmproxy/contrib/tls/_constructs.py index 4cb7d3823..f599f0fd5 100644 --- a/mitmproxy/contrib/tls/_constructs.py +++ b/mitmproxy/contrib/tls/_constructs.py @@ -2,7 +2,6 @@ # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. -from __future__ import absolute_import, division, print_function from construct import (Array, Bytes, Struct, UBInt16, UBInt32, UBInt8, PascalString, Embed, TunnelAdapter, GreedyRange, Switch, OptionalGreedyRange, Optional) diff --git a/mitmproxy/contrib/tls/utils.py b/mitmproxy/contrib/tls/utils.py index 87afbacb7..ff442387f 100644 --- a/mitmproxy/contrib/tls/utils.py +++ b/mitmproxy/contrib/tls/utils.py @@ -2,7 +2,6 @@ # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. -from __future__ import absolute_import, division, print_function import construct diff --git a/mitmproxy/contrib/wbxml/ASWBXMLCodePage.py b/mitmproxy/contrib/wbxml/ASWBXMLCodePage.py index 2f9d87177..1d00afd42 100644 --- a/mitmproxy/contrib/wbxml/ASWBXMLCodePage.py +++ b/mitmproxy/contrib/wbxml/ASWBXMLCodePage.py @@ -49,4 +49,4 @@ class ASWBXMLCodePage: return None def __repr__(self): - return str(self.tokenLookup) \ No newline at end of file + return str(self.tokenLookup) diff --git a/mitmproxy/contrib/wbxml/GlobalTokens.py b/mitmproxy/contrib/wbxml/GlobalTokens.py index 41310fb1d..85d5e5589 100644 --- a/mitmproxy/contrib/wbxml/GlobalTokens.py +++ b/mitmproxy/contrib/wbxml/GlobalTokens.py @@ -47,4 +47,4 @@ class GlobalTokens: EXT_1 = 0xC1 EXT_2 = 0xC2 OPAQUE = 0xC3 - LITERAL_AC = 0xC4 \ No newline at end of file + LITERAL_AC = 0xC4 diff --git a/mitmproxy/contrib/wbxml/InvalidDataException.py b/mitmproxy/contrib/wbxml/InvalidDataException.py index 67f8ea930..e9e3e087d 100644 --- a/mitmproxy/contrib/wbxml/InvalidDataException.py +++ b/mitmproxy/contrib/wbxml/InvalidDataException.py @@ -28,4 +28,4 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' class InvalidDataException(Exception): - pass \ No newline at end of file + pass diff --git a/mitmproxy/controller.py b/mitmproxy/controller.py index 09b7abed4..214dbd4cc 100644 --- a/mitmproxy/controller.py +++ b/mitmproxy/controller.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import functools import threading @@ -177,7 +176,7 @@ class ServerThread(basethread.BaseThread): def __init__(self, server): self.server = server address = getattr(self.server, "address", None) - super(ServerThread, self).__init__( + super().__init__( "ServerThread ({})".format(repr(address)) ) @@ -362,7 +361,7 @@ class DummyReply(Reply): and during testing. """ def __init__(self): - super(DummyReply, self).__init__(None) + super().__init__(None) self._should_reset = False def mark_reset(self): diff --git a/mitmproxy/dump.py b/mitmproxy/dump.py index 87f5783cf..dfe5309b6 100644 --- a/mitmproxy/dump.py +++ b/mitmproxy/dump.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import typing from typing import Optional @@ -29,7 +28,7 @@ class Options(options.Options): self.flow_detail = flow_detail self.keepserving = keepserving self.tfile = tfile - super(Options, self).__init__(**kwargs) + super().__init__(**kwargs) class DumpMaster(flow.FlowMaster): @@ -86,4 +85,4 @@ class DumpMaster(flow.FlowMaster): if self.options.rfile and not self.options.keepserving: self.addons.done() return - super(DumpMaster, self).run() + super().run() diff --git a/mitmproxy/exceptions.py b/mitmproxy/exceptions.py index 7fca584af..b696c91f6 100644 --- a/mitmproxy/exceptions.py +++ b/mitmproxy/exceptions.py @@ -5,7 +5,6 @@ Every Exception mitmproxy raises shall be a subclass of ProxyException. See also: http://lucumr.pocoo.org/2014/10/16/on-error-handling/ """ -from __future__ import absolute_import, print_function, division class ProxyException(Exception): @@ -15,7 +14,7 @@ class ProxyException(Exception): """ def __init__(self, message=None): - super(ProxyException, self).__init__(message) + super().__init__(message) class Kill(ProxyException): @@ -41,7 +40,7 @@ class TlsProtocolException(ProtocolException): class ClientHandshakeException(TlsProtocolException): def __init__(self, message, server): - super(ClientHandshakeException, self).__init__(message) + super().__init__(message) self.server = server diff --git a/mitmproxy/flow/__init__.py b/mitmproxy/flow/__init__.py index c857352c7..f7e83e8a7 100644 --- a/mitmproxy/flow/__init__.py +++ b/mitmproxy/flow/__init__.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division from mitmproxy.flow import export, modules from mitmproxy.flow.io import FlowWriter, FilteredFlowWriter, FlowReader, read_flows_from_paths diff --git a/mitmproxy/flow/export.py b/mitmproxy/flow/export.py index 603bf85ad..a73bda5b6 100644 --- a/mitmproxy/flow/export.py +++ b/mitmproxy/flow/export.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import json import re diff --git a/mitmproxy/flow/io.py b/mitmproxy/flow/io.py index f48d494f2..cc28998ba 100644 --- a/mitmproxy/flow/io.py +++ b/mitmproxy/flow/io.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import os diff --git a/mitmproxy/flow/io_compat.py b/mitmproxy/flow/io_compat.py index 31d5ed518..fc190e2fd 100644 --- a/mitmproxy/flow/io_compat.py +++ b/mitmproxy/flow/io_compat.py @@ -1,7 +1,6 @@ """ This module handles the import of mitmproxy flows generated by old versions. """ -from __future__ import absolute_import, print_function, division from typing import Any diff --git a/mitmproxy/flow/master.py b/mitmproxy/flow/master.py index a1b0a6311..c05eb9d10 100644 --- a/mitmproxy/flow/master.py +++ b/mitmproxy/flow/master.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import os import sys @@ -51,7 +50,7 @@ class FlowMaster(controller.Master): return self.servers[0] def __init__(self, options, server, state): - super(FlowMaster, self).__init__(options) + super().__init__(options) if server: self.add_server(server) self.state = state diff --git a/mitmproxy/flow/modules.py b/mitmproxy/flow/modules.py index d6d45ce66..c6fe3773e 100644 --- a/mitmproxy/flow/modules.py +++ b/mitmproxy/flow/modules.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division from netlib import wsgi from netlib import version diff --git a/mitmproxy/flow/state.py b/mitmproxy/flow/state.py index 69dcd1d2a..084b798d9 100644 --- a/mitmproxy/flow/state.py +++ b/mitmproxy/flow/state.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division from abc import abstractmethod, ABCMeta @@ -49,7 +48,7 @@ def _pos(*args): class FlowView(FlowList): def __init__(self, store, flt=None): - super(FlowView, self).__init__() + super().__init__() if not flt: flt = _pos self._build(store, flt) @@ -90,7 +89,7 @@ class FlowStore(FlowList): """ def __init__(self): - super(FlowStore, self).__init__() + super().__init__() self._set = set() # Used for O(1) lookups self.views = [] self._recalculate_views() diff --git a/mitmproxy/flowfilter.py b/mitmproxy/flowfilter.py index 64c0a9fc8..b63c27d92 100644 --- a/mitmproxy/flowfilter.py +++ b/mitmproxy/flowfilter.py @@ -31,7 +31,6 @@ ~c CODE Response code. rex Equivalent to ~u rex """ -from __future__ import absolute_import, print_function, division import re import sys @@ -373,7 +372,7 @@ class FAnd(_Token): self.lst = lst def dump(self, indent=0, fp=sys.stdout): - super(FAnd, self).dump(indent, fp) + super().dump(indent, fp) for i in self.lst: i.dump(indent + 1, fp) @@ -387,7 +386,7 @@ class FOr(_Token): self.lst = lst def dump(self, indent=0, fp=sys.stdout): - super(FOr, self).dump(indent, fp) + super().dump(indent, fp) for i in self.lst: i.dump(indent + 1, fp) @@ -401,7 +400,7 @@ class FNot(_Token): self.itm = itm[0] def dump(self, indent=0, fp=sys.stdout): - super(FNot, self).dump(indent, fp) + super().dump(indent, fp) self.itm.dump(indent + 1, fp) def __call__(self, f): diff --git a/mitmproxy/main.py b/mitmproxy/main.py index e39742f34..5a7fef2c0 100644 --- a/mitmproxy/main.py +++ b/mitmproxy/main.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import os import signal diff --git a/mitmproxy/models/__init__.py b/mitmproxy/models/__init__.py index 7b7eaef0c..25319b2dc 100644 --- a/mitmproxy/models/__init__.py +++ b/mitmproxy/models/__init__.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division from netlib.http import decoded from .connections import ClientConnection, ServerConnection diff --git a/mitmproxy/models/connections.py b/mitmproxy/models/connections.py index a99327d87..bf7a12aa6 100644 --- a/mitmproxy/models/connections.py +++ b/mitmproxy/models/connections.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import time import copy @@ -27,7 +26,7 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject): # Eventually, this object is restored from state. We don't have a # connection then. if client_connection: - super(ClientConnection, self).__init__(client_connection, address, server) + super().__init__(client_connection, address, server) else: self.connection = None self.server = None @@ -91,11 +90,11 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject): )) def convert_to_ssl(self, *args, **kwargs): - super(ClientConnection, self).convert_to_ssl(*args, **kwargs) + super().convert_to_ssl(*args, **kwargs) self.timestamp_ssl_setup = time.time() def finish(self): - super(ClientConnection, self).finish() + super().finish() self.timestamp_end = time.time() diff --git a/mitmproxy/models/flow.py b/mitmproxy/models/flow.py index 95a5a699f..2379b3915 100644 --- a/mitmproxy/models/flow.py +++ b/mitmproxy/models/flow.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import time import copy @@ -97,7 +96,7 @@ class Flow(stateobject.StateObject): ) def get_state(self): - d = super(Flow, self).get_state() + d = super().get_state() d.update(version=version.IVERSION) if self._backup and self._backup != d: d.update(backup=self._backup) @@ -107,7 +106,7 @@ class Flow(stateobject.StateObject): state.pop("version") if "backup" in state: self._backup = state.pop("backup") - super(Flow, self).set_state(state) + super().set_state(state) @classmethod def from_state(cls, state): diff --git a/mitmproxy/models/http.py b/mitmproxy/models/http.py index a76d8b91d..e679205dd 100644 --- a/mitmproxy/models/http.py +++ b/mitmproxy/models/http.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import cgi @@ -57,7 +56,7 @@ class HTTPRequest(http.Request): self.is_replay = is_replay def get_state(self): - state = super(HTTPRequest, self).get_state() + state = super().get_state() state.update( stickycookie=self.stickycookie, stickyauth=self.stickyauth, @@ -69,7 +68,7 @@ class HTTPRequest(http.Request): self.stickycookie = state.pop("stickycookie") self.stickyauth = state.pop("stickyauth") self.is_replay = state.pop("is_replay") - super(HTTPRequest, self).set_state(state) + super().set_state(state) @classmethod def wrap(self, request): @@ -154,7 +153,7 @@ class HTTPFlow(flow.Flow): """ def __init__(self, client_conn, server_conn, live=None): - super(HTTPFlow, self).__init__("http", client_conn, server_conn, live) + super().__init__("http", client_conn, server_conn, live) self.request = None """ :py:class:`HTTPRequest` object """ @@ -189,7 +188,7 @@ class HTTPFlow(flow.Flow): return s.format(flow=self) def copy(self): - f = super(HTTPFlow, self).copy() + f = super().copy() if self.request: f.request = self.request.copy() if self.response: diff --git a/mitmproxy/models/tcp.py b/mitmproxy/models/tcp.py index e33475c23..1be23d795 100644 --- a/mitmproxy/models/tcp.py +++ b/mitmproxy/models/tcp.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import time @@ -43,7 +42,7 @@ class TCPFlow(Flow): """ def __init__(self, client_conn, server_conn, live=None): - super(TCPFlow, self).__init__("tcp", client_conn, server_conn, live) + super().__init__("tcp", client_conn, server_conn, live) self.messages = [] # type: List[TCPMessage] _stateobject_attributes = Flow._stateobject_attributes.copy() diff --git a/mitmproxy/onboarding/app.py b/mitmproxy/onboarding/app.py index ecfe4ed59..b4ec4c84f 100644 --- a/mitmproxy/onboarding/app.py +++ b/mitmproxy/onboarding/app.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import os diff --git a/mitmproxy/options.py b/mitmproxy/options.py index 143c24bac..c98b3aea3 100644 --- a/mitmproxy/options.py +++ b/mitmproxy/options.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division from typing import Tuple, Optional, Sequence @@ -141,4 +140,4 @@ class Options(optmanager.OptManager): self.ssl_verify_upstream_trusted_cadir = ssl_verify_upstream_trusted_cadir self.ssl_verify_upstream_trusted_ca = ssl_verify_upstream_trusted_ca self.tcp_hosts = tcp_hosts - super(Options, self).__init__() + super().__init__() diff --git a/mitmproxy/optmanager.py b/mitmproxy/optmanager.py index c62dc4482..45e02c602 100644 --- a/mitmproxy/optmanager.py +++ b/mitmproxy/optmanager.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import contextlib import blinker @@ -25,7 +24,7 @@ class OptManager: # Initialize instance._opts before __init__ is called. # This allows us to call super().__init__() last, which then sets # ._initialized = True as the final operation. - instance = super(OptManager, cls).__new__(cls) + instance = super().__new__(cls) instance.__dict__["_opts"] = {} return instance diff --git a/mitmproxy/protocol/__init__.py b/mitmproxy/protocol/__init__.py index 5bf259aeb..89b60386e 100644 --- a/mitmproxy/protocol/__init__.py +++ b/mitmproxy/protocol/__init__.py @@ -28,7 +28,6 @@ should be established as late as possible; this makes server replay without any outgoing connections possible. """ -from __future__ import absolute_import, print_function, division from .base import Layer, ServerConnectionMixin from .http import UpstreamConnectLayer diff --git a/mitmproxy/protocol/base.py b/mitmproxy/protocol/base.py index dea6b3d11..4c824179d 100644 --- a/mitmproxy/protocol/base.py +++ b/mitmproxy/protocol/base.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import netlib.exceptions from mitmproxy import exceptions @@ -12,7 +11,7 @@ class _LayerCodeCompletion: """ def __init__(self, **mixin_args): # pragma: no cover - super(_LayerCodeCompletion, self).__init__(**mixin_args) + super().__init__(**mixin_args) if True: return self.config = None @@ -58,7 +57,7 @@ class Layer(_LayerCodeCompletion): :type: :py:class:`Layer` """ - super(Layer, self).__init__(**mixin_args) + super().__init__(**mixin_args) def __call__(self): """Logic of the layer. @@ -109,7 +108,7 @@ class ServerConnectionMixin: """ def __init__(self, server_address=None): - super(ServerConnectionMixin, self).__init__() + super().__init__() self.server_conn = None if self.config.options.spoof_source_address: diff --git a/mitmproxy/protocol/http.py b/mitmproxy/protocol/http.py index 3c17670e6..7f00933e0 100644 --- a/mitmproxy/protocol/http.py +++ b/mitmproxy/protocol/http.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import h2.exceptions import netlib.exceptions @@ -85,7 +84,7 @@ class ConnectServerConnection: class UpstreamConnectLayer(base.Layer): def __init__(self, ctx, connect_request): - super(UpstreamConnectLayer, self).__init__(ctx) + super().__init__(ctx) self.connect_request = connect_request self.server_conn = ConnectServerConnection( (connect_request.host, connect_request.port), @@ -125,7 +124,7 @@ class UpstreamConnectLayer(base.Layer): class HttpLayer(base.Layer): def __init__(self, ctx, mode): - super(HttpLayer, self).__init__(ctx) + super().__init__(ctx) self.mode = mode self.__initial_server_conn = None diff --git a/mitmproxy/protocol/http1.py b/mitmproxy/protocol/http1.py index 2f8a15deb..a74e5d628 100644 --- a/mitmproxy/protocol/http1.py +++ b/mitmproxy/protocol/http1.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division from mitmproxy import models from mitmproxy.protocol import http @@ -8,7 +7,7 @@ from netlib.http import http1 class Http1Layer(http._HttpTransmissionLayer): def __init__(self, ctx, mode): - super(Http1Layer, self).__init__(ctx) + super().__init__(ctx) self.mode = mode def read_request_headers(self): diff --git a/mitmproxy/protocol/http2.py b/mitmproxy/protocol/http2.py index ffc556843..756acc9ff 100644 --- a/mitmproxy/protocol/http2.py +++ b/mitmproxy/protocol/http2.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import threading import time @@ -24,7 +23,7 @@ from netlib.http import http2 class SafeH2Connection(connection.H2Connection): def __init__(self, conn, *args, **kwargs): - super(SafeH2Connection, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.conn = conn self.lock = threading.RLock() @@ -89,7 +88,7 @@ class SafeH2Connection(connection.H2Connection): class Http2Layer(base.Layer): def __init__(self, ctx, mode): - super(Http2Layer, self).__init__(ctx) + super().__init__(ctx) self.mode = mode self.streams = dict() self.server_to_client_stream_ids = dict([(0, 0)]) @@ -363,7 +362,7 @@ def detect_zombie_stream(func): class Http2SingleStreamLayer(http._HttpTransmissionLayer, basethread.BaseThread): def __init__(self, ctx, h2_connection, stream_id, request_headers): - super(Http2SingleStreamLayer, self).__init__( + super().__init__( ctx, name="Http2SingleStreamLayer-{}".format(stream_id) ) self.h2_connection = h2_connection diff --git a/mitmproxy/protocol/http_replay.py b/mitmproxy/protocol/http_replay.py index 0f0274316..9f23832da 100644 --- a/mitmproxy/protocol/http_replay.py +++ b/mitmproxy/protocol/http_replay.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import traceback @@ -27,7 +26,7 @@ class RequestReplayThread(basethread.BaseThread): self.channel = controller.Channel(event_queue, should_exit) else: self.channel = None - super(RequestReplayThread, self).__init__( + super().__init__( "RequestReplay (%s)" % flow.request.url ) diff --git a/mitmproxy/protocol/rawtcp.py b/mitmproxy/protocol/rawtcp.py index 069420ea6..ecbe80c95 100644 --- a/mitmproxy/protocol/rawtcp.py +++ b/mitmproxy/protocol/rawtcp.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import socket @@ -16,7 +15,7 @@ class RawTCPLayer(base.Layer): def __init__(self, ctx, ignore=False): self.ignore = ignore - super(RawTCPLayer, self).__init__(ctx) + super().__init__(ctx) def __call__(self): self.connect() diff --git a/mitmproxy/protocol/tls.py b/mitmproxy/protocol/tls.py index dbc834012..bd650ef42 100644 --- a/mitmproxy/protocol/tls.py +++ b/mitmproxy/protocol/tls.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import struct from typing import Optional # noqa @@ -318,7 +317,7 @@ class TlsLayer(base.Layer): """ def __init__(self, ctx, client_tls, server_tls, custom_server_sni = None): - super(TlsLayer, self).__init__(ctx) + super().__init__(ctx) self._client_tls = client_tls self._server_tls = server_tls diff --git a/mitmproxy/protocol/websockets.py b/mitmproxy/protocol/websockets.py index 7ac386f12..73f0a37d8 100644 --- a/mitmproxy/protocol/websockets.py +++ b/mitmproxy/protocol/websockets.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import netlib.exceptions import socket @@ -35,7 +34,7 @@ class WebSocketsLayer(base.Layer): """ def __init__(self, ctx, flow): - super(WebSocketsLayer, self).__init__(ctx) + super().__init__(ctx) self._flow = flow self.client_key = websockets.get_client_key(self._flow.request.headers) diff --git a/mitmproxy/proxy/__init__.py b/mitmproxy/proxy/__init__.py index e3d249fa0..f48c3d613 100644 --- a/mitmproxy/proxy/__init__.py +++ b/mitmproxy/proxy/__init__.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division from .config import ProxyConfig from .root_context import RootContext diff --git a/mitmproxy/proxy/config.py b/mitmproxy/proxy/config.py index e2dc5d262..f92e3b63d 100644 --- a/mitmproxy/proxy/config.py +++ b/mitmproxy/proxy/config.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import base64 import collections diff --git a/mitmproxy/proxy/modes/__init__.py b/mitmproxy/proxy/modes/__init__.py index fa62570c2..ebe23b8c5 100644 --- a/mitmproxy/proxy/modes/__init__.py +++ b/mitmproxy/proxy/modes/__init__.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division from .http_proxy import HttpProxy, HttpUpstreamProxy from .reverse_proxy import ReverseProxy diff --git a/mitmproxy/proxy/modes/http_proxy.py b/mitmproxy/proxy/modes/http_proxy.py index bc64ccd2e..4ec3b5783 100644 --- a/mitmproxy/proxy/modes/http_proxy.py +++ b/mitmproxy/proxy/modes/http_proxy.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division from mitmproxy import protocol @@ -17,7 +16,7 @@ class HttpProxy(protocol.Layer, protocol.ServerConnectionMixin): class HttpUpstreamProxy(protocol.Layer, protocol.ServerConnectionMixin): def __init__(self, ctx, server_address): - super(HttpUpstreamProxy, self).__init__(ctx, server_address=server_address) + super().__init__(ctx, server_address=server_address) def __call__(self): layer = self.ctx.next_layer(self) diff --git a/mitmproxy/proxy/modes/reverse_proxy.py b/mitmproxy/proxy/modes/reverse_proxy.py index 3739ac0e5..1a6f7d3da 100644 --- a/mitmproxy/proxy/modes/reverse_proxy.py +++ b/mitmproxy/proxy/modes/reverse_proxy.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division from mitmproxy import protocol @@ -6,7 +5,7 @@ from mitmproxy import protocol class ReverseProxy(protocol.Layer, protocol.ServerConnectionMixin): def __init__(self, ctx, server_address, server_tls): - super(ReverseProxy, self).__init__(ctx, server_address=server_address) + super().__init__(ctx, server_address=server_address) self.server_tls = server_tls def __call__(self): diff --git a/mitmproxy/proxy/modes/socks_proxy.py b/mitmproxy/proxy/modes/socks_proxy.py index 194378354..e9e684b35 100644 --- a/mitmproxy/proxy/modes/socks_proxy.py +++ b/mitmproxy/proxy/modes/socks_proxy.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import netlib.exceptions from mitmproxy import exceptions @@ -10,7 +9,7 @@ from netlib import tcp class Socks5Proxy(protocol.Layer, protocol.ServerConnectionMixin): def __init__(self, ctx): - super(Socks5Proxy, self).__init__(ctx) + super().__init__(ctx) def __call__(self): try: diff --git a/mitmproxy/proxy/modes/transparent_proxy.py b/mitmproxy/proxy/modes/transparent_proxy.py index c7df79009..c29e7b06c 100644 --- a/mitmproxy/proxy/modes/transparent_proxy.py +++ b/mitmproxy/proxy/modes/transparent_proxy.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division from mitmproxy import exceptions from mitmproxy import platform @@ -8,7 +7,7 @@ from mitmproxy import protocol class TransparentProxy(protocol.Layer, protocol.ServerConnectionMixin): def __init__(self, ctx): - super(TransparentProxy, self).__init__(ctx) + super().__init__(ctx) self.resolver = platform.resolver() def __call__(self): diff --git a/mitmproxy/proxy/root_context.py b/mitmproxy/proxy/root_context.py index fe981f500..4bfe87b29 100644 --- a/mitmproxy/proxy/root_context.py +++ b/mitmproxy/proxy/root_context.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import netlib.exceptions from mitmproxy import controller diff --git a/mitmproxy/proxy/server.py b/mitmproxy/proxy/server.py index 3719ae625..d1ec4e0a4 100644 --- a/mitmproxy/proxy/server.py +++ b/mitmproxy/proxy/server.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import socket import sys @@ -40,7 +39,7 @@ class ProxyServer(tcp.TCPServer): """ self.config = config try: - super(ProxyServer, self).__init__( + super().__init__( (config.options.listen_host, config.options.listen_port) ) except socket.error as e: diff --git a/mitmproxy/script/concurrent.py b/mitmproxy/script/concurrent.py index 9ed08065e..11b2144ee 100644 --- a/mitmproxy/script/concurrent.py +++ b/mitmproxy/script/concurrent.py @@ -2,7 +2,6 @@ This module provides a @concurrent decorator primitive to offload computations from mitmproxy's main master thread. """ -from __future__ import absolute_import, print_function, division from mitmproxy import controller from netlib import basethread diff --git a/mitmproxy/stateobject.py b/mitmproxy/stateobject.py index a38315c14..1ed8675a9 100644 --- a/mitmproxy/stateobject.py +++ b/mitmproxy/stateobject.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division from typing import Any from typing import List diff --git a/mitmproxy/utils.py b/mitmproxy/utils.py index 1c75dd83d..034f57d8c 100644 --- a/mitmproxy/utils.py +++ b/mitmproxy/utils.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import netlib.utils diff --git a/mitmproxy/web/app.py b/mitmproxy/web/app.py index 82ccf3fb5..0d573ec7c 100644 --- a/mitmproxy/web/app.py +++ b/mitmproxy/web/app.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import base64 import json @@ -98,7 +97,7 @@ class BasicAuth: class RequestHandler(BasicAuth, tornado.web.RequestHandler): def set_default_headers(self): - super(RequestHandler, self).set_default_headers() + super().set_default_headers() self.set_header("Server", version.MITMPROXY) self.set_header("X-Frame-Options", "DENY") self.add_header("X-XSS-Protection", "1; mode=block") @@ -137,7 +136,7 @@ class RequestHandler(BasicAuth, tornado.web.RequestHandler): if "exc_info" in kwargs and isinstance(kwargs["exc_info"][1], APIError): self.finish(kwargs["exc_info"][1].log_message) else: - super(RequestHandler, self).write_error(status_code, **kwargs) + super().write_error(status_code, **kwargs) class IndexHandler(RequestHandler): @@ -456,4 +455,4 @@ class Application(tornado.web.Application): autoreload=False, wauthenticator=wauthenticator, ) - super(Application, self).__init__(handlers, **settings) + super().__init__(handlers, **settings) diff --git a/mitmproxy/web/master.py b/mitmproxy/web/master.py index 8500c0cb3..0a237532a 100644 --- a/mitmproxy/web/master.py +++ b/mitmproxy/web/master.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import sys import collections @@ -24,10 +23,10 @@ class Stop(Exception): class WebFlowView(flow.FlowView): def __init__(self, store): - super(WebFlowView, self).__init__(store, None) + super().__init__(store, None) def _add(self, f): - super(WebFlowView, self)._add(f) + super()._add(f) app.ClientConnection.broadcast( type="UPDATE_FLOWS", cmd="add", @@ -35,7 +34,7 @@ class WebFlowView(flow.FlowView): ) def _update(self, f): - super(WebFlowView, self)._update(f) + super()._update(f) app.ClientConnection.broadcast( type="UPDATE_FLOWS", cmd="update", @@ -43,7 +42,7 @@ class WebFlowView(flow.FlowView): ) def _remove(self, f): - super(WebFlowView, self)._remove(f) + super()._remove(f) app.ClientConnection.broadcast( type="UPDATE_FLOWS", cmd="remove", @@ -51,7 +50,7 @@ class WebFlowView(flow.FlowView): ) def _recalculate(self, flows): - super(WebFlowView, self)._recalculate(flows) + super()._recalculate(flows) app.ClientConnection.broadcast( type="UPDATE_FLOWS", cmd="reset" @@ -61,7 +60,7 @@ class WebFlowView(flow.FlowView): class WebState(flow.State): def __init__(self): - super(WebState, self).__init__() + super().__init__() self.view._close() self.view = WebFlowView(self.flows) @@ -83,7 +82,7 @@ class WebState(flow.State): ) def clear(self): - super(WebState, self).clear() + super().clear() self.events.clear() app.ClientConnection.broadcast( type="UPDATE_EVENTLOG", @@ -111,7 +110,7 @@ class Options(options.Options): self.wsingleuser = wsingleuser self.whtpasswd = whtpasswd self.intercept = intercept - super(Options, self).__init__(**kwargs) + super().__init__(**kwargs) # TODO: This doesn't belong here. def process_web_options(self, parser): @@ -135,7 +134,7 @@ class Options(options.Options): class WebMaster(flow.FlowMaster): def __init__(self, server, options): - super(WebMaster, self).__init__(options, server, WebState()) + super().__init__(options, server, WebState()) self.addons.add(*builtins.default_addons()) self.app = app.Application( self, self.options.wdebug, self.options.wauthenticator @@ -187,19 +186,19 @@ class WebMaster(flow.FlowMaster): @controller.handler def request(self, f): - super(WebMaster, self).request(f) + super().request(f) return self._process_flow(f) @controller.handler def response(self, f): - super(WebMaster, self).response(f) + super().response(f) return self._process_flow(f) @controller.handler def error(self, f): - super(WebMaster, self).error(f) + super().error(f) return self._process_flow(f) def add_log(self, e, level="info"): - super(WebMaster, self).add_log(e, level) + super().add_log(e, level) return self.state.add_log(e, level) diff --git a/netlib/__init__.py b/netlib/__init__.py index 9b4faa337..e69de29bb 100644 --- a/netlib/__init__.py +++ b/netlib/__init__.py @@ -1 +0,0 @@ -from __future__ import (absolute_import, print_function, division) diff --git a/netlib/basethread.py b/netlib/basethread.py index 7963eb7e7..a3c81d196 100644 --- a/netlib/basethread.py +++ b/netlib/basethread.py @@ -4,7 +4,7 @@ import threading class BaseThread(threading.Thread): def __init__(self, name, *args, **kwargs): - super(BaseThread, self).__init__(name=name, *args, **kwargs) + super().__init__(name=name, *args, **kwargs) self._thread_started = time.time() def _threadinfo(self): diff --git a/netlib/certutils.py b/netlib/certutils.py index 340376d71..6a97f99ec 100644 --- a/netlib/certutils.py +++ b/netlib/certutils.py @@ -1,4 +1,3 @@ -from __future__ import (absolute_import, print_function, division) import os import ssl import time diff --git a/netlib/debug.py b/netlib/debug.py index 450b058a2..2f6e8770d 100644 --- a/netlib/debug.py +++ b/netlib/debug.py @@ -1,4 +1,3 @@ -from __future__ import (absolute_import, print_function, division) import gc import os diff --git a/netlib/encoding.py b/netlib/encoding.py index a6ae9a963..e123a0336 100644 --- a/netlib/encoding.py +++ b/netlib/encoding.py @@ -1,7 +1,6 @@ """ Utility functions for decoding response bodies. """ -from __future__ import absolute_import import codecs import collections diff --git a/netlib/exceptions.py b/netlib/exceptions.py index 1787cb727..d0b15d279 100644 --- a/netlib/exceptions.py +++ b/netlib/exceptions.py @@ -5,7 +5,6 @@ Every Exception netlib raises shall be a subclass of NetlibException. See also: http://lucumr.pocoo.org/2014/10/16/on-error-handling/ """ -from __future__ import absolute_import, print_function, division class NetlibException(Exception): @@ -13,7 +12,7 @@ class NetlibException(Exception): Base class for all exceptions thrown by netlib. """ def __init__(self, message=None): - super(NetlibException, self).__init__(message) + super().__init__(message) class Disconnect: diff --git a/netlib/http/__init__.py b/netlib/http/__init__.py index 436b59656..315f61ac9 100644 --- a/netlib/http/__init__.py +++ b/netlib/http/__init__.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division from netlib.http.request import Request from netlib.http.response import Response from netlib.http.message import Message diff --git a/netlib/http/authentication.py b/netlib/http/authentication.py index efaa7f532..a65279e47 100644 --- a/netlib/http/authentication.py +++ b/netlib/http/authentication.py @@ -1,4 +1,3 @@ -from __future__ import (absolute_import, print_function, division) import argparse import binascii diff --git a/netlib/http/headers.py b/netlib/http/headers.py index 7d46a88e4..b620c2c75 100644 --- a/netlib/http/headers.py +++ b/netlib/http/headers.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import re @@ -77,7 +76,7 @@ class Headers(multidict.MultiDict): If ``**headers`` contains multiple keys that have equal ``.lower()`` s, the behavior is undefined. """ - super(Headers, self).__init__(fields) + super().__init__(fields) for key, value in self.fields: if not isinstance(key, bytes) or not isinstance(value, bytes): @@ -108,10 +107,10 @@ class Headers(multidict.MultiDict): def __delitem__(self, key): key = _always_bytes(key) - super(Headers, self).__delitem__(key) + super().__delitem__(key) def __iter__(self): - for x in super(Headers, self).__iter__(): + for x in super().__iter__(): yield _native(x) def get_all(self, name): @@ -123,7 +122,7 @@ class Headers(multidict.MultiDict): name = _always_bytes(name) return [ _native(x) for x in - super(Headers, self).get_all(name) + super().get_all(name) ] def set_all(self, name, values): @@ -133,12 +132,12 @@ class Headers(multidict.MultiDict): """ name = _always_bytes(name) values = [_always_bytes(x) for x in values] - return super(Headers, self).set_all(name, values) + return super().set_all(name, values) def insert(self, index, key, value): key = _always_bytes(key) value = _always_bytes(value) - super(Headers, self).insert(index, key, value) + super().insert(index, key, value) def items(self, multi=False): if multi: @@ -147,7 +146,7 @@ class Headers(multidict.MultiDict): for k, v in self.fields ) else: - return super(Headers, self).items() + return super().items() def replace(self, pattern, repl, flags=0, count=0): """ diff --git a/netlib/http/http1/__init__.py b/netlib/http/http1/__init__.py index 2aa7e26a0..e4bf01c5c 100644 --- a/netlib/http/http1/__init__.py +++ b/netlib/http/http1/__init__.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division from .read import ( read_request, read_request_head, read_response, read_response_head, diff --git a/netlib/http/http1/assemble.py b/netlib/http/http1/assemble.py index e74732d2e..737a4ec94 100644 --- a/netlib/http/http1/assemble.py +++ b/netlib/http/http1/assemble.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import netlib.http.url from netlib import exceptions diff --git a/netlib/http/http1/read.py b/netlib/http/http1/read.py index 70fffbd4a..4c00a96ab 100644 --- a/netlib/http/http1/read.py +++ b/netlib/http/http1/read.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import time import sys import re diff --git a/netlib/http/http2/__init__.py b/netlib/http/http2/__init__.py index 7f84a1ab5..c99eb6cb6 100644 --- a/netlib/http/http2/__init__.py +++ b/netlib/http/http2/__init__.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division from netlib.http.http2.framereader import read_raw_frame, parse_frame from netlib.http.http2.utils import parse_headers diff --git a/netlib/http/message.py b/netlib/http/message.py index e693db1df..aa37cc587 100644 --- a/netlib/http/message.py +++ b/netlib/http/message.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import re import warnings diff --git a/netlib/http/request.py b/netlib/http/request.py index 7a83894b3..a9896ec73 100644 --- a/netlib/http/request.py +++ b/netlib/http/request.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import re import urllib @@ -65,7 +64,7 @@ class Request(message.Message): An HTTP request. """ def __init__(self, *args, **kwargs): - super(Request, self).__init__() + super().__init__() self.data = RequestData(*args, **kwargs) def __repr__(self): @@ -92,7 +91,7 @@ class Request(message.Message): if isinstance(repl, str): repl = strutils.escaped_str_to_bytes(repl) - c = super(Request, self).replace(pattern, repl, flags, count) + c = super().replace(pattern, repl, flags, count) self.path, pc = re.subn( pattern, repl, self.data.path, flags=flags, count=count ) diff --git a/netlib/http/response.py b/netlib/http/response.py index 02a93fa73..81beb81d8 100644 --- a/netlib/http/response.py +++ b/netlib/http/response.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import time from email.utils import parsedate_tz, formatdate, mktime_tz @@ -49,7 +48,7 @@ class Response(message.Message): An HTTP response. """ def __init__(self, *args, **kwargs): - super(Response, self).__init__() + super().__init__() self.data = ResponseData(*args, **kwargs) def __repr__(self): diff --git a/netlib/http/status_codes.py b/netlib/http/status_codes.py index 8a4dc1f52..55d337be7 100644 --- a/netlib/http/status_codes.py +++ b/netlib/http/status_codes.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division CONTINUE = 100 SWITCHING = 101 diff --git a/netlib/http/user_agents.py b/netlib/http/user_agents.py index e8681908a..4fd02e89b 100644 --- a/netlib/http/user_agents.py +++ b/netlib/http/user_agents.py @@ -1,4 +1,3 @@ -from __future__ import (absolute_import, print_function, division) """ A small collection of useful user-agent header strings. These should be diff --git a/netlib/multidict.py b/netlib/multidict.py index b86267314..72d88122f 100644 --- a/netlib/multidict.py +++ b/netlib/multidict.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division from abc import ABCMeta, abstractmethod @@ -163,7 +162,7 @@ class _MultiDict(MutableMapping, basetypes.Serializable, metaclass=ABCMeta): if multi: return self.fields else: - return super(_MultiDict, self).items() + return super().items() def collect(self): """ @@ -215,7 +214,7 @@ class _MultiDict(MutableMapping, basetypes.Serializable, metaclass=ABCMeta): class MultiDict(_MultiDict): def __init__(self, fields=()): - super(MultiDict, self).__init__() + super().__init__() self.fields = tuple( tuple(i) for i in fields ) @@ -244,6 +243,7 @@ class ImmutableMultiDict(MultiDict, metaclass=ABCMeta): An updated ImmutableMultiDict. The original object will not be modified. """ ret = self.copy() + # FIXME: This is filthy... super(ImmutableMultiDict, ret).__delitem__(key) return ret @@ -253,6 +253,7 @@ class ImmutableMultiDict(MultiDict, metaclass=ABCMeta): An updated ImmutableMultiDict. The original object will not be modified. """ ret = self.copy() + # FIXME: This is filthy... super(ImmutableMultiDict, ret).set_all(key, values) return ret @@ -262,6 +263,7 @@ class ImmutableMultiDict(MultiDict, metaclass=ABCMeta): An updated ImmutableMultiDict. The original object will not be modified. """ ret = self.copy() + # FIXME: This is filthy... super(ImmutableMultiDict, ret).insert(index, key, value) return ret @@ -275,7 +277,7 @@ class MultiDictView(_MultiDict): def __init__(self, getter, setter): self._getter = getter self._setter = setter - super(MultiDictView, self).__init__() + super().__init__() @staticmethod def _kconv(key): diff --git a/netlib/socks.py b/netlib/socks.py index 5b28a8cd0..9f1adb986 100644 --- a/netlib/socks.py +++ b/netlib/socks.py @@ -1,4 +1,3 @@ -from __future__ import (absolute_import, print_function, division) import struct import array import ipaddress @@ -8,7 +7,7 @@ from netlib import tcp, utils class SocksError(Exception): def __init__(self, code, message): - super(SocksError, self).__init__(message) + super().__init__(message) self.code = code VERSION = utils.BiDi( diff --git a/netlib/strutils.py b/netlib/strutils.py index 1f7db9490..57cfbc798 100644 --- a/netlib/strutils.py +++ b/netlib/strutils.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import re import codecs diff --git a/netlib/tcp.py b/netlib/tcp.py index 05ceef5a1..aeb1d4479 100644 --- a/netlib/tcp.py +++ b/netlib/tcp.py @@ -1,4 +1,3 @@ -from __future__ import (absolute_import, print_function, division) import os import select import socket @@ -597,7 +596,7 @@ class ConnectionCloser: class TCPClient(_Connection): def __init__(self, address, source_address=None, spoof_source_address=None): - super(TCPClient, self).__init__(None) + super().__init__(None) self.address = address self.source_address = source_address self.cert = None @@ -769,7 +768,7 @@ class BaseHandler(_Connection): """ def __init__(self, connection, address, server): - super(BaseHandler, self).__init__(connection) + super().__init__(connection) self.address = Address.wrap(address) self.server = server self.clientcert = None diff --git a/netlib/utils.py b/netlib/utils.py index 1a18dfcd4..8cd9ba6ea 100644 --- a/netlib/utils.py +++ b/netlib/utils.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import os.path import re import importlib diff --git a/netlib/version.py b/netlib/version.py index eea704841..c7ca8d011 100644 --- a/netlib/version.py +++ b/netlib/version.py @@ -1,4 +1,3 @@ -from __future__ import (absolute_import, print_function, division) IVERSION = (0, 19) VERSION = ".".join(str(i) for i in IVERSION) diff --git a/netlib/version_check.py b/netlib/version_check.py index 7091146da..547c031c8 100644 --- a/netlib/version_check.py +++ b/netlib/version_check.py @@ -3,7 +3,6 @@ Having installed a wrong version of pyOpenSSL or netlib is unfortunately a very common source of error. Check before every start that both versions are somewhat okay. """ -from __future__ import division, absolute_import, print_function import sys import inspect import os.path diff --git a/netlib/websockets/__init__.py b/netlib/websockets/__init__.py index e14e8a7d4..06c8f9bc6 100644 --- a/netlib/websockets/__init__.py +++ b/netlib/websockets/__init__.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division from .frame import FrameHeader from .frame import Frame diff --git a/netlib/websockets/frame.py b/netlib/websockets/frame.py index eb7d9ccdf..b58fa2897 100644 --- a/netlib/websockets/frame.py +++ b/netlib/websockets/frame.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import import os import struct import io diff --git a/netlib/websockets/masker.py b/netlib/websockets/masker.py index f4f489a61..1c8330b16 100644 --- a/netlib/websockets/masker.py +++ b/netlib/websockets/masker.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import class Masker: diff --git a/netlib/websockets/utils.py b/netlib/websockets/utils.py index aa0d39a1e..fdec074ed 100644 --- a/netlib/websockets/utils.py +++ b/netlib/websockets/utils.py @@ -3,7 +3,6 @@ Collection of WebSockets Protocol utility functions (RFC6455) Spec: https://tools.ietf.org/html/rfc6455 """ -from __future__ import absolute_import import base64 import hashlib diff --git a/netlib/wsgi.py b/netlib/wsgi.py index 07e0c9db6..8e8445f62 100644 --- a/netlib/wsgi.py +++ b/netlib/wsgi.py @@ -1,4 +1,3 @@ -from __future__ import (absolute_import, print_function, division) import time import traceback diff --git a/pathod/language/__init__.py b/pathod/language/__init__.py index 15c2895bf..b7897ed2f 100644 --- a/pathod/language/__init__.py +++ b/pathod/language/__init__.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import import itertools import time diff --git a/pathod/pathoc.py b/pathod/pathoc.py index 1f81ed598..e3b4d1ae2 100644 --- a/pathod/pathoc.py +++ b/pathod/pathoc.py @@ -1,4 +1,3 @@ -from __future__ import print_function import contextlib import sys import os diff --git a/pathod/pathoc_cmdline.py b/pathod/pathoc_cmdline.py index 4199e37a9..ab330505b 100644 --- a/pathod/pathoc_cmdline.py +++ b/pathod/pathoc_cmdline.py @@ -1,4 +1,3 @@ -from __future__ import print_function import sys import argparse import os diff --git a/pathod/pathod.py b/pathod/pathod.py index fe8635ea8..0f659d401 100644 --- a/pathod/pathod.py +++ b/pathod/pathod.py @@ -1,4 +1,3 @@ -from __future__ import print_function import copy import logging import os diff --git a/pathod/protocols/http2.py b/pathod/protocols/http2.py index dcd17ebab..69f49c634 100644 --- a/pathod/protocols/http2.py +++ b/pathod/protocols/http2.py @@ -1,4 +1,3 @@ -from __future__ import (absolute_import, print_function, division) import itertools import time diff --git a/release/rtool.py b/release/rtool.py index 45e1416e6..3ed9157e0 100755 --- a/release/rtool.py +++ b/release/rtool.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -from __future__ import absolute_import, print_function, division import contextlib import fnmatch diff --git a/test/mitmproxy/__init__.py b/test/mitmproxy/__init__.py index 61d03152d..fdb35964b 100644 --- a/test/mitmproxy/__init__.py +++ b/test/mitmproxy/__init__.py @@ -1,4 +1,3 @@ -from __future__ import (print_function, absolute_import, division) # Silence third-party modules import logging diff --git a/test/mitmproxy/builtins/test_filestreamer.py b/test/mitmproxy/builtins/test_filestreamer.py index 7964c69ac..6de2d8e7c 100644 --- a/test/mitmproxy/builtins/test_filestreamer.py +++ b/test/mitmproxy/builtins/test_filestreamer.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division from .. import tutils, mastertest diff --git a/test/mitmproxy/protocol/test_http1.py b/test/mitmproxy/protocol/test_http1.py index d2c473d73..e6346d721 100644 --- a/test/mitmproxy/protocol/test_http1.py +++ b/test/mitmproxy/protocol/test_http1.py @@ -1,4 +1,3 @@ -from __future__ import (absolute_import, print_function, division) from netlib.http import http1 from netlib.tcp import TCPClient diff --git a/test/mitmproxy/protocol/test_http2.py b/test/mitmproxy/protocol/test_http2.py index 3a222c109..e6b13a05e 100644 --- a/test/mitmproxy/protocol/test_http2.py +++ b/test/mitmproxy/protocol/test_http2.py @@ -1,6 +1,5 @@ # coding=utf-8 -from __future__ import (absolute_import, print_function, division) import pytest import os diff --git a/test/mitmproxy/protocol/test_websockets.py b/test/mitmproxy/protocol/test_websockets.py index 094d9298b..88145b30c 100644 --- a/test/mitmproxy/protocol/test_websockets.py +++ b/test/mitmproxy/protocol/test_websockets.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import pytest import os diff --git a/test/mitmproxy/test_addons.py b/test/mitmproxy/test_addons.py index c5d54e8c5..eb35d15b6 100644 --- a/test/mitmproxy/test_addons.py +++ b/test/mitmproxy/test_addons.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division from mitmproxy import addons from mitmproxy import controller from mitmproxy import options diff --git a/test/mitmproxy/test_controller.py b/test/mitmproxy/test_controller.py index 84f762e6e..d4368d074 100644 --- a/test/mitmproxy/test_controller.py +++ b/test/mitmproxy/test_controller.py @@ -24,7 +24,7 @@ class TestMaster: def tick(self, timeout): # Speed up test - super(DummyMaster, self).tick(0) + super().tick(0) m = DummyMaster(None) assert not m.should_exit.is_set() diff --git a/test/mitmproxy/test_optmanager.py b/test/mitmproxy/test_optmanager.py index 8414e6b59..1d677bd3b 100644 --- a/test/mitmproxy/test_optmanager.py +++ b/test/mitmproxy/test_optmanager.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import copy from mitmproxy import optmanager @@ -10,7 +9,7 @@ class TO(optmanager.OptManager): def __init__(self, one=None, two=None): self.one = one self.two = two - super(TO, self).__init__() + super().__init__() def test_options(): diff --git a/test/mitmproxy/test_server.py b/test/mitmproxy/test_server.py index ec59fbdfe..923d8ccf1 100644 --- a/test/mitmproxy/test_server.py +++ b/test/mitmproxy/test_server.py @@ -449,7 +449,7 @@ class TestHTTPSUpstreamServerVerificationWBadCert(tservers.HTTPProxyTest): @classmethod def get_options(cls): - opts = super(tservers.HTTPProxyTest, cls).get_options() + opts = super().get_options() opts.ssl_verify_upstream_trusted_ca = tutils.test_data.path( "data/servercert/trusted-root.pem" ) @@ -540,7 +540,7 @@ class TestHttps2Http(tservers.ReverseProxyTest): @classmethod def get_options(cls): - opts = super(TestHttps2Http, cls).get_options() + opts = super().get_options() s = parse_server_spec(opts.upstream_server) opts.upstream_server = "http://%s" % s.address return opts @@ -700,13 +700,13 @@ class MasterRedirectRequest(tservers.TestMaster): # This is the actual redirection. f.request.port = self.redirect_port - super(MasterRedirectRequest, self).request(f) + super().request(f) @controller.handler def response(self, f): f.response.content = bytes(f.client_conn.address.port) f.response.headers["server-conn-id"] = str(f.server_conn.source_address.port) - super(MasterRedirectRequest, self).response(f) + super().response(f) class TestRedirectRequest(tservers.HTTPProxyTest): @@ -954,19 +954,19 @@ class TestUpstreamProxySSL( delattr(self, "_ignore_%s_backup" % attr) def _ignore_on(self): - super(TestUpstreamProxySSL, self)._ignore_on() + super()._ignore_on() self._host_pattern_on("ignore") def _ignore_off(self): - super(TestUpstreamProxySSL, self)._ignore_off() + super()._ignore_off() self._host_pattern_off("ignore") def _tcpproxy_on(self): - super(TestUpstreamProxySSL, self)._tcpproxy_on() + super()._tcpproxy_on() self._host_pattern_on("tcp") def _tcpproxy_off(self): - super(TestUpstreamProxySSL, self)._tcpproxy_off() + super()._tcpproxy_off() self._host_pattern_off("tcp") def test_simple(self): @@ -1110,7 +1110,7 @@ class TestHTTPSAddUpstreamCertsToClientChainTrue( """ @classmethod def get_options(cls): - opts = super(tservers.HTTPProxyTest, cls).get_options() + opts = super().get_options() opts.add_upstream_certs_to_client_chain = True return opts @@ -1125,6 +1125,6 @@ class TestHTTPSAddUpstreamCertsToClientChainFalse( """ @classmethod def get_options(cls): - opts = super(tservers.HTTPProxyTest, cls).get_options() + opts = super().get_options() opts.add_upstream_certs_to_client_chain = False return opts diff --git a/test/mitmproxy/tools/bench.py b/test/mitmproxy/tools/bench.py index 8127d083a..fb75ef464 100644 --- a/test/mitmproxy/tools/bench.py +++ b/test/mitmproxy/tools/bench.py @@ -1,4 +1,3 @@ -from __future__ import print_function import requests import time diff --git a/test/mitmproxy/tools/benchtool.py b/test/mitmproxy/tools/benchtool.py index 170436769..bc68645cd 100644 --- a/test/mitmproxy/tools/benchtool.py +++ b/test/mitmproxy/tools/benchtool.py @@ -18,7 +18,7 @@ class ApacheBenchThread(Thread): def __init__(self, concurrency): self.concurrency = concurrency - super(ApacheBenchThread, self).__init__() + super().__init__() def run(self): time.sleep(2) diff --git a/test/mitmproxy/tservers.py b/test/mitmproxy/tservers.py index 6796e2430..431e0f90f 100644 --- a/test/mitmproxy/tservers.py +++ b/test/mitmproxy/tservers.py @@ -203,7 +203,7 @@ class TransparentProxyTest(ProxyTestBase): @classmethod def setup_class(cls): - super(TransparentProxyTest, cls).setup_class() + super().setup_class() cls._resolver = mock.patch( "mitmproxy.platform.resolver", @@ -214,7 +214,7 @@ class TransparentProxyTest(ProxyTestBase): @classmethod def teardown_class(cls): cls._resolver.stop() - super(TransparentProxyTest, cls).teardown_class() + super().teardown_class() @classmethod def get_options(cls): @@ -308,7 +308,7 @@ class ChainProxyTest(ProxyTestBase): @classmethod def setup_class(cls): cls.chain = [] - super(ChainProxyTest, cls).setup_class() + super().setup_class() for _ in range(cls.n): opts = cls.get_options() config = ProxyConfig(opts) @@ -323,19 +323,19 @@ class ChainProxyTest(ProxyTestBase): @classmethod def teardown_class(cls): - super(ChainProxyTest, cls).teardown_class() + super().teardown_class() for proxy in cls.chain: proxy.shutdown() def setup(self): - super(ChainProxyTest, self).setup() + super().setup() for proxy in self.chain: proxy.tmaster.clear_log() proxy.tmaster.state.clear() @classmethod def get_options(cls): - opts = super(ChainProxyTest, cls).get_options() + opts = super().get_options() if cls.chain: # First proxy is in normal mode. opts.update( mode="upstream", diff --git a/test/mitmproxy/tutils.py b/test/mitmproxy/tutils.py index 575dacf03..2869a5f50 100644 --- a/test/mitmproxy/tutils.py +++ b/test/mitmproxy/tutils.py @@ -52,7 +52,7 @@ class DummyFlow(Flow): """A flow that is neither HTTP nor TCP.""" def __init__(self, client_conn, server_conn, live=None): - super(DummyFlow, self).__init__("dummy", client_conn, server_conn, live) + super().__init__("dummy", client_conn, server_conn, live) def tdummyflow(client_conn=True, server_conn=True, err=None): diff --git a/test/netlib/http/http1/test_assemble.py b/test/netlib/http/http1/test_assemble.py index 841ea58a1..5d7e007e0 100644 --- a/test/netlib/http/http1/test_assemble.py +++ b/test/netlib/http/http1/test_assemble.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division from netlib.exceptions import HttpException from netlib.http import Headers from netlib.http.http1.assemble import ( diff --git a/test/netlib/http/http1/test_read.py b/test/netlib/http/http1/test_read.py index a768a722a..86480e2bb 100644 --- a/test/netlib/http/http1/test_read.py +++ b/test/netlib/http/http1/test_read.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division from io import BytesIO from mock import Mock diff --git a/test/netlib/http/test_message.py b/test/netlib/http/test_message.py index dd08e0188..8374f8f62 100644 --- a/test/netlib/http/test_message.py +++ b/test/netlib/http/test_message.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, division from netlib.tutils import tresp from netlib import http, tutils diff --git a/test/netlib/http/test_request.py b/test/netlib/http/test_request.py index e091f280b..87eb9c351 100644 --- a/test/netlib/http/test_request.py +++ b/test/netlib/http/test_request.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, division from netlib.http import Headers from netlib.tutils import treq, raises diff --git a/test/netlib/http/test_response.py b/test/netlib/http/test_response.py index 66d6e307d..bf08e6f28 100644 --- a/test/netlib/http/test_response.py +++ b/test/netlib/http/test_response.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, print_function, division import email diff --git a/test/netlib/test_debug.py b/test/netlib/test_debug.py index 4732125b0..bdb85c9e1 100644 --- a/test/netlib/test_debug.py +++ b/test/netlib/test_debug.py @@ -1,4 +1,3 @@ -from __future__ import (absolute_import, print_function, division) import io from netlib import debug diff --git a/test/netlib/tservers.py b/test/netlib/tservers.py index fdf40ff30..e24506ee7 100644 --- a/test/netlib/tservers.py +++ b/test/netlib/tservers.py @@ -1,4 +1,3 @@ -from __future__ import (absolute_import, print_function, division) import threading import queue diff --git a/test/pathod/__init__.py b/test/pathod/__init__.py index 3f5dc124c..e69de29bb 100644 --- a/test/pathod/__init__.py +++ b/test/pathod/__init__.py @@ -1 +0,0 @@ -from __future__ import (print_function, absolute_import, division)