mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-20 19:01:15 +08:00
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:
committed by
David Fisher
parent
63cbe2dc3c
commit
b63e09c239
@@ -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): ...
|
||||
|
||||
14
third_party/2.7/dateutil/parser.pyi
vendored
14
third_party/2.7/dateutil/parser.pyi
vendored
@@ -27,13 +27,13 @@ class parserinfo(object):
|
||||
def validate(self, res: datetime) -> bool: ...
|
||||
|
||||
class parser(object):
|
||||
def __init__(self, info: Optional['parserinfo']) -> None: ...
|
||||
def __init__(self, info: parserinfo = None) -> None: ...
|
||||
def parse(self, timestr: Union[str, unicode, IO[unicode]],
|
||||
default: Optional[datetime],
|
||||
ignoretz: bool, tzinfos: Dict[Union[str, unicode], tzinfo],
|
||||
**kwargs: Dict[str, Any]) -> datetime: ...
|
||||
default: datetime = None,
|
||||
ignoretz: bool = ..., tzinfos: Dict[Union[str, unicode], tzinfo] = None,
|
||||
**kwargs: Any) -> datetime: ...
|
||||
|
||||
DEFAULTPARSER = ... # type: 'parser'
|
||||
DEFAULTPARSER = ... # type: parser
|
||||
def parse(timestr: Union[str, unicode, IO[unicode]],
|
||||
parserinfo: Optional['parserinfo'],
|
||||
**kwargs: Dict[str, Any]) -> datetime: ...
|
||||
parserinfo: parserinfo = None,
|
||||
**kwargs: Any) -> datetime: ...
|
||||
|
||||
Reference in New Issue
Block a user