Skip to content
Draft
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
13 changes: 13 additions & 0 deletions typings/alive_progress/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""
This type stub file was generated by pyright.
"""

from .core.configuration import config_handler
from .core.progress import alive_bar, alive_it

VERSION = ...
__author__ = ...
__email__ = ...
__version__ = ...
__description__ = ...
__all__ = ('alive_bar', 'alive_it', 'config_handler')
9 changes: 9 additions & 0 deletions typings/alive_progress/animations/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""
This type stub file was generated by pyright.
"""

from .bars import bar_factory
from .spinners import alongside_spinner_factory, bouncing_spinner_factory, delayed_spinner_factory, frame_spinner_factory, scrolling_spinner_factory, sequential_spinner_factory
from .utils import spinner_player

__all__ = ('bar_factory', 'spinner_player', 'frame_spinner_factory', 'scrolling_spinner_factory', 'bouncing_spinner_factory', 'sequential_spinner_factory', 'alongside_spinner_factory', 'delayed_spinner_factory')
69 changes: 69 additions & 0 deletions typings/alive_progress/animations/bars.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
"""
This type stub file was generated by pyright.
"""

from ..utils.colors import ORANGE_BOLD

def bar_factory(chars=..., *, tip=..., background=..., borders=..., errors=...): # -> Callable[..., tuple[Callable[..., tuple[Any | tuple[()] | tuple[Any | Literal[' '], ...], tuple[Any, *tuple[None, ...]] | tuple[()] | Any | None]], Callable[..., tuple[None, tuple[Any | tuple[Any | Literal[' '], ...]]]], Callable[..., tuple[tuple[Any, *tuple[None, ...]] | tuple[()] | None, tuple[*tuple[tuple[Any, *tuple[None, ...]] | tuple[()], ...], Any]]], Callable[..., tuple[Any, None]]]]:
"""Create a factory of a bar with the given styling parameters.
Supports unicode grapheme clusters and emoji chars (those that has length one but when on
screen occupies two cells).

Now supports transparent fills! Just send a tip, and leave `chars` as None.
Also tips are now considered for the 100%, which means it smoothly enters and exits the
frame to get to 100%!! The effect is super cool, use a multi-char tip to see.

Args:
chars (Optional[str]): the sequence of increasing glyphs to fill the bar
can be None for a transparent fill, unless tip is also None.
tip (Optional[str): the tip in front of the bar
can be None, unless chars is also None.
background (Optional[str]): the pattern to be used underneath the bar
borders (Optional[Union[str, Tuple[str, str]]): the pattern or patterns to be used
before and after the bar
errors (Optional[Union[str, Tuple[str, str]]): the pattern or patterns to be used
when an underflow or overflow occurs

Returns:
a styled bar factory

"""
...

def bar_controller(inner_bar_factory): # -> Callable[..., Callable[..., Any]]:
...

def check(bar, t_compile, verbosity=..., *, steps=...): # -> None:
"""Check the data, codepoints, and even the animation of this bar.

Args:
verbosity (int): change the verbosity level
0 for brief data only (default)
/ \\
/ 3 to include animation
/ \\
1 to unfold bar data ---------- 4 to unfold bar data
| |
2 to reveal codepoints -------- 5 to reveal codepoints
steps (int): number of steps to display the bar progress

"""
...

SECTION = ORANGE_BOLD
HELP_MSG = ...
def spec_data(bar): # -> None:
...

def format_codepoints(frame): # -> str:
...

def render_data(bar, show_codepoints, steps): # -> None:
...

def bar_repr(bar, p): # -> tuple[tuple[Any, ...], LiteralString, str]:
...

def animate(bar): # -> None:
...

150 changes: 150 additions & 0 deletions typings/alive_progress/animations/spinner_compiler.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
"""
This type stub file was generated by pyright.
"""

from ..utils.colors import ORANGE_BOLD

def spinner_controller(*, natural, skip_compiler=...): # -> Callable[..., Callable[..., Any | Callable[[], Generator[Any, Any, None]]]]:
...

def extra_command(is_compiler): # -> Callable[..., Any]:
...

EXTRA_COMMANDS = ...
@compiler_command
def replace(spec, old, new): # -> None:
"""Replace a portion of the frames by another with the same length.

Args:
old (str): the old string to be replaced
new (str): the new string

"""
...

