`autoflake --in-place **/*.py`

This commit is contained in:
Maximilian Hils 2022-04-26 13:52:46 +02:00
parent e83ec8390a
commit b31ad66225
73 changed files with 45 additions and 85 deletions

View File

@ -3,7 +3,6 @@ import contextlib
import inspect
import textwrap
from pathlib import Path
from typing import List, Type
from mitmproxy import hooks, log, addonmanager
from mitmproxy.proxy import server_hooks, layer

View File

@ -4,7 +4,6 @@ This module is for blocking DNS over HTTPS requests.
It loads a blocklist of IPs and hostnames that are known to serve DNS over HTTPS requests.
It also uses headers, query params, and paths to detect DoH (and block it)
"""
from typing import List
from mitmproxy import ctx

View File

@ -1,4 +1,3 @@
import typing
from mitmproxy import http
from mitmproxy.connection import Server

View File

@ -1,4 +1,4 @@
from typing import Set, Union, Dict, Optional
from typing import Optional, Union
import json
from dataclasses import dataclass
from mitmproxy import ctx

View File

@ -13,7 +13,6 @@ import json
import base64
import zlib
import os
import typing
from datetime import datetime
from datetime import timezone

View File

@ -14,7 +14,6 @@ Note:
https://stackoverflow.com/questions/55358072/cookie-manipulation-in-mitmproxy-requests-and-responses
"""
from typing import List, Dict
import json
from mitmproxy import http

View File

@ -4,7 +4,6 @@ https://moxie.org/software/sslstrip/
"""
import re
import urllib.parse
import typing
from mitmproxy import http

View File

@ -1,7 +1,6 @@
import copy
import logging
import typing
from typing import Dict
from bs4 import BeautifulSoup

View File

@ -3,7 +3,7 @@ import logging
import random
import string
import time
from typing import Dict, List, cast, Any
from typing import Any, cast
import mitmproxy.http
from mitmproxy import flowfilter

View File

@ -2,7 +2,6 @@ import json
from json import JSONDecodeError
from pathlib import Path
from unittest import mock
from typing import List
from unittest.mock import patch
from mitmproxy.test import tflow

View File

@ -2,7 +2,7 @@ import itertools
import json
import typing
from collections.abc import MutableMapping
from typing import Any, Dict, Generator, List, TextIO, Callable
from typing import Any, Callable, Generator, TextIO
from mitmproxy import flowfilter
from mitmproxy.http import HTTPFlow

View File

@ -3,7 +3,7 @@ import datetime
import json
import logging
from pathlib import Path
from typing import Type, Dict, Union, Optional
from typing import Optional, Union
from mitmproxy import flowfilter
from mitmproxy.http import HTTPFlow
@ -29,12 +29,10 @@ class UrlIndexWriter(abc.ABC):
@abc.abstractmethod
def load(self):
"""Load existing URL index."""
pass
@abc.abstractmethod
def add_url(self, flow: HTTPFlow):
"""Add new URL to URL index."""
pass
@abc.abstractmethod
def save(self):

View File

@ -16,7 +16,6 @@ class InjectionGenerator:
@abc.abstractmethod
def inject(self, index, flow: HTTPFlow):
"""Injects the given URL index into the given flow."""
pass
class HTMLInjection(InjectionGenerator):

View File

@ -36,7 +36,7 @@ Line: 1029zxcs'd"ao<ac>so[sb]po(pc)se;sl/bsl\eq=3847asd
"""
from html.parser import HTMLParser
from typing import Dict, Union, Tuple, Optional, List, NamedTuple
from typing import NamedTuple, Optional, Union
from urllib.parse import urlparse
import re
import socket

View File

@ -1,7 +1,7 @@
import asyncio
import ipaddress
import socket
from typing import Callable, Iterable, List, Tuple, Union
from typing import Callable, Iterable, Union
from mitmproxy import ctx, dns
IP4_PTR_SUFFIX = ".in-addr.arpa"

View File

