| 1 | from collections.abc import Iterable, Sequence |
| 2 | from typing import Protocol, TypeVar, overload, type_check_only |
| 3 | |
| 4 | _StrSequenceT_co = TypeVar("_StrSequenceT_co", covariant=True, bound=Sequence[str]) |
| 5 | |
| 6 | @type_check_only |
| 7 | class _SliceableT(Protocol[_StrSequenceT_co]): |
| 8 | @overload |
| 9 | def __getitem__(self, key: int, /) -> str: ... |
| 10 | @overload |
| 11 | def __getitem__(self, key: slice, /) -> _StrSequenceT_co: ... |
| 12 | |
| 13 | __all__ = ["GetoptError", "error", "getopt", "gnu_getopt"] |
| 14 | |
| 15 | def getopt( |
| 16 | args: _SliceableT[_StrSequenceT_co], shortopts: str, longopts: Iterable[str] | str = [] |
| 17 | ) -> tuple[list[tuple[str, str]], _StrSequenceT_co]: ... |
| 18 | def gnu_getopt( |
| 19 | args: Sequence[str], shortopts: str, longopts: Iterable[str] | str = [] |
| 20 | ) -> tuple[list[tuple[str, str]], list[str]]: ... |
| 21 | |
| 22 | class GetoptError(Exception): |
| 23 | msg: str |
| 24 | opt: str |
| 25 | def __init__(self, msg: str, opt: str = "") -> None: ... |
| 26 | |
| 27 | error = GetoptError |