from typing import IO
import io


def with_mode_binary(stream: IO) -> bool:
    """
    Return whether ``stream`` is a binary stream (i.e. reads bytes).
    """
    result = False
    try:
        result = 'b' in stream.mode
    except AttributeError:
        if isinstance(stream, (io.RawIOBase, io.BufferedIOBase, io.BytesIO)):
            result = True

    return result