1 2from typing import Any, Callable, Collection, Iterable, List, NoReturn, Optional, Text, TypeVar, Union, overload 3 4from absl.flags import _flag 5 6 7_MainArgs = TypeVar('_MainArgs') 8_Exc = TypeVar('_Exc', bound=Exception) 9 10 11class ExceptionHandler(): 12 13 def wants(self, exc: _Exc) -> bool: 14 ... 15 16 def handle(self, exc: _Exc): 17 ... 18 19 20EXCEPTION_HANDLERS: List[ExceptionHandler] = ... 21 22 23class HelpFlag(_flag.BooleanFlag): 24 def __init__(self): 25 ... 26 27 28class HelpshortFlag(HelpFlag): 29 ... 30 31 32class HelpfullFlag(_flag.BooleanFlag): 33 def __init__(self): 34 ... 35 36 37class HelpXMLFlag(_flag.BooleanFlag): 38 def __init__(self): 39 ... 40 41 42def define_help_flags() -> None: 43 ... 44 45 46@overload 47def usage(shorthelp: Union[bool, int] = ..., 48 writeto_stdout: Union[bool, int] = ..., 49 detailed_error: Optional[Any] = ..., 50 exitcode: None = ...) -> None: 51 ... 52 53 54@overload 55def usage(shorthelp: Union[bool, int] = ..., 56 writeto_stdout: Union[bool, int] = ..., 57 detailed_error: Optional[Any] = ..., 58 exitcode: int = ...) -> NoReturn: 59 ... 60 61 62def install_exception_handler(handler: ExceptionHandler) -> None: 63 ... 64 65 66class Error(Exception): 67 ... 68 69 70class UsageError(Error): 71 exitcode: int 72 73 74def parse_flags_with_usage(args: List[Text]) -> List[Text]: 75 ... 76 77 78def call_after_init(callback: Callable[[], Any]) -> None: 79 ... 80 81 82# Without the flag_parser argument, `main` should require a List[Text]. 83@overload 84def run( 85 main: Callable[[List[Text]], Any], 86 argv: Optional[List[Text]] = ..., 87 *, 88) -> NoReturn: 89 ... 90 91 92@overload 93def run( 94 main: Callable[[_MainArgs], Any], 95 argv: Optional[List[Text]] = ..., 96 *, 97 flags_parser: Callable[[List[Text]], _MainArgs], 98) -> NoReturn: 99 ... 100