mirror of
https://github.com/zhigang1992/mitmproxy.git
synced 2026-04-29 20:55:03 +08:00
Extend Mypy checking to pathod
* mypy checking pathod * initial commit , fixed errors * tox: mypy checking to pathod * Fixed mypy test failed * issue was with args in custom_contentview.py * tox: mypy checking to #2221 * follow-import=skip since we cant provide args to custom_contentview.py during mypy testing * Lint , Typo Fixed * code style: module import
This commit is contained in:
@@ -3,7 +3,10 @@ This example shows how one can add a custom contentview to mitmproxy.
|
||||
The content view API is explained in the mitmproxy.contentviews module.
|
||||
"""
|
||||
from mitmproxy import contentviews
|
||||
from typing import Tuple, Iterable, AnyStr, List
|
||||
import typing
|
||||
|
||||
|
||||
CVIEWSWAPCASE = typing.Tuple[str, typing.Iterable[typing.List[typing.Tuple[str, typing.AnyStr]]]]
|
||||
|
||||
|
||||
class ViewSwapCase(contentviews.View):
|
||||
@@ -14,7 +17,7 @@ class ViewSwapCase(contentviews.View):
|
||||
prompt = ("swap case text", "z")
|
||||
content_types = ["text/plain"]
|
||||
|
||||
def __call__(self, data: bytes, **metadata) -> Tuple[str, Iterable[List[Tuple[str, AnyStr]]]]:
|
||||
def __call__(self, data: typing.AnyStr, **metadata) -> CVIEWSWAPCASE:
|
||||
return "case-swapped text", contentviews.format_text(data.swapcase())
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# type: ignore
|
||||
#
|
||||
# Simple script showing how to read a mitmproxy dump file
|
||||
#
|
||||
|
||||
from mitmproxy import io
|
||||
from mitmproxy.exceptions import FlowReadException
|
||||
import pprint
|
||||
|
||||
@@ -8,12 +8,13 @@ to multiple files in parallel.
|
||||
import random
|
||||
import sys
|
||||
from mitmproxy import io, http
|
||||
import typing # noqa
|
||||
|
||||
|
||||
class Writer:
|
||||
def __init__(self, path: str) -> None:
|
||||
if path == "-":
|
||||
f = sys.stdout # type: io.TextIO
|
||||
f = sys.stdout # type: typing.IO[typing.Any]
|
||||
else:
|
||||
f = open(path, "wb")
|
||||
self.w = io.FlowWriter(f)
|
||||
|
||||
Reference in New Issue
Block a user