@ -15,7 +15,7 @@ In that case it's not necessary to modify mitmproxy's source, adding a custom ad
that sets nextlayer.layer works just as well.
"""
import re
from typing import Type, Sequence, Union, Tuple, Any, Iterable, Optional, List
from typing import Any, Iterable, Optional, Sequence, Union
from mitmproxy import ctx, exceptions, connection
from mitmproxy.net.tls import is_tls_record_magic

View File

@ -5,7 +5,6 @@ import weakref
from abc import ABC, abstractmethod
from typing import MutableMapping
from typing import Optional
from typing import Tuple
import ldap3
import passlib.apache

View File

@ -3,7 +3,7 @@ from asyncio import base_events
import ipaddress
import re
import struct
from typing import Dict, Optional, Tuple
from typing import Optional
from mitmproxy import command, ctx, exceptions, flow, http, log, master, options, platform, tcp, websocket
from mitmproxy.connection import Address

View File

@ -1,6 +1,6 @@
import collections
from http import cookiejar
from typing import List, Tuple, Dict, Optional
from typing import Optional
from mitmproxy import http, flowfilter, ctx, exceptions
from mitmproxy.net.http import cookies

View File

@ -1,7 +1,7 @@
import ipaddress
import os
from pathlib import Path
from typing import List, Optional, TypedDict, Any
from typing import Any, Optional, TypedDict
from OpenSSL import SSL
from mitmproxy import certs, ctx, exceptions, connection, tls

View File

@ -6,7 +6,7 @@ import re
import sys
from dataclasses import dataclass
from pathlib import Path
from typing import Tuple, Optional, Union, Dict, List, NewType
from typing import NewType, Optional, Union
from cryptography import x509
from cryptography.hazmat.primitives import hashes, serialization

View File

@ -2,7 +2,7 @@ import uuid
import warnings
from abc import ABCMeta
from enum import Flag
from typing import Literal, Optional, Sequence, Tuple
from typing import Literal, Optional, Sequence
from mitmproxy import certs
from mitmproxy.coretypes import serializable

View File

@ -12,7 +12,7 @@ metadata depend on the protocol in use. Known attributes can be found in
`base.View`.
"""
import traceback
from typing import List, Union
from typing import Union
from typing import Optional
import blinker

View File

@ -3,7 +3,7 @@ from __future__ import annotations
import struct
from dataclasses import dataclass, field
from enum import Enum
from typing import Dict, Generator, Iterable, Iterator, List, Optional, Tuple, Union
from typing import Generator, Iterable, Iterator
from mitmproxy import contentviews, ctx, flow, flowfilter, http
from mitmproxy.contentviews import base
@ -41,7 +41,6 @@ class ProtoParser:
The rule only applies if the processed message is a server response.
"""
pass
@dataclass
class ParserRuleRequest(ParserRule):
@ -50,7 +49,6 @@ class ProtoParser:
The rule only applies if the processed message is a client request.
"""
pass
@dataclass
class ParserFieldDefinition:
@ -512,7 +510,6 @@ class ProtoParser:
self.try_unpack = as_packed
except Exception as e:
ctx.log.warn(e)
pass
def _gen_tag_str(self):
tags = self.parent_tags[:]

View File

@ -1,5 +1,4 @@
import io
import typing
from kaitaistruct import KaitaiStream

View File

@ -1,10 +1,8 @@
from abc import ABCMeta
from abc import abstractmethod
from typing import Iterator
from typing import List
from typing import MutableMapping
from typing import Sequence
from typing import Tuple
from typing import TypeVar
from mitmproxy.coretypes import serializable

View File

@ -1,6 +1,6 @@
import abc
import uuid
from typing import Type, TypeVar
from typing import TypeVar
T = TypeVar('T', bound='Serializable')

View File

@ -5,7 +5,7 @@ import random
import struct
from ipaddress import IPv4Address, IPv6Address
import time
from typing import ClassVar, List, Optional, Tuple, Union
from typing import ClassVar
from mitmproxy import connection, flow, stateobject
from mitmproxy.net.dns import classes, domain_names, op_codes, response_codes, types

View File

@ -1,4 +1,4 @@
from typing import Any, Callable, Dict, Iterator, Type
from typing import Any, Callable, Iterator
from mitmproxy import dns
from mitmproxy import flow

View File

@ -49,7 +49,6 @@ class AddonHalt(MitmproxyException):
"""
Raised by addons to signal that no further handlers should handle this event.
"""
pass
class TypeError(MitmproxyException):

View File

@ -36,7 +36,7 @@
import functools
import re
import sys
from typing import ClassVar, Sequence, Type, Protocol, Union
from typing import ClassVar, Protocol, Sequence, Union
import pyparsing as pp
from mitmproxy import dns, flow, http, tcp

View File

@ -1,7 +1,7 @@
import re
import warnings
from dataclasses import dataclass, is_dataclass, fields
from typing import ClassVar, Any, Dict, Type, Set, List, TYPE_CHECKING, Sequence
from typing import Any, ClassVar, Sequence, TYPE_CHECKING
import mitmproxy.flow

