diff --git a/docs/scripts/api-events.py b/docs/scripts/api-events.py index 6262b44b6..ca90398d5 100644 --- a/docs/scripts/api-events.py +++ b/docs/scripts/api-events.py @@ -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 diff --git a/examples/contrib/block_dns_over_https.py b/examples/contrib/block_dns_over_https.py index 50d796592..4d527af39 100644 --- a/examples/contrib/block_dns_over_https.py +++ b/examples/contrib/block_dns_over_https.py @@ -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 diff --git a/examples/contrib/change_upstream_proxy.py b/examples/contrib/change_upstream_proxy.py index fb07b0af2..ddcbabf10 100644 --- a/examples/contrib/change_upstream_proxy.py +++ b/examples/contrib/change_upstream_proxy.py @@ -1,4 +1,3 @@ -import typing from mitmproxy import http from mitmproxy.connection import Server diff --git a/examples/contrib/domain_fronting.py b/examples/contrib/domain_fronting.py index ccd12de5f..fd73d2985 100644 --- a/examples/contrib/domain_fronting.py +++ b/examples/contrib/domain_fronting.py @@ -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 diff --git a/examples/contrib/har_dump.py b/examples/contrib/har_dump.py index 548f281e3..8f70ede7f 100644 --- a/examples/contrib/har_dump.py +++ b/examples/contrib/har_dump.py @@ -13,7 +13,6 @@ import json import base64 import zlib import os -import typing from datetime import datetime from datetime import timezone diff --git a/examples/contrib/http_manipulate_cookies.py b/examples/contrib/http_manipulate_cookies.py index 765ea9289..f420dc411 100644 --- a/examples/contrib/http_manipulate_cookies.py +++ b/examples/contrib/http_manipulate_cookies.py @@ -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 diff --git a/examples/contrib/sslstrip.py b/examples/contrib/sslstrip.py index 1c4c45bc5..05aa5f3e5 100644 --- a/examples/contrib/sslstrip.py +++ b/examples/contrib/sslstrip.py @@ -4,7 +4,6 @@ https://moxie.org/software/sslstrip/ """ import re import urllib.parse -import typing from mitmproxy import http diff --git a/examples/contrib/webscanner_helper/mapping.py b/examples/contrib/webscanner_helper/mapping.py index 289efa308..9eebb9d82 100644 --- a/examples/contrib/webscanner_helper/mapping.py +++ b/examples/contrib/webscanner_helper/mapping.py @@ -1,7 +1,6 @@ import copy import logging import typing -from typing import Dict from bs4 import BeautifulSoup diff --git a/examples/contrib/webscanner_helper/proxyauth_selenium.py b/examples/contrib/webscanner_helper/proxyauth_selenium.py index e1dc7829b..6ac1d94de 100644 --- a/examples/contrib/webscanner_helper/proxyauth_selenium.py +++ b/examples/contrib/webscanner_helper/proxyauth_selenium.py @@ -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 diff --git a/examples/contrib/webscanner_helper/test_urlindex.py b/examples/contrib/webscanner_helper/test_urlindex.py index 407407a5e..058a36068 100644 --- a/examples/contrib/webscanner_helper/test_urlindex.py +++ b/examples/contrib/webscanner_helper/test_urlindex.py @@ -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 diff --git a/examples/contrib/webscanner_helper/urldict.py b/examples/contrib/webscanner_helper/urldict.py index 1611cad8a..a13570646 100644 --- a/examples/contrib/webscanner_helper/urldict.py +++ b/examples/contrib/webscanner_helper/urldict.py @@ -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 diff --git a/examples/contrib/webscanner_helper/urlindex.py b/examples/contrib/webscanner_helper/urlindex.py index 5a2a5c76a..650e47c01 100644 --- a/examples/contrib/webscanner_helper/urlindex.py +++ b/examples/contrib/webscanner_helper/urlindex.py @@ -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): diff --git a/examples/contrib/webscanner_helper/urlinjection.py b/examples/contrib/webscanner_helper/urlinjection.py index aa8616820..6c4f98291 100644 --- a/examples/contrib/webscanner_helper/urlinjection.py +++ b/examples/contrib/webscanner_helper/urlinjection.py @@ -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): diff --git a/examples/contrib/xss_scanner.py b/examples/contrib/xss_scanner.py index 3e93ab161..368662cfb 100644 --- a/examples/contrib/xss_scanner.py +++ b/examples/contrib/xss_scanner.py @@ -36,7 +36,7 @@ Line: 1029zxcs'd"aoso[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 diff --git a/mitmproxy/addons/dns_resolver.py b/mitmproxy/addons/dns_resolver.py index eaf0977c8..4e4887150 100644 --- a/mitmproxy/addons/dns_resolver.py +++ b/mitmproxy/addons/dns_resolver.py @@ -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" diff --git a/mitmproxy/addons/next_layer.py b/mitmproxy/addons/next_layer.py index 328cc9bce..947e88823 100644 --- a/mitmproxy/addons/next_layer.py +++ b/mitmproxy/addons/next_layer.py @@ -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 diff --git a/mitmproxy/addons/proxyauth.py b/mitmproxy/addons/proxyauth.py index 44c216925..a3ff2b95e 100644 --- a/mitmproxy/addons/proxyauth.py +++ b/mitmproxy/addons/proxyauth.py @@ -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 diff --git a/mitmproxy/addons/proxyserver.py b/mitmproxy/addons/proxyserver.py index 926dda968..d62c636b0 100644 --- a/mitmproxy/addons/proxyserver.py +++ b/mitmproxy/addons/proxyserver.py @@ -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 diff --git a/mitmproxy/addons/stickycookie.py b/mitmproxy/addons/stickycookie.py index fcd58ccc2..428f3ec5a 100644 --- a/mitmproxy/addons/stickycookie.py +++ b/mitmproxy/addons/stickycookie.py @@ -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 diff --git a/mitmproxy/addons/tlsconfig.py b/mitmproxy/addons/tlsconfig.py index 7b19aea76..2a4160a2c 100644 --- a/mitmproxy/addons/tlsconfig.py +++ b/mitmproxy/addons/tlsconfig.py @@ -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 diff --git a/mitmproxy/certs.py b/mitmproxy/certs.py index c413ec663..04bc07f10 100644 --- a/mitmproxy/certs.py +++ b/mitmproxy/certs.py @@ -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 diff --git a/mitmproxy/connection.py b/mitmproxy/connection.py index aa29a1f34..f45e196c6 100644 --- a/mitmproxy/connection.py +++ b/mitmproxy/connection.py @@ -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 diff --git a/mitmproxy/contentviews/__init__.py b/mitmproxy/contentviews/__init__.py index e15164731..9c3f6b9a6 100644 --- a/mitmproxy/contentviews/__init__.py +++ b/mitmproxy/contentviews/__init__.py @@ -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 diff --git a/mitmproxy/contentviews/grpc.py b/mitmproxy/contentviews/grpc.py index 2af42ac42..bd60da460 100644 --- a/mitmproxy/contentviews/grpc.py +++ b/mitmproxy/contentviews/grpc.py @@ -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[:] diff --git a/mitmproxy/contentviews/image/image_parser.py b/mitmproxy/contentviews/image/image_parser.py index f5d65c219..c60d99eba 100644 --- a/mitmproxy/contentviews/image/image_parser.py +++ b/mitmproxy/contentviews/image/image_parser.py @@ -1,5 +1,4 @@ import io -import typing from kaitaistruct import KaitaiStream diff --git a/mitmproxy/coretypes/multidict.py b/mitmproxy/coretypes/multidict.py index a30ad6699..a334257b6 100644 --- a/mitmproxy/coretypes/multidict.py +++ b/mitmproxy/coretypes/multidict.py @@ -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 diff --git a/mitmproxy/coretypes/serializable.py b/mitmproxy/coretypes/serializable.py index e6352f605..60a51cbca 100644 --- a/mitmproxy/coretypes/serializable.py +++ b/mitmproxy/coretypes/serializable.py @@ -1,6 +1,6 @@ import abc import uuid -from typing import Type, TypeVar +from typing import TypeVar T = TypeVar('T', bound='Serializable') diff --git a/mitmproxy/dns.py b/mitmproxy/dns.py index d5b63f326..aed7f3343 100644 --- a/mitmproxy/dns.py +++ b/mitmproxy/dns.py @@ -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 diff --git a/mitmproxy/eventsequence.py b/mitmproxy/eventsequence.py index f21571e46..bf15b6e29 100644 --- a/mitmproxy/eventsequence.py +++ b/mitmproxy/eventsequence.py @@ -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 diff --git a/mitmproxy/exceptions.py b/mitmproxy/exceptions.py index 2e22f1a31..d199f1387 100644 --- a/mitmproxy/exceptions.py +++ b/mitmproxy/exceptions.py @@ -49,7 +49,6 @@ class AddonHalt(MitmproxyException): """ Raised by addons to signal that no further handlers should handle this event. """ - pass class TypeError(MitmproxyException): diff --git a/mitmproxy/flowfilter.py b/mitmproxy/flowfilter.py index 1a393189f..dd1c70208 100644 --- a/mitmproxy/flowfilter.py +++ b/mitmproxy/flowfilter.py @@ -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 diff --git a/mitmproxy/hooks.py b/mitmproxy/hooks.py index 26f68fd96..81e0ab6db 100644 --- a/mitmproxy/hooks.py +++ b/mitmproxy/hooks.py @@ -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 diff --git a/mitmproxy/http.py b/mitmproxy/http.py index fc6407be5..2a76fcc88 100644 --- a/mitmproxy/http.py +++ b/mitmproxy/http.py @@ -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 diff --git a/mitmproxy/io/compat.py b/mitmproxy/io/compat.py index 71d4deed2..4dd1ac234 100644 --- a/mitmproxy/io/compat.py +++ b/mitmproxy/io/compat.py @@ -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 diff --git a/mitmproxy/io/io.py b/mitmproxy/io/io.py index c26591a61..99a1b2529 100644 --- a/mitmproxy/io/io.py +++ b/mitmproxy/io/io.py @@ -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 diff --git a/mitmproxy/net/dns/domain_names.py b/mitmproxy/net/dns/domain_names.py index 7b33ce7f8..a3dcd5dac 100644 --- a/mitmproxy/net/dns/domain_names.py +++ b/mitmproxy/net/dns/domain_names.py @@ -1,5 +1,5 @@ import struct -from typing import Dict, List, Optional, Tuple +from typing import Optional _LABEL_SIZE = struct.Struct("!B") diff --git a/mitmproxy/net/http/cookies.py b/mitmproxy/net/http/cookies.py index de212dff5..daddc048c 100644 --- a/mitmproxy/net/http/cookies.py +++ b/mitmproxy/net/http/cookies.py @@ -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 diff --git a/mitmproxy/net/http/headers.py b/mitmproxy/net/http/headers.py index 6a57b0504..7c5bd7d50 100644 --- a/mitmproxy/net/http/headers.py +++ b/mitmproxy/net/http/headers.py @@ -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]]]: diff --git a/mitmproxy/net/http/http1/read.py b/mitmproxy/net/http/http1/read.py index 92218a057..5c50d6c79 100644 --- a/mitmproxy/net/http/http1/read.py +++ b/mitmproxy/net/http/http1/read.py @@ -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 diff --git a/mitmproxy/net/http/multipart.py b/mitmproxy/net/http/multipart.py index aa9c3a9a9..0881429ff 100644 --- a/mitmproxy/net/http/multipart.py +++ b/mitmproxy/net/http/multipart.py @@ -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 diff --git a/mitmproxy/net/http/url.py b/mitmproxy/net/http/url.py index f14ba9bd7..9cb8f1640 100644 --- a/mitmproxy/net/http/url.py +++ b/mitmproxy/net/http/url.py @@ -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. diff --git a/mitmproxy/net/server_spec.py b/mitmproxy/net/server_spec.py index 560f37520..a6303fb71 100644 --- a/mitmproxy/net/server_spec.py +++ b/mitmproxy/net/server_spec.py @@ -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 diff --git a/mitmproxy/net/tls.py b/mitmproxy/net/tls.py index cf4d1304f..dc0d2bda6 100644 --- a/mitmproxy/net/tls.py +++ b/mitmproxy/net/tls.py @@ -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 diff --git a/mitmproxy/net/udp.py b/mitmproxy/net/udp.py index 4fba7cb23..04f52506f 100644 --- a/mitmproxy/net/udp.py +++ b/mitmproxy/net/udp.py @@ -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 diff --git a/mitmproxy/platform/__init__.py b/mitmproxy/platform/__init__.py index 73b58385d..a00d9bd0d 100644 --- a/mitmproxy/platform/__init__.py +++ b/mitmproxy/platform/__init__.py @@ -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: diff --git a/mitmproxy/platform/linux.py b/mitmproxy/platform/linux.py index 62f990038..577021ac5 100644 --- a/mitmproxy/platform/linux.py +++ b/mitmproxy/platform/linux.py @@ -1,6 +1,5 @@ import socket import struct -import typing # Python's socket module does not have these constants SO_ORIGINAL_DST = 80 diff --git a/mitmproxy/proxy/context.py b/mitmproxy/proxy/context.py index f09db9a98..cffcd553a 100644 --- a/mitmproxy/proxy/context.py +++ b/mitmproxy/proxy/context.py @@ -1,4 +1,4 @@ -from typing import List, TYPE_CHECKING +from typing import TYPE_CHECKING from mitmproxy import connection from mitmproxy.options import Options diff --git a/mitmproxy/proxy/events.py b/mitmproxy/proxy/events.py index 0dba5c154..8627c6454 100644 --- a/mitmproxy/proxy/events.py +++ b/mitmproxy/proxy/events.py @@ -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): diff --git a/mitmproxy/proxy/layer.py b/mitmproxy/proxy/layer.py index 8d5ecb0af..cf4447fe6 100644 --- a/mitmproxy/proxy/layer.py +++ b/mitmproxy/proxy/layer.py @@ -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 diff --git a/mitmproxy/proxy/layers/http/__init__.py b/mitmproxy/proxy/layers/http/__init__.py index e2f1855ab..f6edff4e6 100644 --- a/mitmproxy/proxy/layers/http/__init__.py +++ b/mitmproxy/proxy/layers/http/__init__.py @@ -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 diff --git a/mitmproxy/proxy/layers/http/_http1.py b/mitmproxy/proxy/layers/http/_http1.py index d537036a3..01f7b0416 100644 --- a/mitmproxy/proxy/layers/http/_http1.py +++ b/mitmproxy/proxy/layers/http/_http1.py @@ -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 diff --git a/mitmproxy/proxy/layers/http/_http2.py b/mitmproxy/proxy/layers/http/_http2.py index e1887a22c..ca81d07be 100644 --- a/mitmproxy/proxy/layers/http/_http2.py +++ b/mitmproxy/proxy/layers/http/_http2.py @@ -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 diff --git a/mitmproxy/proxy/layers/http/_upstream_proxy.py b/mitmproxy/proxy/layers/http/_upstream_proxy.py index bad93c646..4597dd75e 100644 --- a/mitmproxy/proxy/layers/http/_upstream_proxy.py +++ b/mitmproxy/proxy/layers/http/_upstream_proxy.py @@ -1,5 +1,5 @@ import time -from typing import Optional, Tuple +from typing import Optional from h11._receivebuffer import ReceiveBuffer diff --git a/mitmproxy/proxy/layers/tls.py b/mitmproxy/proxy/layers/tls.py index a34a51fdc..418e83781 100644 --- a/mitmproxy/proxy/layers/tls.py +++ b/mitmproxy/proxy/layers/tls.py @@ -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 diff --git a/mitmproxy/proxy/layers/websocket.py b/mitmproxy/proxy/layers/websocket.py index 5b2bd17d8..f81cb1982 100644 --- a/mitmproxy/proxy/layers/websocket.py +++ b/mitmproxy/proxy/layers/websocket.py @@ -1,6 +1,6 @@ import time from dataclasses import dataclass -from typing import Iterator, List +from typing import Iterator import wsproto import wsproto.extensions diff --git a/mitmproxy/proxy/tunnel.py b/mitmproxy/proxy/tunnel.py index ef3a267ab..9e4d05ae0 100644 --- a/mitmproxy/proxy/tunnel.py +++ b/mitmproxy/proxy/tunnel.py @@ -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 diff --git a/mitmproxy/tcp.py b/mitmproxy/tcp.py index 41c2c812f..928c6da3d 100644 --- a/mitmproxy/tcp.py +++ b/mitmproxy/tcp.py @@ -1,5 +1,4 @@ import time -from typing import List from mitmproxy import flow from mitmproxy.coretypes import serializable diff --git a/mitmproxy/test/tflow.py b/mitmproxy/test/tflow.py index 26403ae63..e004cdf4f 100644 --- a/mitmproxy/test/tflow.py +++ b/mitmproxy/test/tflow.py @@ -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 diff --git a/mitmproxy/tls.py b/mitmproxy/tls.py index ce694b329..4f7d3f596 100644 --- a/mitmproxy/tls.py +++ b/mitmproxy/tls.py @@ -1,6 +1,6 @@ import io from dataclasses import dataclass -from typing import List, Optional, Tuple +from typing import Optional from kaitaistruct import KaitaiStream diff --git a/mitmproxy/tools/console/layoutwidget.py b/mitmproxy/tools/console/layoutwidget.py index aaf46bb4d..95bfb53b8 100644 --- a/mitmproxy/tools/console/layoutwidget.py +++ b/mitmproxy/tools/console/layoutwidget.py @@ -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 diff --git a/mitmproxy/utils/asyncio_utils.py b/mitmproxy/utils/asyncio_utils.py index f4896c96c..2fc0e1d01 100644 --- a/mitmproxy/utils/asyncio_utils.py +++ b/mitmproxy/utils/asyncio_utils.py @@ -1,5 +1,4 @@ import asyncio -import sys import time from collections.abc import Coroutine from typing import Optional diff --git a/mitmproxy/utils/sliding_window.py b/mitmproxy/utils/sliding_window.py index 42ff98d93..1de5eae13 100644 --- a/mitmproxy/utils/sliding_window.py +++ b/mitmproxy/utils/sliding_window.py @@ -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') diff --git a/mitmproxy/utils/spec.py b/mitmproxy/utils/spec.py index fbf7c2918..319401225 100644 --- a/mitmproxy/utils/spec.py +++ b/mitmproxy/utils/spec.py @@ -1,4 +1,3 @@ -import typing from mitmproxy import flowfilter diff --git a/mitmproxy/websocket.py b/mitmproxy/websocket.py index d890cd6eb..0073c31ca 100644 --- a/mitmproxy/websocket.py +++ b/mitmproxy/websocket.py @@ -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 diff --git a/release/cibuild.py b/release/cibuild.py index 13c7c5db7..b475374ca 100755 --- a/release/cibuild.py +++ b/release/cibuild.py @@ -462,7 +462,6 @@ def cli(): # pragma: no cover """ mitmproxy build tool """ - pass @cli.command("build") diff --git a/test/individual_coverage.py b/test/individual_coverage.py index c969b4b82..9fba9cfcc 100755 --- a/test/individual_coverage.py +++ b/test/individual_coverage.py @@ -77,7 +77,6 @@ def main(): if any(e != 0 for _, _, e in result): sys.exit(1) - pass if __name__ == '__main__': diff --git a/test/mitmproxy/contentviews/test_grpc.py b/test/mitmproxy/contentviews/test_grpc.py index e8fc6daef..bd77da440 100644 --- a/test/mitmproxy/contentviews/test_grpc.py +++ b/test/mitmproxy/contentviews/test_grpc.py @@ -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 diff --git a/test/mitmproxy/data/addonscripts/concurrent_decorator.py b/test/mitmproxy/data/addonscripts/concurrent_decorator.py index 141dd0be7..743a2fc23 100644 --- a/test/mitmproxy/data/addonscripts/concurrent_decorator.py +++ b/test/mitmproxy/data/addonscripts/concurrent_decorator.py @@ -1,5 +1,4 @@ import time -import sys from mitmproxy.script import concurrent diff --git a/test/mitmproxy/proxy/layers/http/test_http2.py b/test/mitmproxy/proxy/layers/http/test_http2.py index e5ef737ca..46cdc7110 100644 --- a/test/mitmproxy/proxy/layers/http/test_http2.py +++ b/test/mitmproxy/proxy/layers/http/test_http2.py @@ -1,4 +1,3 @@ -from typing import List, Tuple import h2.settings import hpack diff --git a/test/mitmproxy/proxy/layers/http/test_http_fuzz.py b/test/mitmproxy/proxy/layers/http/test_http_fuzz.py index eb0ccc8e8..05fd2ad24 100644 --- a/test/mitmproxy/proxy/layers/http/test_http_fuzz.py +++ b/test/mitmproxy/proxy/layers/http/test_http_fuzz.py @@ -1,4 +1,4 @@ -from typing import Tuple, Dict, Any +from typing import Any import pytest from h2.settings import SettingCodes diff --git a/test/mitmproxy/proxy/layers/http/test_http_version_interop.py b/test/mitmproxy/proxy/layers/http/test_http_version_interop.py index 1aad5d2b8..7ad2c1d83 100644 --- a/test/mitmproxy/proxy/layers/http/test_http_version_interop.py +++ b/test/mitmproxy/proxy/layers/http/test_http_version_interop.py @@ -1,4 +1,3 @@ -from typing import Tuple import h2.config import h2.connection diff --git a/test/mitmproxy/proxy/test_tunnel.py b/test/mitmproxy/proxy/test_tunnel.py index 4c627c813..609132956 100644 --- a/test/mitmproxy/proxy/test_tunnel.py +++ b/test/mitmproxy/proxy/test_tunnel.py @@ -1,4 +1,4 @@ -from typing import Tuple, Optional +from typing import Optional import pytest diff --git a/test/mitmproxy/tools/console/conftest.py b/test/mitmproxy/tools/console/conftest.py index e9046ca45..04b25b64b 100644 --- a/test/mitmproxy/tools/console/conftest.py +++ b/test/mitmproxy/tools/console/conftest.py @@ -1,6 +1,5 @@ import re import sys -from typing import List import pytest