diff options
author | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2016-05-28 14:36:43 +0200 |
---|---|---|
committer | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2016-05-28 14:43:32 +0200 |
commit | caee1adeb613368dc658bfc0c99e445d6f41cd7c (patch) | |
tree | 5f7ea696349c91266ebec586bd4a273982e92eca | |
parent | fa7964988f1541587a9fc3b582223e0a7b11a4d1 (diff) | |
download | mitmproxy-caee1adeb613368dc658bfc0c99e445d6f41cd7c.tar.gz mitmproxy-caee1adeb613368dc658bfc0c99e445d6f41cd7c.tar.bz2 mitmproxy-caee1adeb613368dc658bfc0c99e445d6f41cd7c.zip |
cleanup imports with flake8
33 files changed, 29 insertions, 50 deletions
diff --git a/mitmproxy/flow.py b/mitmproxy/flow.py index a09a81a7..d70ec2d9 100644 --- a/mitmproxy/flow.py +++ b/mitmproxy/flow.py @@ -8,13 +8,13 @@ import hashlib import sys import six -from six.moves import http_cookies, http_cookiejar, urllib +from six.moves import http_cookiejar +from six.moves import urllib import os import re -from typing import List, Optional, Set -from netlib import wsgi, odict +from netlib import wsgi from netlib.exceptions import HttpException from netlib.http import Headers, http1, cookies from netlib.utils import clean_bin diff --git a/mitmproxy/flow_export.py b/mitmproxy/flow_export.py index ae282fce..2ac33e15 100644 --- a/mitmproxy/flow_export.py +++ b/mitmproxy/flow_export.py @@ -5,7 +5,8 @@ import netlib.http from netlib.utils import parse_content_type import re -from six.moves.urllib.parse import urlparse, quote, quote_plus +from six.moves.urllib.parse import quote +from six.moves.urllib.parse import quote_plus def curl_command(flow): data = "curl " diff --git a/mitmproxy/protocol/rawtcp.py b/mitmproxy/protocol/rawtcp.py index 1b546c40..05342844 100644 --- a/mitmproxy/protocol/rawtcp.py +++ b/mitmproxy/protocol/rawtcp.py @@ -1,14 +1,10 @@ from __future__ import (absolute_import, print_function, division) import socket -import six -import sys from OpenSSL import SSL from netlib.exceptions import TcpException from netlib.tcp import ssl_read_select -from netlib.utils import clean_bin -from ..exceptions import ProtocolException from ..models import Error from ..models.tcp import TCPFlow, TCPMessage diff --git a/mitmproxy/script/script.py b/mitmproxy/script/script.py index 484025b4..4ec9af97 100644 --- a/mitmproxy/script/script.py +++ b/mitmproxy/script/script.py @@ -6,7 +6,6 @@ by the mitmproxy-specific ScriptContext. # Do not import __future__ here, this would apply transitively to the inline scripts. import os import shlex -import traceback import sys import six diff --git a/netlib/http/cookies.py b/netlib/http/cookies.py index 88c76870..ae041174 100644 --- a/netlib/http/cookies.py +++ b/netlib/http/cookies.py @@ -3,7 +3,6 @@ import re from email.utils import parsedate_tz, formatdate, mktime_tz from netlib.multidict import ImmutableMultiDict -from .. import odict """ A flexible module for cookie parsing and manipulation. diff --git a/netlib/http/http1/assemble.py b/netlib/http/http1/assemble.py index f06ad5a1..1e73cc2b 100644 --- a/netlib/http/http1/assemble.py +++ b/netlib/http/http1/assemble.py @@ -1,7 +1,6 @@ from __future__ import absolute_import, print_function, division from ... import utils -import itertools from ...exceptions import HttpException def assemble_request(request): diff --git a/netlib/http/message.py b/netlib/http/message.py index 028f43a1..b7f42515 100644 --- a/netlib/http/message.py +++ b/netlib/http/message.py @@ -4,7 +4,6 @@ import warnings import six -from ..multidict import MultiDict from .headers import Headers from .. import encoding, utils diff --git a/netlib/http/request.py b/netlib/http/request.py index 056a2d93..5a528bf2 100644 --- a/netlib/http/request.py +++ b/netlib/http/request.py @@ -1,14 +1,12 @@ from __future__ import absolute_import, print_function, division import re -import warnings import six from six.moves import urllib from netlib import utils from netlib.http import cookies -from netlib.odict import ODict from .. import encoding from ..multidict import MultiDictView from .headers import Headers diff --git a/netlib/multidict.py b/netlib/multidict.py index 8e657363..da482620 100644 --- a/netlib/multidict.py +++ b/netlib/multidict.py @@ -2,7 +2,6 @@ from __future__ import absolute_import, print_function, division from abc import ABCMeta, abstractmethod -from typing import Tuple, TypeVar try: from collections.abc import MutableMapping diff --git a/netlib/version_check.py b/netlib/version_check.py index 8e05b458..63f3e876 100644 --- a/netlib/version_check.py +++ b/netlib/version_check.py @@ -10,7 +10,6 @@ import os.path import six import OpenSSL -from . import version PYOPENSSL_MIN_VERSION = (0, 15) diff --git a/netlib/websockets/protocol.py b/netlib/websockets/protocol.py index 1e95fa1c..940132ad 100644 --- a/netlib/websockets/protocol.py +++ b/netlib/websockets/protocol.py @@ -18,7 +18,6 @@ import base64 import hashlib import os -import binascii import six from ..http import Headers diff --git a/netlib/wsgi.py b/netlib/wsgi.py index d6dfae5d..e1259cba 100644 --- a/netlib/wsgi.py +++ b/netlib/wsgi.py @@ -1,5 +1,5 @@ from __future__ import (absolute_import, print_function, division) -from io import BytesIO, StringIO +from io import BytesIO import urllib import time import traceback @@ -154,7 +154,7 @@ class WSGIAdaptor(object): write(i) if not state["headers_sent"]: write(b"") - except Exception as e: + except Exception: try: s = traceback.format_exc() errs.write(s.encode("utf-8", "replace")) diff --git a/pathod/language/websockets.py b/pathod/language/websockets.py index 09443a95..9b752b7e 100644 --- a/pathod/language/websockets.py +++ b/pathod/language/websockets.py @@ -1,4 +1,3 @@ -import os import random import string import netlib.websockets diff --git a/pathod/language/writer.py b/pathod/language/writer.py index 1a27e1ef..22e32ce2 100644 --- a/pathod/language/writer.py +++ b/pathod/language/writer.py @@ -1,6 +1,5 @@ import time from netlib.exceptions import TcpDisconnect -import netlib.tcp BLOCKSIZE = 1024 # It's not clear what the upper limit for time.sleep is. It's lower than the diff --git a/pathod/protocols/http.py b/pathod/protocols/http.py index 1f1765cb..d09b5bf2 100644 --- a/pathod/protocols/http.py +++ b/pathod/protocols/http.py @@ -1,6 +1,6 @@ -from netlib import tcp, wsgi -from netlib.exceptions import HttpReadDisconnect, TlsException -from netlib.http import http1, Request +from netlib import wsgi +from netlib.exceptions import TlsException +from netlib.http import http1 from .. import version, language diff --git a/pathod/protocols/http2.py b/pathod/protocols/http2.py index a098a14e..688cc64e 100644 --- a/pathod/protocols/http2.py +++ b/pathod/protocols/http2.py @@ -1,5 +1,5 @@ from netlib.http import http2 -from .. import version, app, language, utils, log +from .. import language class HTTP2Protocol: diff --git a/test/mitmproxy/test_examples.py b/test/mitmproxy/test_examples.py index c4b06f4b..607d6faf 100644 --- a/test/mitmproxy/test_examples.py +++ b/test/mitmproxy/test_examples.py @@ -3,7 +3,7 @@ import json import os from contextlib import contextmanager -from mitmproxy import utils, script +from mitmproxy import script from mitmproxy.proxy import config import netlib.utils from netlib import tutils as netutils diff --git a/test/mitmproxy/test_flow.py b/test/mitmproxy/test_flow.py index 3e78a5c4..5441ea59 100644 --- a/test/mitmproxy/test_flow.py +++ b/test/mitmproxy/test_flow.py @@ -4,7 +4,6 @@ from six.moves import cStringIO as StringIO import mock import netlib.utils -from netlib import odict from netlib.http import Headers from mitmproxy import filt, controller, tnetstring, flow from mitmproxy.exceptions import FlowReadException, ScriptException diff --git a/test/mitmproxy/test_flow_export.py b/test/mitmproxy/test_flow_export.py index c252c5bd..0374ba7d 100644 --- a/test/mitmproxy/test_flow_export.py +++ b/test/mitmproxy/test_flow_export.py @@ -1,4 +1,3 @@ -import json from textwrap import dedent import re diff --git a/test/mitmproxy/test_protocol_http2.py b/test/mitmproxy/test_protocol_http2.py index c3950975..1e9c62d9 100644 --- a/test/mitmproxy/test_protocol_http2.py +++ b/test/mitmproxy/test_protocol_http2.py @@ -2,7 +2,6 @@ from __future__ import (absolute_import, print_function, division) -import OpenSSL import pytest import traceback import os @@ -468,13 +467,10 @@ class TestConnectionLost(_Http2TestBase, _Http2ServerBase): ]) done = False - ended_streams = 0 - pushed_streams = 0 - responses = 0 while not done: try: raw = b''.join(http2_read_raw_frame(client.rfile)) - events = h2_conn.receive_data(raw) + h2_conn.receive_data(raw) except: break client.wfile.write(h2_conn.data_to_send()) diff --git a/test/mitmproxy/tutils.py b/test/mitmproxy/tutils.py index 118f849c..c1b258a2 100644 --- a/test/mitmproxy/tutils.py +++ b/test/mitmproxy/tutils.py @@ -12,7 +12,7 @@ from unittest.case import SkipTest import netlib.utils import netlib.tutils -from mitmproxy import utils, controller +from mitmproxy import controller from mitmproxy.models import ( ClientConnection, ServerConnection, Error, HTTPRequest, HTTPResponse, HTTPFlow, TCPFlow ) diff --git a/test/netlib/http/http1/test_read.py b/test/netlib/http/http1/test_read.py index d8106904..33f3802b 100644 --- a/test/netlib/http/http1/test_read.py +++ b/test/netlib/http/http1/test_read.py @@ -1,6 +1,5 @@ from __future__ import absolute_import, print_function, division from io import BytesIO -import textwrap from mock import Mock from netlib.exceptions import HttpException, HttpSyntaxException, HttpReadDisconnect, TcpDisconnect from netlib.http import Headers diff --git a/test/netlib/http/http2/test_connections.py b/test/netlib/http/http2/test_connections.py index 7d240c0e..9312576f 100644 --- a/test/netlib/http/http2/test_connections.py +++ b/test/netlib/http/http2/test_connections.py @@ -1,4 +1,3 @@ -import OpenSSL import mock import codecs diff --git a/test/netlib/http/test_message.py b/test/netlib/http/test_message.py index 64592921..f5bf7f0c 100644 --- a/test/netlib/http/test_message.py +++ b/test/netlib/http/test_message.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, division -from netlib.http import decoded, Headers -from netlib.tutils import tresp, raises +from netlib.http import decoded +from netlib.tutils import tresp def _test_passthrough_attr(message, attr): diff --git a/test/netlib/http/test_response.py b/test/netlib/http/test_response.py index cfd093d4..63c976a2 100644 --- a/test/netlib/http/test_response.py +++ b/test/netlib/http/test_response.py @@ -2,12 +2,10 @@ from __future__ import absolute_import, print_function, division import email -import six import time from netlib.http import Headers from netlib.http.cookies import CookieAttrs -from netlib.odict import ODict, ODictCaseless from netlib.tutils import raises, tresp from .test_message import _test_passthrough_attr, _test_decoded_attr diff --git a/test/netlib/test_socks.py b/test/netlib/test_socks.py index 486b975b..17e08054 100644 --- a/test/netlib/test_socks.py +++ b/test/netlib/test_socks.py @@ -1,6 +1,5 @@ import ipaddress from io import BytesIO -import socket from netlib import socks, tcp, tutils diff --git a/test/netlib/test_tcp.py b/test/netlib/test_tcp.py index 4b4bbb92..80cdba36 100644 --- a/test/netlib/test_tcp.py +++ b/test/netlib/test_tcp.py @@ -8,7 +8,6 @@ import threading import mock from OpenSSL import SSL -import OpenSSL from netlib import tcp, certutils, tutils from netlib.exceptions import InvalidCertificateException, TcpReadIncomplete, TlsException, \ diff --git a/test/netlib/test_version_check.py b/test/netlib/test_version_check.py index 680f80e0..fa6b19e5 100644 --- a/test/netlib/test_version_check.py +++ b/test/netlib/test_version_check.py @@ -1,6 +1,6 @@ from io import StringIO import mock -from netlib import version_check, version +from netlib import version_check @mock.patch("sys.exit") diff --git a/test/netlib/websockets/test_websockets.py b/test/netlib/websockets/test_websockets.py index a7d782a4..4a6f0f9b 100644 --- a/test/netlib/websockets/test_websockets.py +++ b/test/netlib/websockets/test_websockets.py @@ -2,7 +2,9 @@ import os from netlib.http.http1 import read_response, read_request -from netlib import tcp, websockets, http, tutils +from netlib import tcp +from netlib import tutils +from netlib import websockets from netlib.http import status_codes from netlib.tutils import treq from netlib.exceptions import * diff --git a/test/pathod/test_language_http2.py b/test/pathod/test_language_http2.py index abfe4606..4acde3af 100644 --- a/test/pathod/test_language_http2.py +++ b/test/pathod/test_language_http2.py @@ -5,7 +5,7 @@ from netlib import tcp from netlib.http import user_agents from pathod import language -from pathod.language import http2, base +from pathod.language import http2 import tutils diff --git a/test/pathod/test_pathoc.py b/test/pathod/test_pathoc.py index 4e8c89c5..e7818772 100644 --- a/test/pathod/test_pathoc.py +++ b/test/pathod/test_pathoc.py @@ -1,12 +1,12 @@ import json from six.moves import cStringIO as StringIO import re -import OpenSSL import pytest from mock import Mock -from netlib import tcp, http, socks -from netlib.exceptions import HttpException, TcpException, NetlibException +from netlib import http +from netlib import tcp +from netlib.exceptions import NetlibException from netlib.http import http1, http2 from pathod import pathoc, test, version, pathod, language diff --git a/test/pathod/test_pathod.py b/test/pathod/test_pathod.py index 05a3962e..13b36e36 100644 --- a/test/pathod/test_pathod.py +++ b/test/pathod/test_pathod.py @@ -2,7 +2,7 @@ from six.moves import cStringIO as StringIO import pytest from pathod import pathod, version -from netlib import tcp, http +from netlib import tcp from netlib.exceptions import HttpException, TlsException import tutils diff --git a/test/pathod/tutils.py b/test/pathod/tutils.py index f6ed3efb..d6b7bc1a 100644 --- a/test/pathod/tutils.py +++ b/test/pathod/tutils.py @@ -4,7 +4,10 @@ import shutil from six.moves import cStringIO as StringIO import netlib -from pathod import utils, test, pathoc, pathod, language +from pathod import language +from pathod import pathoc +from pathod import pathod +from pathod import test from netlib import tcp import requests |