[autofix.ci] apply automated fixes

This commit is contained in:
autofix-ci[bot] 2023-02-27 07:28:30 +00:00 committed by Maximilian Hils
parent 46bfb35488
commit 51670861e6
121 changed files with 496 additions and 649 deletions

View file

@ -5,8 +5,6 @@ This example shows how one can add a custom contentview to mitmproxy,
which is used to pretty-print HTTP bodies for example.
The content view API is explained in the mitmproxy.contentviews module.
"""
from typing import Optional
from mitmproxy import contentviews
from mitmproxy import flow
from mitmproxy import http
@ -19,9 +17,9 @@ class ViewSwapCase(contentviews.View):
self,
data: bytes,
*,
content_type: Optional[str] = None,
flow: Optional[flow.Flow] = None,
http_message: Optional[http.Message] = None,
content_type: str | None = None,
flow: flow.Flow | None = None,
http_message: http.Message | None = None,
**unknown_metadata,
) -> contentviews.TViewResult:
return "case-swapped text", contentviews.format_text(data.swapcase())
@ -30,9 +28,9 @@ class ViewSwapCase(contentviews.View):
self,
data: bytes,
*,
content_type: Optional[str] = None,
flow: Optional[flow.Flow] = None,
http_message: Optional[http.Message] = None,
content_type: str | None = None,
flow: flow.Flow | None = None,
http_message: http.Message | None = None,
**unknown_metadata,
) -> float:
if content_type == "text/plain":

View file

@ -8,10 +8,9 @@ Modifying streamed responses is tricky and brittle:
where one chunk ends with [...]foo" and the next starts with "bar[...].
"""
from collections.abc import Iterable
from typing import Union
def modify(data: bytes) -> Union[bytes, Iterable[bytes]]:
def modify(data: bytes) -> bytes | Iterable[bytes]:
"""
This function will be called for each chunk of request/response body data that arrives at the proxy,
and once at the end of the message with an empty bytes argument (b"").