Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions pyte/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@
__all__ = ("Screen", "DiffScreen", "HistoryScreen", "DebugScreen",
"Stream", "ByteStream")

import io
from typing import Union

from .screens import Screen, DiffScreen, HistoryScreen, DebugScreen
from .streams import Stream, ByteStream


if __debug__:
import io

def dis(chars: bytes | str) -> None:
"""A :func:`dis.dis` for terminals.

Expand Down
7 changes: 5 additions & 2 deletions pyte/screens.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
import warnings
from collections import deque, defaultdict
from functools import lru_cache
from typing import Any, Dict, List, NamedTuple, Optional, Set, TextIO, TypeVar
from collections.abc import Callable, Generator, Sequence
from typing import TYPE_CHECKING, NamedTuple, TypeVar

from wcwidth import wcwidth as _wcwidth # type: ignore[import-untyped]

Expand All @@ -48,6 +47,10 @@
)
from .streams import Stream

if TYPE_CHECKING:
from collections.abc import Callable, Generator, Sequence
from typing import Any, NamedTuple, TextIO

wcwidth: Callable[[str], int] = lru_cache(maxsize=4096)(_wcwidth)

KT = TypeVar("KT")
Expand Down
8 changes: 4 additions & 4 deletions pyte/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@
import re
import warnings
from collections import defaultdict
from collections.abc import Mapping
from typing import Any, Dict, Optional, TYPE_CHECKING
from collections.abc import Callable, Generator
from typing import TYPE_CHECKING

from . import control as ctrl, escape as esc

if TYPE_CHECKING:
from collections.abc import Callable, Generator, Mapping
from typing import Any
from .screens import Screen

ParserGenerator = Generator[bool | None, str, None]

ParserGenerator = Generator[Optional[bool], str, None]

class Stream:
"""A stream is a state machine that parses a stream of bytes and
Expand Down