From ebc521869db925df7c5db3ba72a0e5a08214e867 Mon Sep 17 00:00:00 2001 From: Rune Tynan Date: Mon, 3 Feb 2020 01:13:56 -0500 Subject: [PATCH] Add missing parameter types to optparse (#3711) * Add missing parameter types to optparse * mark add_option_group arg as positional-only Co-authored-by: Jelle Zijlstra --- stdlib/2and3/optparse.pyi | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/stdlib/2and3/optparse.pyi b/stdlib/2and3/optparse.pyi index e3fe3142a..5e4f3a9c4 100644 --- a/stdlib/2and3/optparse.pyi +++ b/stdlib/2and3/optparse.pyi @@ -1,6 +1,6 @@ # Generated by pytype, with only minor tweaks. Might be incomplete. import sys -from typing import Any, AnyStr, Callable, Dict, IO, Iterable, List, Mapping, Optional, Sequence, Tuple, Union +from typing import Any, AnyStr, Callable, Dict, IO, Iterable, List, Mapping, Optional, Sequence, Tuple, Union, overload # See https://groups.google.com/forum/#!topic/python-ideas/gA1gdj3RZ5g if sys.version_info >= (3,): @@ -59,7 +59,7 @@ class HelpFormatter: def dedent(self) -> None: ... def expand_default(self, option: Option) -> _Text: ... def format_description(self, description: _Text) -> _Text: ... - def format_epilog(self, epilog) -> _Text: ... + def format_epilog(self, epilog: _Text) -> _Text: ... def format_heading(self, heading: Any) -> _Text: ... def format_option(self, option: OptionParser) -> _Text: ... def format_option_strings(self, option: OptionParser) -> Any: ... @@ -104,7 +104,7 @@ class Option: dest: Optional[_Text] nargs: int type: Any - def __init__(self, *opts, **attrs) -> None: ... + def __init__(self, *opts: Optional[_Text], **attrs: Any) -> None: ... def _check_action(self) -> None: ... def _check_callback(self) -> None: ... def _check_choice(self) -> None: ... @@ -135,7 +135,10 @@ class OptionContainer: def _check_conflict(self, option: Any) -> None: ... def _create_option_mappings(self) -> None: ... def _share_option_mappings(self, parser: OptionParser) -> None: ... - def add_option(self, *args, **kwargs) -> Any: ... + @overload + def add_option(self, opt: Option) -> Option: ... + @overload + def add_option(self, *args: Optional[_Text], **kwargs: Any) -> Any: ... def add_options(self, option_list: Iterable[Option]) -> None: ... def destroy(self) -> None: ... def format_description(self, formatter: Optional[HelpFormatter]) -> Any: ... @@ -203,7 +206,10 @@ class OptionParser(OptionContainer): def _process_args(self, largs: List[Any], rargs: List[Any], values: Values) -> None: ... def _process_long_opt(self, rargs: List[Any], values: Any) -> None: ... def _process_short_opts(self, rargs: List[Any], values: Any) -> None: ... - def add_option_group(self, *args, **kwargs) -> OptionParser: ... + @overload + def add_option_group(self, __opt_group: OptionGroup) -> OptionParser: ... + @overload + def add_option_group(self, *args: Any, **kwargs: Any) -> OptionParser: ... def check_values(self, values: Values, args: List[_Text]) -> Tuple[Values, List[_Text]]: ... def disable_interspersed_args(self) -> None: ... def enable_interspersed_args(self) -> None: ... @@ -223,6 +229,6 @@ class OptionParser(OptionContainer): def print_help(self, file: Optional[IO[str]] = ...) -> None: ... def print_version(self, file: Optional[IO[str]] = ...) -> None: ... def set_default(self, dest: Any, value: Any) -> None: ... - def set_defaults(self, **kwargs) -> None: ... + def set_defaults(self, **kwargs: Any) -> None: ... def set_process_default_values(self, process: Any) -> None: ... def set_usage(self, usage: _Text) -> None: ...