Switch to PEP-604 syntax in python2 stubs (#5915)

Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
This commit is contained in:
Oleg Höfling
2021-08-14 11:12:30 +02:00
committed by GitHub
parent 431c4f7fc1
commit ff63953188
235 changed files with 2473 additions and 2768 deletions

View File

@@ -1,4 +1,4 @@
from typing import IO, Any, AnyStr, Callable, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, Type, Union, overload
from typing import IO, Any, AnyStr, Callable, Dict, Iterable, List, Mapping, Sequence, Tuple, Type, Union, overload
# See https://groups.google.com/forum/#!topic/python-ideas/gA1gdj3RZ5g
_Text = Union[str, unicode]
@@ -46,7 +46,7 @@ class HelpFormatter:
parser: OptionParser
short_first: Any
width: int
def __init__(self, indent_increment: int, max_help_position: int, width: Optional[int], short_first: int) -> None: ...
def __init__(self, indent_increment: int, max_help_position: int, width: int | None, short_first: int) -> None: ...
def dedent(self) -> None: ...
def expand_default(self, option: Option) -> _Text: ...
def format_description(self, description: _Text) -> _Text: ...
@@ -63,14 +63,14 @@ class HelpFormatter:
class IndentedHelpFormatter(HelpFormatter):
def __init__(
self, indent_increment: int = ..., max_help_position: int = ..., width: Optional[int] = ..., short_first: int = ...
self, indent_increment: int = ..., max_help_position: int = ..., width: int | None = ..., short_first: int = ...
) -> None: ...
def format_heading(self, heading: _Text) -> _Text: ...
def format_usage(self, usage: _Text) -> _Text: ...
class TitledHelpFormatter(HelpFormatter):
def __init__(
self, indent_increment: int = ..., max_help_position: int = ..., width: Optional[int] = ..., short_first: int = ...
self, indent_increment: int = ..., max_help_position: int = ..., width: int | None = ..., short_first: int = ...
) -> None: ...
def format_heading(self, heading: _Text) -> _Text: ...
def format_usage(self, usage: _Text) -> _Text: ...
@@ -79,7 +79,7 @@ class Option:
ACTIONS: Tuple[_Text, ...]
ALWAYS_TYPED_ACTIONS: Tuple[_Text, ...]
ATTRS: List[_Text]
CHECK_METHODS: Optional[List[Callable[..., Any]]]
CHECK_METHODS: List[Callable[..., Any]] | None
CONST_ACTIONS: Tuple[_Text, ...]
STORE_ACTIONS: Tuple[_Text, ...]
TYPED_ACTIONS: Tuple[_Text, ...]
@@ -88,23 +88,23 @@ class Option:
_long_opts: List[_Text]
_short_opts: List[_Text]
action: _Text
dest: Optional[_Text]
dest: _Text | None
default: Any
nargs: int
type: Any
callback: Optional[Callable[..., Any]]
callback_args: Optional[Tuple[Any, ...]]
callback_kwargs: Optional[Dict[_Text, Any]]
help: Optional[_Text]
metavar: Optional[_Text]
def __init__(self, *opts: Optional[_Text], **attrs: Any) -> None: ...
callback: Callable[..., Any] | None
callback_args: Tuple[Any, ...] | None
callback_kwargs: Dict[_Text, Any] | None
help: _Text | None
metavar: _Text | None
def __init__(self, *opts: _Text | None, **attrs: Any) -> None: ...
def _check_action(self) -> None: ...
def _check_callback(self) -> None: ...
def _check_choice(self) -> None: ...
def _check_const(self) -> None: ...
def _check_dest(self) -> None: ...
def _check_nargs(self) -> None: ...
def _check_opt_strings(self, opts: Iterable[Optional[_Text]]) -> List[_Text]: ...
def _check_opt_strings(self, opts: Iterable[_Text | None]) -> List[_Text]: ...
def _check_type(self) -> None: ...
def _set_attrs(self, attrs: Dict[_Text, Any]) -> None: ...
def _set_opt_strings(self, opts: Iterable[_Text]) -> None: ...
@@ -131,14 +131,14 @@ class OptionContainer:
@overload
def add_option(self, opt: Option) -> Option: ...
@overload
def add_option(self, *args: Optional[_Text], **kwargs: Any) -> Any: ...
def add_option(self, *args: _Text | None, **kwargs: Any) -> Any: ...
def add_options(self, option_list: Iterable[Option]) -> None: ...
def destroy(self) -> None: ...
def format_description(self, formatter: Optional[HelpFormatter]) -> Any: ...
def format_help(self, formatter: Optional[HelpFormatter]) -> _Text: ...
def format_option_help(self, formatter: Optional[HelpFormatter]) -> _Text: ...
def format_description(self, formatter: HelpFormatter | None) -> Any: ...
def format_help(self, formatter: HelpFormatter | None) -> _Text: ...
def format_option_help(self, formatter: HelpFormatter | None) -> _Text: ...
def get_description(self) -> Any: ...
def get_option(self, opt_str: _Text) -> Optional[Option]: ...
def get_option(self, opt_str: _Text) -> Option | None: ...
def has_option(self, opt_str: _Text) -> bool: ...
def remove_option(self, opt_str: _Text) -> None: ...
def set_conflict_handler(self, handler: Any) -> None: ...
@@ -148,12 +148,12 @@ class OptionGroup(OptionContainer):
option_list: List[Option]
parser: OptionParser
title: _Text
def __init__(self, parser: OptionParser, title: _Text, description: Optional[_Text] = ...) -> None: ...
def __init__(self, parser: OptionParser, title: _Text, description: _Text | None = ...) -> None: ...
def _create_option_list(self) -> None: ...
def set_title(self, title: _Text) -> None: ...
class Values:
def __init__(self, defaults: Optional[Mapping[str, Any]] = ...) -> None: ...
def __init__(self, defaults: Mapping[str, Any] | None = ...) -> None: ...
def _update(self, dict: Mapping[_Text, Any], mode: Any) -> None: ...
def _update_careful(self, dict: Mapping[_Text, Any]) -> None: ...
def _update_loose(self, dict: Mapping[_Text, Any]) -> None: ...
@@ -165,30 +165,30 @@ class Values:
class OptionParser(OptionContainer):
allow_interspersed_args: bool
epilog: Optional[_Text]
epilog: _Text | None
formatter: HelpFormatter
largs: Optional[List[_Text]]
largs: List[_Text] | None
option_groups: List[OptionGroup]
option_list: List[Option]
process_default_values: Any
prog: Optional[_Text]
rargs: Optional[List[Any]]
prog: _Text | None
rargs: List[Any] | None
standard_option_list: List[Option]
usage: Optional[_Text]
values: Optional[Values]
usage: _Text | None
values: Values | None
version: _Text
def __init__(
self,
usage: Optional[_Text] = ...,
option_list: Optional[Iterable[Option]] = ...,
usage: _Text | None = ...,
option_list: Iterable[Option] | None = ...,
option_class: Type[Option] = ...,
version: Optional[_Text] = ...,
version: _Text | None = ...,
conflict_handler: _Text = ...,
description: Optional[_Text] = ...,
formatter: Optional[HelpFormatter] = ...,
description: _Text | None = ...,
formatter: HelpFormatter | None = ...,
add_help_option: bool = ...,
prog: Optional[_Text] = ...,
epilog: Optional[_Text] = ...,
prog: _Text | None = ...,
epilog: _Text | None = ...,
) -> None: ...
def _add_help_option(self) -> None: ...
def _add_version_option(self) -> None: ...
@@ -209,22 +209,20 @@ class OptionParser(OptionContainer):
def disable_interspersed_args(self) -> None: ...
def enable_interspersed_args(self) -> None: ...
def error(self, msg: _Text) -> None: ...
def exit(self, status: int = ..., msg: Optional[str] = ...) -> None: ...
def expand_prog_name(self, s: Optional[_Text]) -> Any: ...
def exit(self, status: int = ..., msg: str | None = ...) -> None: ...
def expand_prog_name(self, s: _Text | None) -> Any: ...
def format_epilog(self, formatter: HelpFormatter) -> Any: ...
def format_help(self, formatter: Optional[HelpFormatter] = ...) -> _Text: ...
def format_option_help(self, formatter: Optional[HelpFormatter] = ...) -> _Text: ...
def format_help(self, formatter: HelpFormatter | None = ...) -> _Text: ...
def format_option_help(self, formatter: HelpFormatter | None = ...) -> _Text: ...
def get_default_values(self) -> Values: ...
def get_option_group(self, opt_str: _Text) -> Any: ...
def get_prog_name(self) -> _Text: ...
def get_usage(self) -> _Text: ...
def get_version(self) -> _Text: ...
def parse_args(
self, args: Optional[Sequence[AnyStr]] = ..., values: Optional[Values] = ...
) -> Tuple[Values, List[AnyStr]]: ...
def print_usage(self, file: Optional[IO[str]] = ...) -> None: ...
def print_help(self, file: Optional[IO[str]] = ...) -> None: ...
def print_version(self, file: Optional[IO[str]] = ...) -> None: ...
def parse_args(self, args: Sequence[AnyStr] | None = ..., values: Values | None = ...) -> Tuple[Values, List[AnyStr]]: ...
def print_usage(self, file: IO[str] | None = ...) -> None: ...
def print_help(self, file: IO[str] | None = ...) -> None: ...
def print_version(self, file: IO[str] | None = ...) -> None: ...
def set_default(self, dest: Any, value: Any) -> None: ...
def set_defaults(self, **kwargs: Any) -> None: ...
def set_process_default_values(self, process: Any) -> None: ...