@compiler_command
def pause(spec, edges=..., center=..., other=...): # -> None:
"""Make the animation appear to pause at the edges or at the middle, or make it slower as
a whole, or both.

Use without arguments to get their defaults, which gives a small pause at the edges,
very nice for bouncing text with `hide=False`. Please note that the defaults only apply
if none of the params are set.

In the future, I'd like to make this a `pace` command, which would receive a sequence
of ints of any length, and apply it bouncing across the cycle. For example to smoothly
decelerate it could be (6, 3, 2, 1), which would become (6, 3, 2, 1, 1, ..., 1, 2, 3, 6).

Args:
edges (Optional[int]): how many times the first and last frames of a cycle repeats
default is 8.
center (Optional[int]): how many times the middle frame of a cycle repeats
default is 1.
other (Optional[int]): how many times all the other frames of a cycle repeats
default is 1.

"""
...

@compiler_command
def reshape(spec, num_frames): # -> None:
"""Reshape frame data into another grouping. It can be used to simplify content
description, or for artistic effects.

Args:
num_frames (int): the number of consecutive frames to group

"""
...

@compiler_command
def bounce(spec): # -> None:
"""Make the animation bounce its cycles."""
...

@compiler_command
def transpose(spec): # -> None:
"""Transpose the frame content matrix, exchanging columns for rows. It can be used
to simplify content description, or for artistic effects."""
...

@runner_command
def sequential(spec): # -> None:
"""Configure the runner to play the compiled cycles in sequential order."""
...

@runner_command
def randomize(spec, cycles=...): # -> None:
"""Configure the runner to play the compiled cycles in random order.

Args:
cycles (Optional[int]): number of cycles to play randomized

"""
...

def apply_extra_commands(spec, extra_commands): # -> None:
...

def spinner_compiler(gen, natural, extra_commands): # -> SimpleNamespace:
"""Optimized spinner compiler, which compiles ahead of time all frames of all cycles
of a spinner.

Args:
gen (Generator): the generator expressions that defines the cycles and their frames
natural (int): the natural length of the spinner
extra_commands (tuple[tuple[cmd, list[Any], dict[Any]]]): requested extra commands

Returns:
the spec of a compiled animation

"""
...

def spinner_runner_factory(spec, t_compile, extra_commands): # -> Callable[[], Generator[Any, Any, None]]:
"""Optimized spinner runner, which receives the spec of an animation, and controls
the flow of cycles and frames already compiled to a certain screen length and with
wide chars fixed, thus avoiding any overhead in runtime within complex spinners,
while allowing their factories to be garbage collected.

Args:
spec (SimpleNamespace): the spec of an animation
t_compile (about_time.Handler): the compile time information
extra_commands (tuple[tuple[cmd, list[Any], dict[Any]]]): requested extra commands

Returns:
a spinner runner

"""
...

def check(spec, verbosity=...): # -> None:
"""Check the specs, contents, codepoints, and even the animation of this compiled spinner.

Args:
verbosity (int): change the verbosity level
0 for specs only (default)
/ \\
/ 3 to include animation
/ \\
1 to unfold frame data -------- 4 to unfold frame data
| |
2 to reveal codepoints -------- 5 to reveal codepoints

"""
...

SECTION = ORANGE_BOLD
HELP_MSG = ...
def spec_data(spec): # -> None:
...

def format_codepoints(frame): # -> str:
...

def render_data(spec, show_codepoints): # -> None:
...

def animate(spec): # -> None:
...

127 changes: 127 additions & 0 deletions typings/alive_progress/animations/spinners.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
"""
This type stub file was generated by pyright.
"""