View File

@ -10,13 +10,10 @@ from email.utils import formatdate
from email.utils import mktime_tz
from email.utils import parsedate_tz
from typing import Callable
from typing import Dict
from typing import Iterable
from typing import Iterator
from typing import List
from typing import Mapping
from typing import Optional
from typing import Tuple
from typing import Union
from typing import cast
from typing import Any

View File

@ -6,7 +6,7 @@ v3.0.0dev) and versioning. Every change or migration gets a new flow file
version number, this prevents issues with developer builds and snapshots.
"""
import uuid
from typing import Any, Dict, Mapping, Union
from typing import Any, Mapping, Union
from mitmproxy import version
from mitmproxy.utils import strutils

View File

@ -1,5 +1,5 @@
import os
from typing import Any, Dict, IO, Iterable, Type, Union, cast
from typing import Any, IO, Iterable, Union, cast
from mitmproxy import dns
from mitmproxy import exceptions

View File

@ -1,5 +1,5 @@
import struct
from typing import Dict, List, Optional, Tuple
from typing import Optional
_LABEL_SIZE = struct.Struct("!B")

View File

@ -1,7 +1,7 @@
import email.utils
import re
import time
from typing import Tuple, List, Iterable
from typing import Iterable
from mitmproxy.coretypes import multidict

View File

@ -1,5 +1,5 @@
import collections
from typing import Dict, Optional, Tuple
from typing import Optional
def parse_content_type(c: str) -> Optional[tuple[str, str, dict[str, str]]]:

View File

@ -1,6 +1,6 @@
import re
import time
from typing import List, Tuple, Iterable, Optional
from typing import Iterable, Optional
from mitmproxy.http import Request, Headers, Response
from mitmproxy.net.http import url

View File

@ -1,6 +1,6 @@
import mimetypes
import re
from typing import Tuple, List, Optional
from typing import Optional
from urllib.parse import quote
from mitmproxy.net.http import headers

View File

@ -2,7 +2,6 @@ import re
import urllib.parse
from typing import AnyStr, Optional
from typing import Sequence
from typing import Tuple
from mitmproxy.net import check
# This regex extracts & splits the host header into host and port.

View File

@ -3,7 +3,7 @@ Server specs are used to describe an upstream proxy or server.
"""
import functools
import re
from typing import Tuple, Literal, NamedTuple
from typing import Literal, NamedTuple
from mitmproxy.net import check

View File

@ -4,7 +4,7 @@ import threading
from enum import Enum
from functools import lru_cache
from pathlib import Path
from typing import Iterable, Callable, Optional, Tuple, List, Any, BinaryIO
from typing import Any, BinaryIO, Callable, Iterable, Optional
import certifi

View File

@ -4,7 +4,7 @@ import asyncio
import ipaddress
import socket
import struct
from typing import Any, Callable, Dict, Optional, Tuple, Union, cast
from typing import Any, Callable, Union, cast
from mitmproxy import ctx
from mitmproxy.connection import Address
from mitmproxy.utils import human

View File

@ -1,7 +1,7 @@
import re
import socket
import sys
from typing import Callable, Optional, Tuple
from typing import Callable, Optional
def init_transparent_mode() -> None:

View File

@ -1,6 +1,5 @@
import socket
import struct
import typing
# Python's socket module does not have these constants
SO_ORIGINAL_DST = 80

View File

@ -1,4 +1,4 @@
from typing import List, TYPE_CHECKING
from typing import TYPE_CHECKING
from mitmproxy import connection
from mitmproxy.options import Options

View File

