tnetstring: accept IO[bytes], not just BinaryIO

This commit is contained in:
Maximilian Hils 2021-08-03 14:39:12 +02:00
parent 04a1ff4a42
commit 7624e19010
2 changed files with 5 additions and 5 deletions

View File

@ -1,5 +1,5 @@
import os 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 exceptions
from mitmproxy import flow from mitmproxy import flow
@ -25,8 +25,8 @@ class FlowWriter:
class FlowReader: class FlowReader:
def __init__(self, fo: BinaryIO): def __init__(self, fo: IO[bytes]):
self.fo: BinaryIO = fo self.fo: IO[bytes] = fo
def stream(self) -> Iterable[flow.Flow]: def stream(self) -> Iterable[flow.Flow]:
""" """

View File

@ -58,7 +58,7 @@ def dumps(value: TSerializable) -> bytes:
return b''.join(q) 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 This function dumps a python object as a tnetstring and
writes it to the given file. writes it to the given file.
@ -156,7 +156,7 @@ def loads(string: bytes) -> TSerializable:
return pop(string)[0] return pop(string)[0]
def load(file_handle: typing.BinaryIO) -> TSerializable: def load(file_handle: typing.IO[bytes]) -> TSerializable:
"""load(file) -> object """load(file) -> object
This function reads a tnetstring from a file and parses it into a This function reads a tnetstring from a file and parses it into a