Skip to content

Commit

Permalink
Use typing types instead of builtins for older pythons
Browse files Browse the repository at this point in the history
  • Loading branch information
uSpike authored and superbobry committed Dec 19, 2022
1 parent dbe7492 commit 6a8b941
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions pyte/screens.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import warnings
from collections import deque, defaultdict
from functools import lru_cache
from typing import Any, Callable, DefaultDict, Dict, Generator, NamedTuple, Optional, Sequence, TextIO, TypeVar
from typing import Any, Callable, DefaultDict, Dict, Generator, List, NamedTuple, Optional, Set, Sequence, TextIO, TypeVar

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

Expand Down Expand Up @@ -214,11 +214,11 @@ def default_char(self) -> Char:
return Char(data=" ", fg="default", bg="default", reverse=reverse)

def __init__(self, columns: int, lines: int) -> None:
self.savepoints: list[Savepoint] = []
self.savepoints: List[Savepoint] = []
self.columns = columns
self.lines = lines
self.buffer: Dict[int, StaticDefaultDict[int, Char]] = defaultdict(lambda: StaticDefaultDict[int, Char](self.default_char))
self.dirty: set[int] = set()
self.dirty: Set[int] = set()
self.reset()
self.mode = _DEFAULT_MODE.copy()
self.margins: Optional[Margins] = None
Expand All @@ -228,7 +228,7 @@ def __repr__(self) -> str:
self.columns, self.lines))

@property
def display(self) -> list[str]:
def display(self) -> List[str]:
"""A :func:`list` of screen lines as unicode strings."""
def render(line: StaticDefaultDict[int, Char]) -> Generator[str, None, None]:
is_wide_char = False
Expand Down
5 changes: 3 additions & 2 deletions pyte/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
import re
import warnings
from collections import defaultdict
from typing import Any, Callable, Generator, Optional, TYPE_CHECKING
from collections.abc import Mapping
from typing import Any, Callable, Dict, Generator, Optional, TYPE_CHECKING

from . import control as ctrl, escape as esc

Expand Down Expand Up @@ -245,7 +246,7 @@ def _parser_fsm(self) -> ParserGenerator:
ctrl.VT, ctrl.FF, ctrl.CR])
OSC_TERMINATORS = set([ctrl.ST_C0, ctrl.ST_C1, ctrl.BEL])

def create_dispatcher(mapping: dict[str, str]) -> dict[str, Callable[..., None]]:
def create_dispatcher(mapping: Mapping[str, str]) -> Dict[str, Callable[..., None]]:
return defaultdict(lambda: debug, dict(
(event, getattr(listener, attr))
for event, attr in mapping.items()))
Expand Down

0 comments on commit 6a8b941

Please sign in to comment.