Skip to content
Open
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
21 changes: 18 additions & 3 deletions stubs/tabulate/tabulate/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections.abc import Callable, Container, Iterable, Mapping, Sequence
from typing import Any, Final, Literal, NamedTuple, TypeAlias
from collections.abc import Callable, Container, Iterable, Iterator, Mapping, Sequence
from typing import Any, Final, Literal, NamedTuple, Protocol, TypeAlias, type_check_only
from typing_extensions import Self

__all__ = ["tabulate", "tabulate_formats", "simple_separated_format"]
Expand Down Expand Up @@ -41,10 +41,25 @@ LATEX_ESCAPE_RULES: Final[dict[str, str]]
tabulate_formats: list[str]
multiline_formats: dict[str, str]

@type_check_only
class _IndexLike(Protocol):
def __iter__(self) -> Iterator[Any]: ...
@property
def name(self) -> Any: ...

@type_check_only
class _DataFrameLike(Protocol):
def __iter__(self) -> Iterator[Any]: ...
def keys(self) -> Any: ...
@property
def values(self) -> Iterable[Any]: ...
@property
def index(self) -> _IndexLike: ...

def simple_separated_format(separator: str) -> TableFormat: ...
def tabulate(
# The key is converted using str().
tabular_data: Mapping[Any, Iterable[Any]] | Iterable[Iterable[Any]],
tabular_data: Mapping[Any, Iterable[Any]] | Iterable[Iterable[Any]] | _DataFrameLike,
headers: str | dict[str, str] | Sequence[str] = (),
tablefmt: str | TableFormat = "simple",
floatfmt: str | Iterable[str] = "g",
Expand Down
Loading