mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-22 07:08:10 +00:00
tnetstring: accept IO[bytes], not just BinaryIO
This commit is contained in:
parent
04a1ff4a42
commit
7624e19010
@ -1,5 +1,5 @@
|
||||
import os
|
||||
from typing import Any, Dict, Iterable, Type, Union, cast, BinaryIO # noqa
|
||||
from typing import Any, Dict, IO, Iterable, Type, Union, cast
|
||||
|
||||
from mitmproxy import exceptions
|
||||
from mitmproxy import flow
|
||||
@ -25,8 +25,8 @@ class FlowWriter:
|
||||
|
||||
|
||||
class FlowReader:
|
||||
def __init__(self, fo: BinaryIO):
|
||||
self.fo: BinaryIO = fo
|
||||
def __init__(self, fo: IO[bytes]):
|
||||
self.fo: IO[bytes] = fo
|
||||
|
||||
def stream(self) -> Iterable[flow.Flow]:
|
||||
"""
|
||||
|
@ -58,7 +58,7 @@ def dumps(value: TSerializable) -> bytes:
|
||||
return b''.join(q)
|
||||
|
||||
|
||||
def dump(value: TSerializable, file_handle: typing.BinaryIO) -> None:
|
||||
def dump(value: TSerializable, file_handle: typing.IO[bytes]) -> None:
|
||||
"""
|
||||
This function dumps a python object as a tnetstring and
|
||||
writes it to the given file.
|
||||
@ -156,7 +156,7 @@ def loads(string: bytes) -> TSerializable:
|
||||
return pop(string)[0]
|
||||
|
||||
|
||||
def load(file_handle: typing.BinaryIO) -> TSerializable:
|
||||
def load(file_handle: typing.IO[bytes]) -> TSerializable:
|
||||
"""load(file) -> object
|
||||
|
||||
This function reads a tnetstring from a file and parses it into a
|
||||
|
Loading…
Reference in New Issue
Block a user