def frame_spinner_factory(*frames): # -> Callable[..., Generator[Generator[Any, Any, None], None, None]]:
"""Create a factory of a spinner that delivers frames in sequence, split by cycles.
Supports unicode grapheme clusters and emoji chars (those that has length one but when on
screen occupies two cells), as well as all other spinners.

Args:
frames (Union[str, Tuple[str, ...]): the frames to be displayed, split by cycles
if sent only a string, it is interpreted as frames of a single char each.

Returns:
a styled spinner factory

Examples:
To define one cycle:
>>> frame_spinner_factory(('cool',)) # only one frame.
>>> frame_spinner_factory(('ooo', '---')) # two frames.
>>> frame_spinner_factory('|/_') # three frames of one char each, same as below.
>>> frame_spinner_factory(('|', '/', '_'))

To define two cycles:
>>> frame_spinner_factory(('super',), ('cool',)) # one frame each.
>>> frame_spinner_factory(('ooo', '-'), ('vvv', '^')) # two frames each.
>>> frame_spinner_factory('|/_', '▁▄█') # three frames each, same as below.
>>> frame_spinner_factory(('|', '/', '_'), ('▁', '▄', '█'))

Mix and match at will:
>>> frame_spinner_factory(('oo', '-'), 'cool', ('it', 'is', 'alive!'))

"""
...

def scrolling_spinner_factory(chars, length=..., block=..., background=..., *, right=..., hide=..., wrap=..., overlay=...): # -> Callable[..., Generator[Generator[tuple[str, ...], Any, None], None, None]]:
"""Create a factory of a spinner that scrolls characters from one side to
the other, configurable with various constraints.
Supports unicode grapheme clusters and emoji chars, those that has length one but when on
screen occupies two cells.

Args:
chars (str): the characters to be scrolled, either together or split in blocks
length (Optional[int]): the natural length that should be used in the style
block (Optional[int]): if defined, split chars in blocks with this size
background (Optional[str]): the pattern to be used besides or underneath the animations
right (bool): the scroll direction to animate
hide (bool): controls whether the animation goes through the borders or not
wrap (bool): makes the animation wrap borders or stop when not hiding.
overlay (bool): fixes the background in place if overlay, scrolls it otherwise

Returns:
a styled spinner factory

"""
...

def bouncing_spinner_factory(chars, length=..., block=..., background=..., *, right=..., hide=..., overlay=...): # -> Callable[..., Generator[Generator[Any, Any, None], None, None]]:
"""Create a factory of a spinner that scrolls characters from one side to
the other and bounce back, configurable with various constraints.
Supports unicode grapheme clusters and emoji chars, those that has length one but when on
screen occupies two cells.

Args:
chars (Union[str, Tuple[str, str]]): the characters to be scrolled, either
together or split in blocks. Also accepts a tuple of two strings,
which are used one in each direction.
length (Optional[int]): the natural length that should be used in the style
block (Union[int, Tuple[int, int], None]): if defined, split chars in blocks
background (Optional[str]): the pattern to be used besides or underneath the animations
right (bool): the scroll direction to start the animation
hide (bool): controls whether the animation goes through the borders or not
overlay (bool): fixes the background in place if overlay, scrolls it otherwise

Returns:
a styled spinner factory

"""
...

def sequential_spinner_factory(*spinner_factories, intermix=...): # -> Callable[..., Generator[Generator[Any, Any, None], None, None]]:
"""Create a factory of a spinner that combines other spinners together, playing them
one at a time sequentially, either intermixing their cycles or until depletion.

Args:
spinner_factories (spinner): the spinners to be combined
intermix (bool): intermixes the cycles if True, generating all possible combinations;
runs each one until depletion otherwise.

Returns:
a styled spinner factory

"""
...

def alongside_spinner_factory(*spinner_factories, pivot=...): # -> Callable[..., Generator[Generator[Any | tuple[()], Any, None], None, None]]:
"""Create a factory of a spinner that combines other spinners together, playing them
alongside simultaneously. Each one uses its own natural length, which is spread weighted
to the available space.

Args:
spinner_factories (spinner): the spinners to be combined
pivot (Optional[int]): the index of the spinner to dictate the animation cycles
if None, the whole animation will be compiled into a unique cycle.

Returns:
a styled spinner factory

"""
...

def delayed_spinner_factory(spinner_factory, copies, offset=..., *, dynamic=...): # -> Any | Callable[..., Any]:
"""Create a factory of a spinner that combines itself several times alongside,
with an increasing iteration offset on each one.

Args:
spinner_factory (spinner): the source spinner
copies (int): the number of copies
offset (int): the offset to be applied incrementally to each copy
dynamic (bool): dynamically changes the number of copies based on available space

Returns:
a styled spinner factory

"""
...

Loading
Loading