Skip to content

Commit

Permalink
update Python type stubs to reflect latest changes to styles module
Browse files Browse the repository at this point in the history
  • Loading branch information
apparebit committed Aug 30, 2024
1 parent e0787a8 commit 06ff134
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 85 deletions.
127 changes: 42 additions & 85 deletions prettypretty/color/style.pyi → prettypretty/color/style/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from collections.abc import Iterator
from typing import Self

from . import Color
from .. import Color
from .format import Format

class DefaultColor:
"""The default foreground or background color."""
Expand Down Expand Up @@ -208,116 +208,67 @@ class Layer:
def __str__(self) -> str: ...


class Format:
"""Text formats other than color."""
Bold: Format = ...
Thin: Format = ...
Italic: Format = ...
Underlined: Format = ...
Blinking: Format = ...
Reversed: Format = ...
Hidden: Format = ...
Stricken: Format = ...
NotBoldOrThin: Format = ...
NotItalic: Format = ...
NotUnderlined: Format = ...
NotBlinking: Format = ...
NotReversed: Format = ...
NotHidden: Format = ...
NotStricken: Format = ...

@staticmethod
def all() -> AllFormats: ...

def __hash__(self) -> int: ...
def __eq__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...


class AllFormats:
"""An iterator over all formats."""
def drain(self) -> None: ...
def __iter__(self) -> Self: ...
def __next__(self) -> Format: ...


class Formatting:
"""Terminal formatting."""
def __new__(cls) -> Self: ...
def bold(self) -> Self: ...
def thin(self) -> Self: ...
def italic(self) -> Self: ...
def underlined(self) -> Self: ...
def blinking(self) -> Self: ...
def reversed(self) -> Self: ...
def hidden(self) -> Self: ...
def stricken(self) -> Self: ...
def has(self, format: Format) -> bool: ...
def formats(self) -> Iterator[Format]: ...
def __invert__(self) -> Self: ...
def __sub__(self, other: Self) -> Self: ...
def __hash__(self) -> int: ...
def __eq__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...


class Style_Reset(Style):
class StyleToken_Reset(StyleToken):
def __new__(cls) -> Self: ...


class Style_Text(Style):
def __new__(cls, formatting: Formatting) -> Self: ...
class StyleToken_Format(StyleToken):
def __new__(cls, format: Format) -> Self: ...


class Style_Foreground(Style):
class StyleToken_Foreground(StyleToken):
def __new__(cls, foreground: TerminalColor) -> Self: ...


class Style_Background(Style):
class StyleToken_Background(StyleToken):
def __new__(cls, background: TerminalColor) -> Self: ...


class Style_HiResFore(Style):
class StyleToken_HiResForeground(StyleToken):
def __new__(cls, foreground: Color) -> Self: ...


class Style_HiResBack(Style):
class StyleToken_HiResBackground(StyleToken):
def __new__(cls, background: Color) -> Self: ...


class Style:
"""The enum of all terminal styles."""
Reset = Style_Reset
Text = Style_Text
Foreground = Style_Foreground
Background = Style_Background
HiResFore = Style_HiResFore
HiResBack = Style_HiResBack
class StyleToken:
"""The enum of all terminal style tokens."""
Reset = StyleToken_Reset
Format = StyleToken_Format
Foreground = StyleToken_Foreground
Background = StyleToken_Background
HiResForeground = StyleToken_HiResForeground
HiResBackground = StyleToken_HiResBackground

def fidelity(self) -> Fidelity: ...
def __hash__(self) -> int: ...
def __eq__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...


def style() -> StyleCollection: ...
# Create a new, empty style collection. Idiomatic use starts with this
# method, followed by fluent style selections.
class TokenIterator:
"""An iterator over style tokens."""
def __iter__(self) -> Self: ...
def __next__(self) -> Format: ...


def stylist() -> StyleBuilder: ...
# Create a new, empty style builder for assembling fluent styles.

class StyleCollection:
"""A combination of styles."""

class StyleBuilder:
"""A builder for fluently assembling styles."""
def __new__(cls) -> Self: ...
# FIXME: Enable fluent invocations!
def reset(self) -> None: ...
def bold(self) -> None: ...
def thin(self) -> None: ...
def italic(self) -> None: ...
def underlined(self) -> None: ...
def blinking(self) -> None: ...
def reversed(self) -> None: ...
def hidden(self) -> None: ...
def stricken(self) -> None: ...
def reset(self) -> Self: ...
def bold(self) -> Self: ...
def thin(self) -> Self: ...
def italic(self) -> Self: ...
def underlined(self) -> Self: ...
def blinking(self) -> Self: ...
def reversed(self) -> Self: ...
def hidden(self) -> Self: ...
def stricken(self) -> Self: ...
def foreground(
self,
color: (
Expand All @@ -334,6 +285,12 @@ class StyleCollection:
) -> None: ...
def hires_foreground(self, color: Color) -> None: ...
def hires_background(self, color: Color) -> None: ...
def go(self) -> Style: ...


class Style:
"""A style."""
def tokens(self) -> TokenIterator: ...
def fidelity(self) -> Fidelity: ...
def __hash__(self) -> int: ...
def __eq__(self, other: object) -> bool: ...
Expand Down
54 changes: 54 additions & 0 deletions prettypretty/color/style/format.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
from collections.abc import Iterator
from typing import Self

class Attribute:
"""Text attributes other than color."""
Bold: Attribute = ...
Thin: Attribute = ...
Italic: Attribute = ...
Underlined: Attribute = ...
Blinking: Attribute = ...
Reversed: Attribute = ...
Hidden: Attribute = ...
Stricken: Attribute = ...
NotBoldOrThin: Attribute = ...
NotItalic: Attribute = ...
NotUnderlined: Attribute = ...
NotBlinking: Attribute = ...
NotReversed: Attribute = ...
NotHidden: Attribute = ...
NotStricken: Attribute = ...

@staticmethod
def all() -> AllAttributes: ...

def __hash__(self) -> int: ...
def __eq__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...


class AllAttributes:
"""An iterator over all attributes."""
def drain(self) -> None: ...
def __iter__(self) -> Self: ...
def __next__(self) -> Attribute: ...


class Format:
"""Terminal formatting."""
def __new__(cls) -> Self: ...
def bold(self) -> Self: ...
def thin(self) -> Self: ...
def italic(self) -> Self: ...
def underlined(self) -> Self: ...
def blinking(self) -> Self: ...
def reversed(self) -> Self: ...
def hidden(self) -> Self: ...
def stricken(self) -> Self: ...
def has(self, format: Format) -> bool: ...
def formats(self) -> Iterator[Format]: ...
def __invert__(self) -> Self: ...
def __sub__(self, other: Self) -> Self: ...
def __hash__(self) -> int: ...
def __eq__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...

0 comments on commit 06ff134

Please sign in to comment.