mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 05:24:52 +08:00
clean python 3 specific stuff from stdlib/@python2 stubs (#5451)
This commit is contained in:
@@ -24,10 +24,7 @@ _T = TypeVar("_T")
|
||||
_ActionT = TypeVar("_ActionT", bound=Action)
|
||||
_N = TypeVar("_N")
|
||||
|
||||
if sys.version_info >= (3,):
|
||||
_Text = str
|
||||
else:
|
||||
_Text = Union[str, unicode]
|
||||
_Text = Union[str, unicode]
|
||||
|
||||
ONE_OR_MORE: str
|
||||
OPTIONAL: str
|
||||
@@ -109,62 +106,24 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
|
||||
fromfile_prefix_chars: Optional[_Text]
|
||||
add_help: bool
|
||||
|
||||
if sys.version_info >= (3, 5):
|
||||
allow_abbrev: bool
|
||||
|
||||
# undocumented
|
||||
_positionals: _ArgumentGroup
|
||||
_optionals: _ArgumentGroup
|
||||
_subparsers: Optional[_ArgumentGroup]
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
def __init__(
|
||||
self,
|
||||
prog: Optional[str] = ...,
|
||||
usage: Optional[str] = ...,
|
||||
description: Optional[str] = ...,
|
||||
epilog: Optional[str] = ...,
|
||||
parents: Sequence[ArgumentParser] = ...,
|
||||
formatter_class: _FormatterClass = ...,
|
||||
prefix_chars: str = ...,
|
||||
fromfile_prefix_chars: Optional[str] = ...,
|
||||
argument_default: Any = ...,
|
||||
conflict_handler: str = ...,
|
||||
add_help: bool = ...,
|
||||
allow_abbrev: bool = ...,
|
||||
exit_on_error: bool = ...,
|
||||
) -> None: ...
|
||||
elif sys.version_info >= (3, 5):
|
||||
def __init__(
|
||||
self,
|
||||
prog: Optional[str] = ...,
|
||||
usage: Optional[str] = ...,
|
||||
description: Optional[str] = ...,
|
||||
epilog: Optional[str] = ...,
|
||||
parents: Sequence[ArgumentParser] = ...,
|
||||
formatter_class: _FormatterClass = ...,
|
||||
prefix_chars: str = ...,
|
||||
fromfile_prefix_chars: Optional[str] = ...,
|
||||
argument_default: Any = ...,
|
||||
conflict_handler: str = ...,
|
||||
add_help: bool = ...,
|
||||
allow_abbrev: bool = ...,
|
||||
) -> None: ...
|
||||
else:
|
||||
def __init__(
|
||||
self,
|
||||
prog: Optional[Text] = ...,
|
||||
usage: Optional[Text] = ...,
|
||||
description: Optional[Text] = ...,
|
||||
epilog: Optional[Text] = ...,
|
||||
parents: Sequence[ArgumentParser] = ...,
|
||||
formatter_class: _FormatterClass = ...,
|
||||
prefix_chars: Text = ...,
|
||||
fromfile_prefix_chars: Optional[Text] = ...,
|
||||
argument_default: Any = ...,
|
||||
conflict_handler: Text = ...,
|
||||
add_help: bool = ...,
|
||||
) -> None: ...
|
||||
def __init__(
|
||||
self,
|
||||
prog: Optional[Text] = ...,
|
||||
usage: Optional[Text] = ...,
|
||||
description: Optional[Text] = ...,
|
||||
epilog: Optional[Text] = ...,
|
||||
parents: Sequence[ArgumentParser] = ...,
|
||||
formatter_class: _FormatterClass = ...,
|
||||
prefix_chars: Text = ...,
|
||||
fromfile_prefix_chars: Optional[Text] = ...,
|
||||
argument_default: Any = ...,
|
||||
conflict_handler: Text = ...,
|
||||
add_help: bool = ...,
|
||||
) -> None: ...
|
||||
# The type-ignores in these overloads should be temporary. See:
|
||||
# https://github.com/python/typeshed/pull/2643#issuecomment-442280277
|
||||
@overload
|
||||
@@ -177,35 +136,19 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
|
||||
def parse_args(self, *, namespace: None) -> Namespace: ... # type: ignore
|
||||
@overload
|
||||
def parse_args(self, *, namespace: _N) -> _N: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
def add_subparsers(
|
||||
self,
|
||||
*,
|
||||
title: str = ...,
|
||||
description: Optional[str] = ...,
|
||||
prog: str = ...,
|
||||
parser_class: Type[ArgumentParser] = ...,
|
||||
action: Type[Action] = ...,
|
||||
option_string: str = ...,
|
||||
dest: Optional[str] = ...,
|
||||
required: bool = ...,
|
||||
help: Optional[str] = ...,
|
||||
metavar: Optional[str] = ...,
|
||||
) -> _SubParsersAction: ...
|
||||
else:
|
||||
def add_subparsers(
|
||||
self,
|
||||
*,
|
||||
title: Text = ...,
|
||||
description: Optional[Text] = ...,
|
||||
prog: Text = ...,
|
||||
parser_class: Type[ArgumentParser] = ...,
|
||||
action: Type[Action] = ...,
|
||||
option_string: Text = ...,
|
||||
dest: Optional[Text] = ...,
|
||||
help: Optional[Text] = ...,
|
||||
metavar: Optional[Text] = ...,
|
||||
) -> _SubParsersAction: ...
|
||||
def add_subparsers(
|
||||
self,
|
||||
*,
|
||||
title: Text = ...,
|
||||
description: Optional[Text] = ...,
|
||||
prog: Text = ...,
|
||||
parser_class: Type[ArgumentParser] = ...,
|
||||
action: Type[Action] = ...,
|
||||
option_string: Text = ...,
|
||||
dest: Optional[Text] = ...,
|
||||
help: Optional[Text] = ...,
|
||||
metavar: Optional[Text] = ...,
|
||||
) -> _SubParsersAction: ...
|
||||
def print_usage(self, file: Optional[IO[str]] = ...) -> None: ...
|
||||
def print_help(self, file: Optional[IO[str]] = ...) -> None: ...
|
||||
def format_usage(self) -> str: ...
|
||||
@@ -216,13 +159,6 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
|
||||
def convert_arg_line_to_args(self, arg_line: Text) -> List[str]: ...
|
||||
def exit(self, status: int = ..., message: Optional[Text] = ...) -> NoReturn: ...
|
||||
def error(self, message: Text) -> NoReturn: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
def parse_intermixed_args(
|
||||
self, args: Optional[Sequence[str]] = ..., namespace: Optional[Namespace] = ...
|
||||
) -> Namespace: ...
|
||||
def parse_known_intermixed_args(
|
||||
self, args: Optional[Sequence[str]] = ..., namespace: Optional[Namespace] = ...
|
||||
) -> Tuple[Namespace, List[str]]: ...
|
||||
# undocumented
|
||||
def _get_optional_actions(self) -> List[Action]: ...
|
||||
def _get_positional_actions(self) -> List[Action]: ...
|
||||
@@ -290,9 +226,6 @@ class RawDescriptionHelpFormatter(HelpFormatter): ...
|
||||
class RawTextHelpFormatter(RawDescriptionHelpFormatter): ...
|
||||
class ArgumentDefaultsHelpFormatter(HelpFormatter): ...
|
||||
|
||||
if sys.version_info >= (3,):
|
||||
class MetavarTypeHelpFormatter(HelpFormatter): ...
|
||||
|
||||
class Action(_AttributeHolder):
|
||||
option_strings: Sequence[_Text]
|
||||
dest: _Text
|
||||
@@ -324,22 +257,6 @@ class Action(_AttributeHolder):
|
||||
values: Union[Text, Sequence[Any], None],
|
||||
option_string: Optional[Text] = ...,
|
||||
) -> None: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def format_usage(self) -> str: ...
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
class BooleanOptionalAction(Action):
|
||||
def __init__(
|
||||
self,
|
||||
option_strings: Sequence[str],
|
||||
dest: str,
|
||||
default: Union[_T, str, None] = ...,
|
||||
type: Optional[Union[Callable[[Text], _T], Callable[[str], _T], FileType]] = ...,
|
||||
choices: Optional[Iterable[_T]] = ...,
|
||||
required: bool = ...,
|
||||
help: Optional[Text] = ...,
|
||||
metavar: Optional[Union[Text, Tuple[Text, ...]]] = ...,
|
||||
) -> None: ...
|
||||
|
||||
class Namespace(_AttributeHolder):
|
||||
def __init__(self, **kwargs: Any) -> None: ...
|
||||
@@ -351,14 +268,7 @@ class FileType:
|
||||
# undocumented
|
||||
_mode: _Text
|
||||
_bufsize: int
|
||||
if sys.version_info >= (3,):
|
||||
_encoding: Optional[str]
|
||||
_errors: Optional[str]
|
||||
def __init__(
|
||||
self, mode: str = ..., bufsize: int = ..., encoding: Optional[str] = ..., errors: Optional[str] = ...
|
||||
) -> None: ...
|
||||
else:
|
||||
def __init__(self, mode: Text = ..., bufsize: Optional[int] = ...) -> None: ...
|
||||
def __init__(self, mode: Text = ..., bufsize: Optional[int] = ...) -> None: ...
|
||||
def __call__(self, string: Text) -> IO[Any]: ...
|
||||
|
||||
# undocumented
|
||||
@@ -451,27 +361,15 @@ class _SubParsersAction(Action):
|
||||
_name_parser_map: Dict[_Text, ArgumentParser]
|
||||
choices: Dict[_Text, ArgumentParser]
|
||||
_choices_actions: List[Action]
|
||||
if sys.version_info >= (3, 7):
|
||||
def __init__(
|
||||
self,
|
||||
option_strings: Sequence[Text],
|
||||
prog: Text,
|
||||
parser_class: Type[ArgumentParser],
|
||||
dest: Text = ...,
|
||||
required: bool = ...,
|
||||
help: Optional[Text] = ...,
|
||||
metavar: Optional[Union[Text, Tuple[Text, ...]]] = ...,
|
||||
) -> None: ...
|
||||
else:
|
||||
def __init__(
|
||||
self,
|
||||
option_strings: Sequence[Text],
|
||||
prog: Text,
|
||||
parser_class: Type[ArgumentParser],
|
||||
dest: Text = ...,
|
||||
help: Optional[Text] = ...,
|
||||
metavar: Optional[Union[Text, Tuple[Text, ...]]] = ...,
|
||||
) -> None: ...
|
||||
def __init__(
|
||||
self,
|
||||
option_strings: Sequence[Text],
|
||||
prog: Text,
|
||||
parser_class: Type[ArgumentParser],
|
||||
dest: Text = ...,
|
||||
help: Optional[Text] = ...,
|
||||
metavar: Optional[Union[Text, Tuple[Text, ...]]] = ...,
|
||||
) -> None: ...
|
||||
# TODO: Type keyword args properly.
|
||||
def add_parser(self, name: Text, **kwargs: Any) -> ArgumentParser: ...
|
||||
def _get_subactions(self) -> List[Action]: ...
|
||||
@@ -479,9 +377,8 @@ class _SubParsersAction(Action):
|
||||
# undocumented
|
||||
class ArgumentTypeError(Exception): ...
|
||||
|
||||
if sys.version_info < (3, 7):
|
||||
# undocumented
|
||||
def _ensure_value(namespace: Namespace, name: Text, value: Any) -> Any: ...
|
||||
# undocumented
|
||||
def _ensure_value(namespace: Namespace, name: Text, value: Any) -> Any: ...
|
||||
|
||||
# undocumented
|
||||
def _get_action_name(argument: Optional[Action]) -> Optional[str]: ...
|
||||
|
||||
Reference in New Issue
Block a user