diff --git a/blessed/_capabilities.pyi b/blessed/_capabilities.pyi index 04c59c3..6930f45 100644 --- a/blessed/_capabilities.pyi +++ b/blessed/_capabilities.pyi @@ -1,3 +1,5 @@ +"""Type hint for terminal capability builder patterns""" + # std imports from typing import Any, Dict, Tuple, OrderedDict diff --git a/blessed/color.pyi b/blessed/color.pyi index ece82e3..670d7f4 100644 --- a/blessed/color.pyi +++ b/blessed/color.pyi @@ -1,8 +1,12 @@ +"""Type hints for color functions""" + # std imports from typing import Dict, Tuple, Callable _RGB = Tuple[int, int, int] +# pylint: disable=unused-argument,missing-function-docstring + def rgb_to_xyz(red: int, green: int, blue: int) -> Tuple[float, float, float]: ... def xyz_to_lab( x_val: float, y_val: float, z_val: float diff --git a/blessed/colorspace.pyi b/blessed/colorspace.pyi index a799cd0..4683720 100644 --- a/blessed/colorspace.pyi +++ b/blessed/colorspace.pyi @@ -1,8 +1,12 @@ +"""Type hints for color reference data""" + # std imports from typing import Set, Dict, Tuple, NamedTuple CGA_COLORS: Set[str] +#pylint: disable=missing-class-docstring + class RGBColor(NamedTuple): red: int green: int diff --git a/blessed/formatters.pyi b/blessed/formatters.pyi index 32a3dc2..f007288 100644 --- a/blessed/formatters.pyi +++ b/blessed/formatters.pyi @@ -1,5 +1,8 @@ +"""Type hints for sequence-formatting functions""" + # std imports -from typing import (Any, +from typing import (TYPE_CHECKING, + Any, Set, List, Type, @@ -11,14 +14,17 @@ from typing import (Any, Optional, overload) -# local -from .terminal import Terminal +if TYPE_CHECKING: + # local + from .terminal import Terminal COLORS: Set[str] COMPOUNDABLES: Set[str] _T = TypeVar("_T") +# pylint: disable=unused-argument,missing-function-docstring,missing-class-docstring + class ParameterizingString(str): def __new__(cls: Type[_T], cap: str, normal: str = ..., name: str = ...) -> _T: ... @overload @@ -58,13 +64,13 @@ class NullCallableString(str): def __call__(self, *args: str) -> str: ... def get_proxy_string( - term: Terminal, attr: str + term: 'Terminal', attr: str ) -> Optional[ParameterizingProxyString]: ... def split_compound(compound: str) -> List[str]: ... -def resolve_capability(term: Terminal, attr: str) -> str: ... +def resolve_capability(term: 'Terminal', attr: str) -> str: ... def resolve_color( - term: Terminal, color: str + term: 'Terminal', color: str ) -> Union[NullCallableString, FormattingString]: ... def resolve_attribute( - term: Terminal, attr: str + term: 'Terminal', attr: str ) -> Union[ParameterizingString, FormattingString]: ... diff --git a/blessed/keyboard.pyi b/blessed/keyboard.pyi index ae76393..d751227 100644 --- a/blessed/keyboard.pyi +++ b/blessed/keyboard.pyi @@ -1,11 +1,16 @@ +"""Type hints for 'keyboard awareness'""" + # std imports -from typing import Set, Dict, Type, Mapping, TypeVar, Iterable, Optional, OrderedDict +from typing import TYPE_CHECKING, Set, Dict, Type, Mapping, TypeVar, Iterable, Optional, OrderedDict -# local -from .terminal import Terminal +if TYPE_CHECKING: + # local + from .terminal import Terminal _T = TypeVar("_T") +# pylint: disable=unused-argument,missing-function-docstring,missing-class-docstring + class Keystroke(str): def __new__( cls: Type[_T], @@ -21,7 +26,7 @@ class Keystroke(str): def code(self) -> Optional[int]: ... def get_keyboard_codes() -> Dict[int, str]: ... -def get_keyboard_sequences(term: Terminal) -> OrderedDict[str, int]: ... +def get_keyboard_sequences(term: 'Terminal') -> OrderedDict[str, int]: ... def get_leading_prefixes(sequences: Iterable[str]) -> Set[str]: ... def resolve_sequence( text: str, mapper: Mapping[str, int], codes: Mapping[int, str] diff --git a/blessed/sequences.py b/blessed/sequences.py index 486294c..0f4c70a 100644 --- a/blessed/sequences.py +++ b/blessed/sequences.py @@ -15,6 +15,8 @@ __all__ = ('Sequence', 'SequenceTextWrapper', 'iter_parse', 'measure_length') +# pylint: disable=unused-argument,missing-function-docstring + class Termcap(object): """Terminal capability of given variable name and pattern.""" diff --git a/blessed/sequences.pyi b/blessed/sequences.pyi index 4460b7a..7167992 100644 --- a/blessed/sequences.pyi +++ b/blessed/sequences.pyi @@ -1,12 +1,26 @@ +"""Type hints for 'sequence awareness'""" + # std imports import textwrap -from typing import Any, Type, Tuple, Pattern, TypeVar, Iterator, Optional, SupportsIndex +from typing import (TYPE_CHECKING, + Any, + Type, + Tuple, + Pattern, + TypeVar, + Iterator, + Optional, + SupportsIndex) -# local -from .terminal import Terminal +if TYPE_CHECKING: + # local + from .terminal import Terminal _T = TypeVar("_T") +# pylint: disable=unused-argument,missing-function-docstring,missing-class-docstring +# pylint: disable=super-init-not-called + class Termcap: name: str = ... pattern: str = ... @@ -33,11 +47,11 @@ class Termcap: ) -> "Termcap": ... class SequenceTextWrapper(textwrap.TextWrapper): - term: Terminal = ... - def __init__(self, width: int, term: Terminal, **kwargs: Any) -> None: ... + term: 'Terminal' = ... + def __init__(self, width: int, term: 'Terminal', **kwargs: Any) -> None: ... class Sequence(str): - def __new__(cls: Type[_T], sequence_text: str, term: Terminal) -> _T: ... + def __new__(cls: Type[_T], sequence_text: str, term: 'Terminal') -> _T: ... def ljust(self, width: SupportsIndex, fillchar: str = ...) -> str: ... def rjust(self, width: SupportsIndex, fillchar: str = ...) -> str: ... def center(self, width: SupportsIndex, fillchar: str = ...) -> str: ... @@ -50,6 +64,6 @@ class Sequence(str): def padd(self, strip: bool = ...) -> str: ... def iter_parse( - term: Terminal, text: str + term: 'Terminal', text: str ) -> Iterator[Tuple[str, Optional[Termcap]]]: ... -def measure_length(text: str, term: Terminal) -> int: ... +def measure_length(text: str, term: 'Terminal') -> int: ... diff --git a/blessed/terminal.py b/blessed/terminal.py index 6d5a13e..fd3e38e 100644 --- a/blessed/terminal.py +++ b/blessed/terminal.py @@ -894,6 +894,7 @@ def formatter(self, value): inadvertently returning another terminal capability. """ formatters = split_compound(value) + # Pylint sometimes thinks formatters isn't a list # pylint: disable=not-an-iterable if all((fmt in COLORS or fmt in COMPOUNDABLES) for fmt in formatters): return getattr(self, value) diff --git a/blessed/terminal.pyi b/blessed/terminal.pyi index bff670b..f7f5d43 100644 --- a/blessed/terminal.pyi +++ b/blessed/terminal.pyi @@ -1,3 +1,5 @@ +"""Type hints for :class:`Terminal`, the primary API entry point.""" + # std imports from typing import IO, Any, List, Tuple, Union, Optional, OrderedDict, SupportsIndex, ContextManager @@ -11,6 +13,9 @@ from .formatters import (FormattingString, HAS_TTY: bool +# pylint: disable=unused-argument,missing-function-docstring,missing-class-docstring +# pylint: disable=too-many-public-methods,too-few-public-methods + class Terminal: caps: OrderedDict[str, Termcap] errors: List[str] = ... @@ -105,4 +110,5 @@ class Terminal: self, timeout: Optional[float] = ..., esc_delay: float = ... ) -> Keystroke: ... -class WINSZ: ... +class WINSZ: + ... diff --git a/blessed/win_terminal.pyi b/blessed/win_terminal.pyi index 275f16f..2474389 100644 --- a/blessed/win_terminal.pyi +++ b/blessed/win_terminal.pyi @@ -1,9 +1,13 @@ +"""Type hints for Windows version of :class:`Terminal`.""" + # std imports from typing import Optional, ContextManager # local from .terminal import Terminal as _Terminal +# pylint: disable=missing-class-docstring + class Terminal(_Terminal): def getch(self) -> str: ... def kbhit(self, timeout: Optional[float] = ...) -> bool: ...