Akuli and srittau: Remove Python 2 branches from Python 3 stubs (#5461)

* run script and do some manual changes (Akuli)

* do the whole thing manually (srittau)

* merge changes (Akuli)

Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
This commit is contained in:
Akuli
2021-05-15 15:33:39 +03:00
committed by GitHub
parent b0ef85288d
commit 17dcea4a68
106 changed files with 1539 additions and 3275 deletions

View File

@@ -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 = str
ONE_OR_MORE: str
OPTIONAL: str
@@ -108,9 +105,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
formatter_class: _FormatterClass
fromfile_prefix_chars: Optional[_Text]
add_help: bool
if sys.version_info >= (3, 5):
allow_abbrev: bool
allow_abbrev: bool
# undocumented
_positionals: _ArgumentGroup
@@ -134,7 +129,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
allow_abbrev: bool = ...,
exit_on_error: bool = ...,
) -> None: ...
elif sys.version_info >= (3, 5):
else:
def __init__(
self,
prog: Optional[str] = ...,
@@ -150,21 +145,6 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
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: ...
# The type-ignores in these overloads should be temporary. See:
# https://github.com/python/typeshed/pull/2643#issuecomment-442280277
@overload
@@ -289,9 +269,7 @@ class HelpFormatter:
class RawDescriptionHelpFormatter(HelpFormatter): ...
class RawTextHelpFormatter(RawDescriptionHelpFormatter): ...
class ArgumentDefaultsHelpFormatter(HelpFormatter): ...
if sys.version_info >= (3,):
class MetavarTypeHelpFormatter(HelpFormatter): ...
class MetavarTypeHelpFormatter(HelpFormatter): ...
class Action(_AttributeHolder):
option_strings: Sequence[_Text]
@@ -351,14 +329,11 @@ 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: ...
_encoding: Optional[str]
_errors: Optional[str]
def __init__(
self, mode: str = ..., bufsize: int = ..., encoding: Optional[str] = ..., errors: Optional[str] = ...
) -> None: ...
def __call__(self, string: Text) -> IO[Any]: ...
# undocumented