On this page
  1. typing.IO
  2. Import
  3. Signature & Overview
  4. Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

typing.IO

Prev: typing.get_type_hints | Up: typing | Next: typing.NewType
Rel: typing.AbstractSet, typing.Annotated, typing.Any, typing.assert_never
Ref: docs.python.org — typing.IO
Tags: #public #python3 #stdlib #typing


Import

import typing
from typing import IO

Signature & Overview

typing.IO()

Generic base class for TextIO and BinaryIO.

Methods & Attributes

Usage

import io
from typing import IO

def read_all(stream: IO[str]) -> str:
    return stream.read()

assert read_all(io.StringIO("ok")) == "ok"

Gotchas

REPL Inspect

from typing import IO
help(IO)

Linked from

Related notes