Fix some issues for dateutil and argparse (#357)

* Fix stubs for 2.7/dateutil. They were pretty broken.

(The 3/dateutil share some of the brokenness but that's still a TODO.)

* Fix argparse stubs.

- Container is not strong enough for choices.
- add_subparsers() returns something with an add_parser() method.
This commit is contained in:
Guido van Rossum
2016-07-12 16:24:33 -07:00
committed by David Fisher
parent 63cbe2dc3c
commit b63e09c239
2 changed files with 16 additions and 12 deletions

View File

@@ -1,7 +1,7 @@
# Stubs for argparse (Python 3.4)
from typing import (
Any, Callable, Container, List, IO, Optional, Sequence, Tuple, Type, Union,
Any, Callable, Iterable, List, IO, Optional, Sequence, Tuple, Type, Union,
TypeVar, overload
)
import sys
@@ -53,7 +53,7 @@ class ArgumentParser:
const: Any = ...,
default: Any = ...,
type: Callable[[str], _T] = ...,
choices: Container[_T] = ...,
choices: Iterable[_T] = ...,
required: bool = ...,
help: str = ...,
metavar: Union[str, Tuple[str, ...]] = ...,
@@ -69,7 +69,7 @@ class ArgumentParser:
option_string: str = ...,
dest: Optional[str] = ...,
help: Optional[str] = ...,
metavar: Optional[str] = ...) -> None: ...
metavar: Optional[str] = ...) -> _SubParsersAction: ...
def add_argument_group(self, title: Optional[str] = ...,
description: Optional[str] = ...) -> _ArgumentGroup: ...
@overload
@@ -108,7 +108,7 @@ class Action:
const: Any = ...,
default: Any = ...,
type: Optional[Callable[[str], _T]] = ...,
choices: Optional[Container[_T]] = ...,
choices: Optional[Iterable[_T]] = ...,
required: bool = ...,
help: Optional[str] = ...,
metavar: Union[str, Tuple[str, ...]] = ...) -> None: ...
@@ -139,7 +139,7 @@ class _ArgumentGroup:
const: Any = ...,
default: Any = ...,
type: Callable[[str], _T] = ...,
choices: Container[_T] = ...,
choices: Iterable[_T] = ...,
required: bool = ...,
help: str = ...,
metavar: Union[str, Tuple[str, ...]] = ...,
@@ -148,5 +148,9 @@ class _ArgumentGroup:
class _MutuallyExclusiveGroup(_ArgumentGroup): ...
class _SubParsersAction:
# TODO: Type keyword args properly.
def add_parser(self, name: str, **kwargs: Any) -> ArgumentParser: ...
# not documented
class ArgumentTypeError(Exception): ...