@ -27,7 +27,6 @@ class Start(Event):
Every layer initially receives a start event.
This is useful to emit events on startup.
"""
pass
@dataclass
@ -54,7 +53,6 @@ class ConnectionClosed(ConnectionEvent):
"""
Remote has closed a connection.
"""
pass
class CommandCompleted(Event):

View File

@ -5,7 +5,7 @@ import collections
import textwrap
from abc import abstractmethod
from dataclasses import dataclass
from typing import Optional, List, ClassVar, Deque, NamedTuple, Generator, Any, TypeVar
from typing import Any, ClassVar, Deque, Generator, NamedTuple, Optional, TypeVar
from mitmproxy.connection import Connection
from mitmproxy.proxy import commands, events

View File

@ -2,7 +2,7 @@ import collections
import enum
import time
from dataclasses import dataclass
from typing import DefaultDict, Dict, List, Optional, Tuple, Union
from typing import DefaultDict, Optional, Union
import wsproto.handshake
from mitmproxy import flow, http

View File

@ -1,5 +1,5 @@
import abc
from typing import Callable, Optional, Type, Union
from typing import Callable, Optional, Union
import h11
from h11._readers import ChunkedReader, ContentLengthReader, Http10Reader

View File

@ -1,7 +1,7 @@
import collections
import time
from enum import Enum
from typing import ClassVar, DefaultDict, Dict, List, Optional, Sequence, Tuple, Type, Union
from typing import ClassVar, DefaultDict, Optional, Sequence, Union
import h2.config
import h2.connection

View File

@ -1,5 +1,5 @@
import time
from typing import Optional, Tuple
from typing import Optional
from h11._receivebuffer import ReceiveBuffer

View File

@ -1,7 +1,7 @@
import struct
import time
from dataclasses import dataclass
from typing import Iterator, Literal, Optional, Tuple
from typing import Iterator, Literal, Optional
from OpenSSL import SSL
from mitmproxy.tls import ClientHello, ClientHelloData, TlsData

View File

@ -1,6 +1,6 @@
import time
from dataclasses import dataclass
from typing import Iterator, List
from typing import Iterator
import wsproto
import wsproto.extensions

View File

@ -1,6 +1,6 @@
import time
from enum import Enum, auto
from typing import List, Optional, Tuple, Union
from typing import Optional, Union
from mitmproxy import connection
from mitmproxy.proxy import commands, context, events, layer

View File

@ -1,5 +1,4 @@
import time
from typing import List
from mitmproxy import flow
from mitmproxy.coretypes import serializable

View File

@ -1,5 +1,5 @@
import uuid
from typing import List, Optional, Union
from typing import Optional, Union
from mitmproxy import connection
from mitmproxy import dns

View File

@ -1,6 +1,6 @@
import io
from dataclasses import dataclass
from typing import List, Optional, Tuple
from typing import Optional
from kaitaistruct import KaitaiStream

View File

@ -19,22 +19,18 @@ class LayoutWidget:
The view focus has changed. Layout objects should implement the API
rather than directly subscribing to events.
"""
pass
def view_changed(self):
"""
The view list has changed.
"""
pass
def layout_popping(self):
"""
We are just about to pop a window off the stack, or exit an overlay.
"""
pass
def layout_pushed(self, prev):
"""
We have just pushed a window onto the stack.
"""
pass

View File

@ -1,5 +1,4 @@
import asyncio
import sys
import time
from collections.abc import Coroutine
from typing import Optional

View File

@ -1,5 +1,5 @@
import itertools
from typing import TypeVar, Iterable, Iterator, Tuple, Optional, List
from typing import Iterable, Iterator, Optional, TypeVar
T = TypeVar('T')

View File

@ -1,4 +1,3 @@
import typing
from mitmproxy import flowfilter

View File

@ -7,7 +7,7 @@ This module only defines the classes for individual `WebSocketMessage`s and the
"""
import time
import warnings
from typing import List, Tuple, Union
from typing import Union
from typing import Optional
from mitmproxy import stateobject

View File

@ -462,7 +462,6 @@ def cli(): # pragma: no cover
"""
mitmproxy build tool
"""
pass
@cli.command("build")

View File

@ -77,7 +77,6 @@ def main():
if any(e != 0 for _, _, e in result):
sys.exit(1)
pass
if __name__ == '__main__':

View File

@ -1,6 +1,5 @@
import pytest
from typing import List
from mitmproxy.contentviews import grpc
from mitmproxy.contentviews.grpc import ViewGrpcProtobuf, ViewConfig, ProtoParser, parse_grpc_messages
from mitmproxy.net.encoding import encode

View File

@ -1,5 +1,4 @@
import time
import sys
from mitmproxy.script import concurrent

View File

@ -1,4 +1,3 @@
from typing import List, Tuple
import h2.settings
import hpack

View File

@ -1,4 +1,4 @@
from typing import Tuple, Dict, Any
from typing import Any
import pytest
from h2.settings import SettingCodes

View File

@ -1,4 +1,3 @@
from typing import Tuple
import h2.config
import h2.connection

View File

@ -1,4 +1,4 @@
from typing import Tuple, Optional
from typing import Optional
import pytest

View File

@ -1,6 +1,5 @@
import re
import sys
from typing import List
import pytest