aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@corte.si>2016-10-17 18:21:23 +1300
committerGitHub <noreply@github.com>2016-10-17 18:21:23 +1300
commit00071238d2e79ff91132b7e5a3bcc8019d9191ec (patch)
tree507c346e8f8c605d428140274678fced2e6bbc16
parent666c59cbfbcbd28062c201c3cb5d6cb928e90aee (diff)
parentc774a9fec93feedc37a450400a03b83f5f4cb4b9 (diff)
downloadmitmproxy-00071238d2e79ff91132b7e5a3bcc8019d9191ec.tar.gz
mitmproxy-00071238d2e79ff91132b7e5a3bcc8019d9191ec.tar.bz2
mitmproxy-00071238d2e79ff91132b7e5a3bcc8019d9191ec.zip
Merge pull request #1617 from cortesi/object
python3
-rw-r--r--examples/mitmproxywrapper.py2
-rw-r--r--examples/tls_passthrough.py3
-rw-r--r--mitmproxy/addons.py3
-rw-r--r--mitmproxy/builtins/__init__.py1
-rw-r--r--mitmproxy/builtins/anticache.py1
-rw-r--r--mitmproxy/builtins/anticomp.py1
-rw-r--r--mitmproxy/builtins/dumper.py3
-rw-r--r--mitmproxy/builtins/filestreamer.py1
-rw-r--r--mitmproxy/builtins/script.py3
-rw-r--r--mitmproxy/builtins/serverplayback.py3
-rw-r--r--mitmproxy/builtins/stickyauth.py1
-rw-r--r--mitmproxy/builtins/termlog.py1
-rw-r--r--mitmproxy/cmdline.py1
-rw-r--r--mitmproxy/console/common.py1
-rw-r--r--mitmproxy/console/flowdetailview.py1
-rw-r--r--mitmproxy/console/flowlist.py3
-rw-r--r--mitmproxy/console/flowview.py5
-rw-r--r--mitmproxy/console/grideditor/base.py11
-rw-r--r--mitmproxy/console/grideditor/col_bytes.py5
-rw-r--r--mitmproxy/console/grideditor/col_subgrid.py5
-rw-r--r--mitmproxy/console/grideditor/col_text.py12
-rw-r--r--mitmproxy/console/grideditor/editors.py5
-rw-r--r--mitmproxy/console/help.py1
-rw-r--r--mitmproxy/console/master.py21
-rw-r--r--mitmproxy/console/options.py5
-rw-r--r--mitmproxy/console/palettepicker.py1
-rw-r--r--mitmproxy/console/palettes.py1
-rw-r--r--mitmproxy/console/pathedit.py1
-rw-r--r--mitmproxy/console/searchable.py3
-rw-r--r--mitmproxy/console/select.py3
-rw-r--r--mitmproxy/console/signals.py1
-rw-r--r--mitmproxy/console/statusbar.py3
-rw-r--r--mitmproxy/console/tabs.py3
-rw-r--r--mitmproxy/console/window.py5
-rw-r--r--mitmproxy/contentviews.py6
-rw-r--r--mitmproxy/contrib/tls/__init__.py1
-rw-r--r--mitmproxy/contrib/tls/_constructs.py1
-rw-r--r--mitmproxy/contrib/tls/utils.py1
-rw-r--r--mitmproxy/contrib/wbxml/ASWBXMLCodePage.py2
-rw-r--r--mitmproxy/contrib/wbxml/GlobalTokens.py2
-rw-r--r--mitmproxy/contrib/wbxml/InvalidDataException.py2
-rw-r--r--mitmproxy/controller.py15
-rw-r--r--mitmproxy/dump.py5
-rw-r--r--mitmproxy/exceptions.py5
-rw-r--r--mitmproxy/flow/__init__.py1
-rw-r--r--mitmproxy/flow/export.py1
-rw-r--r--mitmproxy/flow/io.py1
-rw-r--r--mitmproxy/flow/io_compat.py1
-rw-r--r--mitmproxy/flow/master.py3
-rw-r--r--mitmproxy/flow/modules.py3
-rw-r--r--mitmproxy/flow/state.py7
-rw-r--r--mitmproxy/flowfilter.py9
-rw-r--r--mitmproxy/main.py1
-rw-r--r--mitmproxy/models/__init__.py1
-rw-r--r--mitmproxy/models/connections.py7
-rw-r--r--mitmproxy/models/flow.py5
-rw-r--r--mitmproxy/models/http.py9
-rw-r--r--mitmproxy/models/tcp.py3
-rw-r--r--mitmproxy/onboarding/app.py1
-rw-r--r--mitmproxy/options.py3
-rw-r--r--mitmproxy/optmanager.py5
-rw-r--r--mitmproxy/platform/linux.py2
-rw-r--r--mitmproxy/platform/osx.py2
-rw-r--r--mitmproxy/platform/windows.py4
-rw-r--r--mitmproxy/protocol/__init__.py1
-rw-r--r--mitmproxy/protocol/base.py11
-rw-r--r--mitmproxy/protocol/http.py7
-rw-r--r--mitmproxy/protocol/http1.py3
-rw-r--r--mitmproxy/protocol/http2.py7
-rw-r--r--mitmproxy/protocol/http_replay.py3
-rw-r--r--mitmproxy/protocol/rawtcp.py3
-rw-r--r--mitmproxy/protocol/tls.py5
-rw-r--r--mitmproxy/protocol/websockets.py3
-rw-r--r--mitmproxy/proxy/__init__.py1
-rw-r--r--mitmproxy/proxy/config.py3
-rw-r--r--mitmproxy/proxy/modes/__init__.py1
-rw-r--r--mitmproxy/proxy/modes/http_proxy.py3
-rw-r--r--mitmproxy/proxy/modes/reverse_proxy.py3
-rw-r--r--mitmproxy/proxy/modes/socks_proxy.py3
-rw-r--r--mitmproxy/proxy/modes/transparent_proxy.py3
-rw-r--r--mitmproxy/proxy/root_context.py3
-rw-r--r--mitmproxy/proxy/server.py5
-rw-r--r--mitmproxy/script/concurrent.py1
-rw-r--r--mitmproxy/stateobject.py1
-rw-r--r--mitmproxy/utils.py1
-rw-r--r--mitmproxy/web/app.py9
-rw-r--r--mitmproxy/web/master.py27
-rw-r--r--netlib/__init__.py1
-rw-r--r--netlib/basethread.py2
-rw-r--r--netlib/certutils.py5
-rw-r--r--netlib/debug.py1
-rw-r--r--netlib/encoding.py1
-rw-r--r--netlib/exceptions.py5
-rw-r--r--netlib/http/__init__.py1
-rw-r--r--netlib/http/authentication.py5
-rw-r--r--netlib/http/headers.py15
-rw-r--r--netlib/http/http1/__init__.py1
-rw-r--r--netlib/http/http1/assemble.py1
-rw-r--r--netlib/http/http1/read.py1
-rw-r--r--netlib/http/http2/__init__.py1
-rw-r--r--netlib/http/message.py3
-rw-r--r--netlib/http/request.py5
-rw-r--r--netlib/http/response.py3
-rw-r--r--netlib/http/status_codes.py1
-rw-r--r--netlib/http/user_agents.py1
-rw-r--r--netlib/multidict.py10
-rw-r--r--netlib/socks.py13
-rw-r--r--netlib/strutils.py1
-rw-r--r--netlib/tcp.py15
-rw-r--r--netlib/tutils.py2
-rw-r--r--netlib/utils.py5
-rw-r--r--netlib/version.py1
-rw-r--r--netlib/version_check.py1
-rw-r--r--netlib/websockets/__init__.py1
-rw-r--r--netlib/websockets/frame.py5
-rw-r--r--netlib/websockets/masker.py3
-rw-r--r--netlib/websockets/utils.py1
-rw-r--r--netlib/wsgi.py9
-rw-r--r--pathod/language/__init__.py1
-rw-r--r--pathod/language/base.py4
-rw-r--r--pathod/language/generators.py6
-rw-r--r--pathod/language/http.py2
-rw-r--r--pathod/language/http2.py2
-rw-r--r--pathod/language/message.py2
-rw-r--r--pathod/log.py2
-rw-r--r--pathod/pathoc.py3
-rw-r--r--pathod/pathoc_cmdline.py1
-rw-r--r--pathod/pathod.py3
-rw-r--r--pathod/protocols/http.py2
-rw-r--r--pathod/protocols/http2.py7
-rw-r--r--pathod/utils.py2
-rwxr-xr-xrelease/rtool.py1
-rw-r--r--test/mitmproxy/__init__.py1
-rw-r--r--test/mitmproxy/builtins/test_filestreamer.py1
-rw-r--r--test/mitmproxy/console/test_pathedit.py2
-rw-r--r--test/mitmproxy/protocol/test_http1.py3
-rw-r--r--test/mitmproxy/protocol/test_http2.py3
-rw-r--r--test/mitmproxy/protocol/test_websockets.py3
-rw-r--r--test/mitmproxy/test_addons.py1
-rw-r--r--test/mitmproxy/test_controller.py12
-rw-r--r--test/mitmproxy/test_examples.py2
-rw-r--r--test/mitmproxy/test_flow.py2
-rw-r--r--test/mitmproxy/test_flow_export.py12
-rw-r--r--test/mitmproxy/test_optmanager.py3
-rw-r--r--test/mitmproxy/test_proxy.py2
-rw-r--r--test/mitmproxy/test_server.py20
-rw-r--r--test/mitmproxy/tools/bench.py1
-rw-r--r--test/mitmproxy/tools/benchtool.py2
-rw-r--r--test/mitmproxy/tservers.py14
-rw-r--r--test/mitmproxy/tutils.py2
-rw-r--r--test/netlib/http/http1/test_assemble.py1
-rw-r--r--test/netlib/http/http1/test_read.py5
-rw-r--r--test/netlib/http/test_headers.py2
-rw-r--r--test/netlib/http/test_message.py9
-rw-r--r--test/netlib/http/test_request.py7
-rw-r--r--test/netlib/http/test_response.py7
-rw-r--r--test/netlib/test_debug.py1
-rw-r--r--test/netlib/test_multidict.py10
-rw-r--r--test/netlib/tservers.py3
-rw-r--r--test/netlib/websockets/test_frame.py4
-rw-r--r--test/netlib/websockets/test_masker.py2
-rw-r--r--test/netlib/websockets/test_utils.py2
-rw-r--r--test/pathod/__init__.py1
-rw-r--r--test/pathod/test_language_base.py2
-rw-r--r--test/pathod/test_pathod.py2
-rw-r--r--test/pathod/test_protocols_http2.py12
-rw-r--r--test/pathod/tutils.py2
167 files changed, 261 insertions, 391 deletions
diff --git a/examples/mitmproxywrapper.py b/examples/mitmproxywrapper.py
index 6841d05f..eade0fe2 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 20e8f9be..445ea5c3 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
@@ -38,7 +37,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 b575b607..5b078129 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
@@ -7,7 +6,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/__init__.py b/mitmproxy/builtins/__init__.py
index 26e9dfbd..1071f2e7 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 41a5ed95..05192f12 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 823e960c..9283d9c9 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 109059b8..ddf84889 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
@@ -20,7 +19,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/filestreamer.py b/mitmproxy/builtins/filestreamer.py
index bf5eedee..b1643b21 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 9bf25703..aef8e480 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
@@ -215,7 +214,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 b495bc27..383e2754 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
@@ -6,7 +5,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/builtins/stickyauth.py b/mitmproxy/builtins/stickyauth.py
index 18b43967..540b717a 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 c8259f0c..3dbb869b 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 e97be5d4..705aed74 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 e1366c1e..5e335c71 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 0a03e1c4..64fdd40b 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 73c8ade5..70ce6cb6 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 3b43fd49..8e041405 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 de1c0cf6..5825e50c 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
@@ -35,7 +34,7 @@ class Cell(urwid.WidgetWrap):
return True
-class Column(object, metaclass=abc.ABCMeta):
+class Column(metaclass=abc.ABCMeta):
subeditor = None
def __init__(self, heading):
@@ -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 43d813be..51ce5a50 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 1dec8032..8a08f838 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 29c1abac..ae15374c 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):
@@ -26,14 +25,15 @@ 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)
+ 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 0c9a2a02..7a1ef097 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 7393d7c4..06579206 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 e7d74e2e..5f31cb74 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 97313bf4..c4d9d872 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 f2acba0a..2bcb7387 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 2e12338f..7b15f98f 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 0eae9123..2255c679 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 d58d3d13..0fd6debc 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 091f07a2..d5a3c42a 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 93eb399f..b5d3111f 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 9536abe7..c43f68ad 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 a5e9c510..e2c2f6b9 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 ab2c80ad..a3a94933 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 24c4d396..9a70b104 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
@@ -93,7 +92,7 @@ def format_text(text):
yield [("text", line)]
-class View(object):
+class View:
name = None
prompt = ()
content_types = []
@@ -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 4b540884..450986f7 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 4cb7d382..f599f0fd 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 87afbacb..ff442387 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 2f9d8717..1d00afd4 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 41310fb1..85d5e558 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 67f8ea93..e9e3e087 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 579cf92d..214dbd4c 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
@@ -41,13 +40,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 +81,7 @@ class Log(object):
self.master.add_log(text, level)
-class Master(object):
+class Master:
"""
The master handles mitmproxy's main event loop.
"""
@@ -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))
)
@@ -185,7 +184,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 +271,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
@@ -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 87f5783c..dfe5309b 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 7fca584a..b696c91f 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 c857352c..f7e83e8a 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 603bf85a..a73bda5b 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 f48d494f..cc28998b 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 31d5ed51..fc190e2f 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 a1b0a631..c05eb9d1 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 7d8a282e..c6fe3773 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
@@ -32,7 +31,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 f6395c79..084b798d 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()
@@ -177,7 +176,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 cdbaf316..b63c27d9 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
@@ -58,7 +57,7 @@ def only(*types):
return decorator
-class _Token(object):
+class _Token:
def dump(self, indent=0, fp=sys.stdout):
print("{spacing}{name}{expr}".format(
@@ -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 e39742f3..5a7fef2c 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 7b7eaef0..25319b2d 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 a99327d8..bf7a12aa 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 95a5a699..2379b391 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 a76d8b91..e679205d 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 e33475c2..1be23d79 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 ecfe4ed5..b4ec4c84 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 143c24ba..c98b3aea 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 92d32b2d..45e02c60 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
@@ -11,7 +10,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
@@ -25,7 +24,7 @@ class OptManager(object):
# 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/platform/linux.py b/mitmproxy/platform/linux.py
index 38bfbe42..8dfd2f81 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 6a555f32..4b74f62b 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 54d29c72..01f20dc1 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/__init__.py b/mitmproxy/protocol/__init__.py
index 5bf259ae..89b60386 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 b280ec35..4c824179 100644
--- a/mitmproxy/protocol/base.py
+++ b/mitmproxy/protocol/base.py
@@ -1,18 +1,17 @@
-from __future__ import absolute_import, print_function, division
import netlib.exceptions
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.
"""
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.
@@ -88,7 +87,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.
@@ -109,7 +108,7 @@ class ServerConnectionMixin(object):
"""
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 54b61199..7f00933e 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
@@ -61,7 +60,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.
@@ -85,7 +84,7 @@ class ConnectServerConnection(object):
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 2f8a15de..a74e5d62 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 ffc55684..756acc9f 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 0f027431..9f23832d 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 069420ea..ecbe80c9 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 203d9c29..bd650ef4 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
@@ -248,7 +247,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)
@@ -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 7ac386f1..73f0a37d 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 e3d249fa..f48c3d61 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 bd1c3f62..f92e3b63 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
@@ -20,7 +19,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/modes/__init__.py b/mitmproxy/proxy/modes/__init__.py
index fa62570c..ebe23b8c 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 bc64ccd2..4ec3b578 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 3739ac0e..1a6f7d3d 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 19437835..e9e684b3 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 c7df7900..c29e7b06 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 d3f3c6df..4bfe87b2 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
@@ -7,7 +6,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 0fedaa74..d1ec4e0a 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:
@@ -62,7 +61,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/script/concurrent.py b/mitmproxy/script/concurrent.py
index 9ed08065..11b2144e 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 a38315c1..1ed8675a 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 1c75dd83..034f57d8 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 ea2203ee..0d573ec7 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
@@ -73,7 +72,7 @@ class APIError(tornado.web.HTTPError):
pass
-class BasicAuth(object):
+class BasicAuth:
def set_auth_headers(self):
self.set_status(401)
@@ -98,7 +97,7 @@ class BasicAuth(object):
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 8500c0cb..0a237532 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 9b4faa33..e69de29b 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 7963eb7e..a3c81d19 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 23836cb5..6a97f99e 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
@@ -155,7 +154,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 +162,7 @@ class CertStoreEntry(object):
self.chain_file = chain_file
-class CertStore(object):
+class CertStore:
"""
Implements an in-memory certificate store.
diff --git a/netlib/debug.py b/netlib/debug.py
index 450b058a..2f6e8770 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 a6ae9a96..e123a033 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 dec79c22..d0b15d27 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,10 +12,10 @@ 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(object):
+class Disconnect:
"""Immediate EOF"""
diff --git a/netlib/http/__init__.py b/netlib/http/__init__.py
index 436b5965..315f61ac 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 58fc9bdc..a65279e4 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
@@ -23,7 +22,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 +89,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/headers.py b/netlib/http/headers.py
index 7d46a88e..b620c2c7 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 2aa7e26a..e4bf01c5 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 e74732d2..737a4ec9 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 70fffbd4..4c00a96a 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 7f84a1ab..c99eb6cb 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 e44faf18..aa37cc58 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
@@ -283,7 +282,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/http/request.py b/netlib/http/request.py
index 7a83894b..a9896ec7 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 02a93fa7..81beb81d 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 8a4dc1f5..55d337be 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 e8681908..4fd02e89 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 b8626731..72d88122 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 8d7c5279..9f1adb98 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(
@@ -52,7 +51,7 @@ USERNAME_PASSWORD_VERSION = utils.BiDi(
)
-class ClientGreeting(object):
+class ClientGreeting:
__slots__ = ("ver", "methods")
def __init__(self, ver, methods):
@@ -89,7 +88,7 @@ class ClientGreeting(object):
f.write(self.methods.tostring())
-class ServerGreeting(object):
+class ServerGreeting:
__slots__ = ("ver", "method")
def __init__(self, ver, method):
@@ -117,7 +116,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 +146,7 @@ class UsernamePasswordAuth(object):
f.write(self.password.encode())
-class UsernamePasswordAuthResponse(object):
+class UsernamePasswordAuthResponse:
__slots__ = ("ver", "status")
def __init__(self, ver, status):
@@ -170,7 +169,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/strutils.py b/netlib/strutils.py
index 1f7db949..57cfbc79 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 e4e134c4..aeb1d447 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
@@ -72,7 +71,7 @@ sslversion_choices = {
}
-class SSLKeyLogger(object):
+class SSLKeyLogger:
def __init__(self, filename):
self.filename = filename
@@ -111,7 +110,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 +425,7 @@ def close_socket(sock):
sock.close()
-class _Connection(object):
+class _Connection:
rbufsize = -1
wbufsize = -1
@@ -574,7 +573,7 @@ class _Connection(object):
return context
-class ConnectionCloser(object):
+class ConnectionCloser:
def __init__(self, conn):
self.conn = conn
self._canceled = False
@@ -597,7 +596,7 @@ class ConnectionCloser(object):
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
@@ -888,7 +887,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 5f598fa9..d22fdd1c 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 8a8b15ea..8cd9ba6e 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
@@ -20,7 +19,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 +48,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/version.py b/netlib/version.py
index eea70484..c7ca8d01 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 7091146d..547c031c 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 e14e8a7d..06c8f9bc 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 2b36d461..b58fa289 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
@@ -43,7 +42,7 @@ CLOSE_REASON = utils.BiDi(
)
-class FrameHeader(object):
+class FrameHeader:
def __init__(
self,
@@ -193,7 +192,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 03b8f435..1c8330b1 100644
--- a/netlib/websockets/masker.py
+++ b/netlib/websockets/masker.py
@@ -1,7 +1,6 @@
-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/websockets/utils.py b/netlib/websockets/utils.py
index aa0d39a1..fdec074e 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 17cbbf00..8e8445f6 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
@@ -8,20 +7,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 +46,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/__init__.py b/pathod/language/__init__.py
index 15c2895b..b7897ed2 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/language/base.py b/pathod/language/base.py
index bdcc6d2f..11f0899d 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 4040e099..4e19ecd9 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 46027ca3..8b5fa828 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 519ee699..35fc5ba8 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 fea4f4de..03b4a2cf 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 1a709dc6..37100bb1 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 f122c14f..e3b4d1ae 100644
--- a/pathod/pathoc.py
+++ b/pathod/pathoc.py
@@ -1,4 +1,3 @@
-from __future__ import print_function
import contextlib
import sys
import os
@@ -34,7 +33,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/pathoc_cmdline.py b/pathod/pathoc_cmdline.py
index 4199e37a..ab330505 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 e882b73e..0f659d40 100644
--- a/pathod/pathod.py
+++ b/pathod/pathod.py
@@ -1,4 +1,3 @@
-from __future__ import print_function
import copy
import logging
import os
@@ -30,7 +29,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 2ede2591..17930320 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 78fe6111..69f49c63 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
@@ -15,14 +14,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 +402,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 9b220e9a..2d077c48 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/release/rtool.py b/release/rtool.py
index 45e1416e..3ed9157e 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 61d03152..fdb35964 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 7964c69a..6de2d8e7 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/console/test_pathedit.py b/test/mitmproxy/console/test_pathedit.py
index ff6ef846..45c69a38 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 2fc4ac63..e6346d72 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
@@ -6,7 +5,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 c4bd2049..e6b13a05 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
@@ -89,7 +88,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 e2361d89..88145b30 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
@@ -44,7 +43,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_addons.py b/test/mitmproxy/test_addons.py
index c5d54e8c..eb35d15b 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 660ce111..d4368d07 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
@@ -24,7 +24,7 @@ class TestMaster(object):
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()
@@ -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_examples.py b/test/mitmproxy/test_examples.py
index 81e8801c..05b7544f 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 cc9d2691..38d61afe 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_flow_export.py b/test/mitmproxy/test_flow_export.py
index 86ff937d..920f538b 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_optmanager.py b/test/mitmproxy/test_optmanager.py
index 8414e6b5..1d677bd3 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_proxy.py b/test/mitmproxy/test_proxy.py
index f7c64e50..5904ce5b 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/test_server.py b/test/mitmproxy/test_server.py
index ec59fbdf..923d8ccf 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 8127d083..fb75ef46 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 17043676..bc68645c 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 d3806a99..431e0f90 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
@@ -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 575dacf0..2869a5f5 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 841ea58a..5d7e007e 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 44eff2ee..86480e2b 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
@@ -104,7 +103,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 +288,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 e8752c52..63f16897 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 5d533ad7..8374f8f6 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
@@ -36,7 +35,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 +49,7 @@ class TestMessageData(object):
assert data != 0
-class TestMessage(object):
+class TestMessage:
def test_init(self):
resp = tresp()
@@ -108,7 +107,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 +185,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 1f01d29d..87eb9c35 100644
--- a/test/netlib/http/test_request.py
+++ b/test/netlib/http/test_request.py
@@ -1,12 +1,11 @@
# -*- coding: utf-8 -*-
-from __future__ import absolute_import, print_function, division
from netlib.http import Headers
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 +13,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 +91,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 e97cc419..bf08e6f2 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
@@ -11,7 +10,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 +18,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 +59,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_debug.py b/test/netlib/test_debug.py
index 4732125b..bdb85c9e 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/test_multidict.py b/test/netlib/test_multidict.py
index 58ae0f98..a9523fd9 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 10a6f70a..e24506ee 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
@@ -85,7 +84,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 cce39454..a039dcb1 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 528fce71..23a9b876 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 34765e04..f6f1e40a 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/__init__.py b/test/pathod/__init__.py
index 3f5dc124..e69de29b 100644
--- a/test/pathod/__init__.py
+++ b/test/pathod/__init__.py
@@ -1 +0,0 @@
-from __future__ import (print_function, absolute_import, division)
diff --git a/test/pathod/test_language_base.py b/test/pathod/test_language_base.py
index 12a235e4..b8abc9ba 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 d119348a..89d7c562 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 7f65c0eb..7300cc1d 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 518485ba..c2243578 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