|
| 1 | +from _typeshed import Incomplete |
| 2 | +from collections import OrderedDict |
| 3 | +from collections.abc import Iterable, Iterator, Mapping, Sequence |
| 4 | +from typing import ClassVar, TypeAlias, TypeVar, overload |
| 5 | +from typing_extensions import Never, Self |
| 6 | + |
| 7 | +from behave.model_core import Replayable |
| 8 | + |
| 9 | +_T = TypeVar("_T") |
| 10 | + |
| 11 | +# A table row, either already parsed or as a plain list of cell values. |
| 12 | +_RowData: TypeAlias = Row | list[str] |
| 13 | + |
| 14 | +class Table(Replayable): |
| 15 | + type: ClassVar[str] |
| 16 | + headings: list[str] |
| 17 | + rows: list[Row] |
| 18 | + line: int |
| 19 | + modified: bool |
| 20 | + def __init__(self, headings: list[str], rows: Iterable[_RowData] | None = None, line: int | None = None) -> None: ... |
| 21 | + def clear(self, headings: list[str] | None = None, keep_headings: bool = True) -> None: ... |
| 22 | + def add_row(self, row: _RowData, line: int | None = None) -> None: ... |
| 23 | + def add_column(self, column_name: str, values: Iterable[str] | None = None, default_value: str = "") -> int: ... |
| 24 | + def remove_column(self, column_name_or_index: str | int) -> None: ... |
| 25 | + def remove_columns(self, column_names: Iterable[str]) -> None: ... |
| 26 | + def has_column(self, column_name: str) -> bool: ... |
| 27 | + def get_column_index(self, column_name: str) -> int: ... |
| 28 | + def require_column(self, column_name: str) -> int: ... |
| 29 | + def require_columns(self, column_names: Iterable[str]) -> None: ... |
| 30 | + def ensure_column_exists(self, column_name: str) -> int: ... |
| 31 | + def __eq__(self, other: object) -> bool: ... |
| 32 | + def __ne__(self, other: object) -> bool: ... |
| 33 | + def __iter__(self) -> Iterator[Row]: ... |
| 34 | + |
| 35 | + @overload |
| 36 | + def __getitem__(self, index: int) -> Row: ... |
| 37 | + @overload |
| 38 | + def __getitem__(self, index: slice) -> list[Row]: ... |
| 39 | + |
| 40 | + # Always raises: the comparison is asserted and then `NotImplementedError` is raised. |
| 41 | + def assert_equals(self, data: object) -> Never: ... |
| 42 | + @classmethod |
| 43 | + def from_dicts(cls, headings: list[str], table_data: Sequence[dict[str, str]], line: int | None = None) -> Self: ... |
| 44 | + @classmethod |
| 45 | + def from_data( |
| 46 | + cls, headings: list[str], table_data: Sequence[dict[str, str] | _RowData] | None = None, line: int = 0 |
| 47 | + ) -> Table: ... |
| 48 | + |
| 49 | +class Row: |
| 50 | + headings: list[str] |
| 51 | + cells: list[str] |
| 52 | + line: int | None |
| 53 | + comments: Incomplete | None |
| 54 | + def __init__(self, headings: list[str], cells: list[str], line: int | None = None, comments=None) -> None: ... |
| 55 | + def __getitem__(self, name: str | int) -> str: ... |
| 56 | + def __contains__(self, item: str) -> bool: ... |
| 57 | + def __eq__(self, other: object) -> bool: ... |
| 58 | + def __ne__(self, other: object) -> bool: ... |
| 59 | + def __len__(self) -> int: ... |
| 60 | + def __iter__(self) -> Iterator[str]: ... |
| 61 | + def items(self) -> zip[tuple[str, str]]: ... |
| 62 | + |
| 63 | + @overload |
| 64 | + def get(self, key: str | int, default: None = None) -> str | None: ... |
| 65 | + @overload |
| 66 | + def get(self, key: str | int, default: _T) -> str | _T: ... |
| 67 | + |
| 68 | + def as_dict(self) -> OrderedDict[str, str]: ... |
| 69 | + @classmethod |
| 70 | + def from_dict(cls, headings: list[str], row_data: Mapping[str, str], *, line: int | None = None, comments=None) -> Self: ... |
| 71 | + |
| 72 | +def __getattr__(name: str) -> Incomplete: ... |
0 commit comments