From 04c8e3f96d56bc7693aafb7c2f6e246b296edd85 Mon Sep 17 00:00:00 2001 From: Semyon Proshev Date: Mon, 16 Apr 2018 19:39:04 +0300 Subject: [PATCH] Sync with typeshed @ a5429d25dc326b69116f958dcb0a43c6f82dadce --- python/helpers/typeshed/stdlib/2/UserDict.pyi | 2 + .../helpers/typeshed/stdlib/2/__builtin__.pyi | 1 - .../typeshed/stdlib/2/email/parser.pyi | 2 + .../helpers/typeshed/stdlib/2/itertools.pyi | 2 +- .../typeshed/stdlib/2/sqlite3/dbapi2.pyi | 254 -------------- python/helpers/typeshed/stdlib/2/unittest.pyi | 6 +- .../typeshed/stdlib/2and3/argparse.pyi | 314 ++++++++++++++---- python/helpers/typeshed/stdlib/2and3/code.pyi | 19 +- .../stdlib/2and3/distutils/errors.pyi | 23 +- .../helpers/typeshed/stdlib/2and3/ftplib.pyi | 4 +- python/helpers/typeshed/stdlib/2and3/pdb.pyi | 37 +-- .../helpers/typeshed/stdlib/2and3/pkgutil.pyi | 8 +- .../typeshed/stdlib/2and3/plistlib.pyi | 2 +- .../helpers/typeshed/stdlib/2and3/sched.pyi | 6 +- .../stdlib/{2 => 2and3}/sqlite3/__init__.pyi | 0 .../stdlib/{3 => 2and3}/sqlite3/dbapi2.pyi | 63 ++-- .../helpers/typeshed/stdlib/2and3/struct.pyi | 5 +- .../helpers/typeshed/stdlib/2and3/tarfile.pyi | 6 +- python/helpers/typeshed/stdlib/2and3/time.pyi | 7 + .../typeshed/stdlib/2and3/traceback.pyi | 8 +- python/helpers/typeshed/stdlib/2and3/uu.pyi | 7 +- .../helpers/typeshed/stdlib/2and3/zipfile.pyi | 2 +- .../typeshed/stdlib/3.4/asyncio/streams.pyi | 8 +- .../helpers/typeshed/stdlib/3.4/pathlib.pyi | 5 + python/helpers/typeshed/stdlib/3.5/zipapp.pyi | 9 +- python/helpers/typeshed/stdlib/3/_ast.pyi | 10 +- .../stdlib/3/collections/__init__.pyi | 5 +- .../helpers/typeshed/stdlib/3/http/client.pyi | 6 +- python/helpers/typeshed/stdlib/3/io.pyi | 12 +- .../helpers/typeshed/stdlib/3/itertools.pyi | 4 +- .../stdlib/3/multiprocessing/__init__.pyi | 3 + .../stdlib/3/multiprocessing/managers.pyi | 4 +- .../helpers/typeshed/stdlib/3/os/__init__.pyi | 43 ++- .../helpers/typeshed/stdlib/3/posixpath.pyi | 5 +- .../typeshed/stdlib/3/socketserver.pyi | 6 +- .../typeshed/stdlib/3/sqlite3/__init__.pyi | 1 - python/helpers/typeshed/stdlib/3/ssl.pyi | 5 +- .../helpers/typeshed/stdlib/3/subprocess.pyi | 32 +- python/helpers/typeshed/stdlib/3/sys.pyi | 4 + .../helpers/typeshed/stdlib/3/tkinter/ttk.pyi | 6 + python/helpers/typeshed/stdlib/3/types.pyi | 3 + .../typeshed/stdlib/3/unittest/__init__.pyi | 6 +- .../typeshed/stdlib/3/unittest/mock.pyi | 3 + python/helpers/typeshed/tests/mypy_test.py | 1 + .../helpers/typeshed/third_party/2/enum.pyi | 2 +- .../helpers/typeshed/third_party/2/gflags.pyi | 4 +- .../third_party/2/six/moves/__init__.pyi | 4 +- .../third_party/2and3/boto/compat.pyi | 9 +- .../third_party/2and3/requests/structures.pyi | 14 +- .../third_party/2and3/yaml/__init__.pyi | 10 +- .../typeshed/third_party/3/itsdangerous.pyi | 4 +- .../third_party/3/six/moves/__init__.pyi | 2 +- 52 files changed, 557 insertions(+), 451 deletions(-) delete mode 100644 python/helpers/typeshed/stdlib/2/sqlite3/dbapi2.pyi rename python/helpers/typeshed/stdlib/{2 => 2and3}/sqlite3/__init__.pyi (100%) rename python/helpers/typeshed/stdlib/{3 => 2and3}/sqlite3/dbapi2.pyi (83%) delete mode 100644 python/helpers/typeshed/stdlib/3/sqlite3/__init__.pyi diff --git a/python/helpers/typeshed/stdlib/2/UserDict.pyi b/python/helpers/typeshed/stdlib/2/UserDict.pyi index 885a62abf73f..33ebd1a51528 100644 --- a/python/helpers/typeshed/stdlib/2/UserDict.pyi +++ b/python/helpers/typeshed/stdlib/2/UserDict.pyi @@ -17,6 +17,8 @@ class IterableUserDict(UserDict[_KT, _VT], Generic[_KT, _VT]): class DictMixin(Iterable[_KT], Container[_KT], Sized, Generic[_KT, _VT]): def has_key(self, key: _KT) -> bool: ... + def __len__(self) -> int: ... + def __iter__(self) -> Iterator[_KT]: ... # From typing.Mapping[_KT, _VT] # (can't inherit because of keys()) diff --git a/python/helpers/typeshed/stdlib/2/__builtin__.pyi b/python/helpers/typeshed/stdlib/2/__builtin__.pyi index aa4953e887dd..30c5b124dca5 100644 --- a/python/helpers/typeshed/stdlib/2/__builtin__.pyi +++ b/python/helpers/typeshed/stdlib/2/__builtin__.pyi @@ -1027,7 +1027,6 @@ class PendingDeprecationWarning(Warning): ... class ImportWarning(Warning): ... class UnicodeWarning(Warning): ... class BytesWarning(Warning): ... -class ResourceWarning(Warning): ... def eval(s: Union[str, unicode], globals: Dict[str, Any] = ..., locals: Dict[str, Any] = ...) -> Any: ... def exec(object: str, diff --git a/python/helpers/typeshed/stdlib/2/email/parser.pyi b/python/helpers/typeshed/stdlib/2/email/parser.pyi index 5c80f1a538ac..4f2282834ca5 100644 --- a/python/helpers/typeshed/stdlib/2/email/parser.pyi +++ b/python/helpers/typeshed/stdlib/2/email/parser.pyi @@ -1,3 +1,5 @@ +from .feedparser import FeedParser as FeedParser # not in __all__ but listed in documentation + class Parser: def __init__(self, *args, **kws) -> None: ... def parse(self, fp, headersonly: bool = ...): ... diff --git a/python/helpers/typeshed/stdlib/2/itertools.pyi b/python/helpers/typeshed/stdlib/2/itertools.pyi index 6038a67e8ff5..487a6e5d613c 100644 --- a/python/helpers/typeshed/stdlib/2/itertools.pyi +++ b/python/helpers/typeshed/stdlib/2/itertools.pyi @@ -38,7 +38,7 @@ def groupby(iterable: Iterable[_T], key: Callable[[_T], _S]) -> Iterator[Tuple[_S, Iterator[_T]]]: ... @overload -def islice(iterable: Iterable[_T], stop: int) -> Iterator[_T]: ... +def islice(iterable: Iterable[_T], stop: Optional[int]) -> Iterator[_T]: ... @overload def islice(iterable: Iterable[_T], start: Optional[int], stop: Optional[int], step: int = ...) -> Iterator[_T]: ... diff --git a/python/helpers/typeshed/stdlib/2/sqlite3/dbapi2.pyi b/python/helpers/typeshed/stdlib/2/sqlite3/dbapi2.pyi deleted file mode 100644 index 8d55e04a664f..000000000000 --- a/python/helpers/typeshed/stdlib/2/sqlite3/dbapi2.pyi +++ /dev/null @@ -1,254 +0,0 @@ -# Filip Hron -# based heavily on Andrey Vlasovskikh's python-skeletons https://github.com/JetBrains/python-skeletons/blob/master/sqlite3.py - -from typing import Any, Union, List, Iterator, Optional -from datetime import time, datetime -from collections import Iterable - -paramstyle = ... # type: str -threadsafety = ... # type: int -apilevel = ... # type: str -Date = ... # type: datetime -Time = ... # type: time -Timestamp = ... # type: datetime - -def DateFromTicks(ticks): ... -def TimeFromTicks(ticks): ... -def TimestampFromTicks(ticks): ... - -version_info = ... # type: Any -sqlite_version_info = ... # type: Any -Binary = ... # type: Any - -def register_adapters_and_converters(): ... - -# The remaining definitions are imported from _sqlite3. - -PARSE_COLNAMES = ... # type: int -PARSE_DECLTYPES = ... # type: int -SQLITE_ALTER_TABLE = ... # type: int -SQLITE_ANALYZE = ... # type: int -SQLITE_ATTACH = ... # type: int -SQLITE_CREATE_INDEX = ... # type: int -SQLITE_CREATE_TABLE = ... # type: int -SQLITE_CREATE_TEMP_INDEX = ... # type: int -SQLITE_CREATE_TEMP_TABLE = ... # type: int -SQLITE_CREATE_TEMP_TRIGGER = ... # type: int -SQLITE_CREATE_TEMP_VIEW = ... # type: int -SQLITE_CREATE_TRIGGER = ... # type: int -SQLITE_CREATE_VIEW = ... # type: int -SQLITE_DELETE = ... # type: int -SQLITE_DENY = ... # type: int -SQLITE_DETACH = ... # type: int -SQLITE_DROP_INDEX = ... # type: int -SQLITE_DROP_TABLE = ... # type: int -SQLITE_DROP_TEMP_INDEX = ... # type: int -SQLITE_DROP_TEMP_TABLE = ... # type: int -SQLITE_DROP_TEMP_TRIGGER = ... # type: int -SQLITE_DROP_TEMP_VIEW = ... # type: int -SQLITE_DROP_TRIGGER = ... # type: int -SQLITE_DROP_VIEW = ... # type: int -SQLITE_IGNORE = ... # type: int -SQLITE_INSERT = ... # type: int -SQLITE_OK = ... # type: int -SQLITE_PRAGMA = ... # type: int -SQLITE_READ = ... # type: int -SQLITE_REINDEX = ... # type: int -SQLITE_SELECT = ... # type: int -SQLITE_TRANSACTION = ... # type: int -SQLITE_UPDATE = ... # type: int -adapters = ... # type: Any -converters = ... # type: Any -sqlite_version = ... # type: str -version = ... # type: str - -# TODO: adapt needs to get probed -def adapt(obj, protocol, alternate): ... -def complete_statement(sql: str) -> bool: ... -def connect(database: Union[bytes, unicode], - timeout: float = ..., - detect_types: int = ..., - isolation_level: Union[str, None] = ..., - check_same_thread: bool = ..., - factory: Union[Connection, None] = ..., - cached_statements: int = ...) -> Connection: ... -def enable_callback_tracebacks(flag: bool) -> None: ... -def enable_shared_cache(do_enable: int) -> None: ... -def register_adapter(type: type, callable: Any) -> None: ... -# TODO: sqlite3.register_converter.__doc__ specifies callable as unknown -def register_converter(typename: str, callable: bytes) -> None: ... - -class Cache(object): - def __init__(self, *args, **kwargs) -> None: ... - def display(self, *args, **kwargs) -> None: ... - def get(self, *args, **kwargs) -> None: ... - -class Connection(object): - DataError = ... # type: Any - DatabaseError = ... # type: Any - Error = ... # type: Any - IntegrityError = ... # type: Any - InterfaceError = ... # type: Any - InternalError = ... # type: Any - NotSupportedError = ... # type: Any - OperationalError = ... # type: Any - ProgrammingError = ... # type: Any - Warning = ... # type: Any - in_transaction = ... # type: Any - isolation_level = ... # type: Any - row_factory = ... # type: Any - text_factory = ... # type: Any - total_changes = ... # type: Any - def __init__(self, *args, **kwargs): ... - def close(self) -> None: ... - def commit(self) -> None: ... - def create_aggregate(self, name: str, num_params: int, aggregate_class: type) -> None: ... - def create_collation(self, name: str, callable: Any) -> None: ... - def create_function(self, name: str, num_params: int, func: Any) -> None: ... - def cursor(self, cursorClass=...) -> Cursor: ... - def execute(self, sql: str, parameters: Iterable = ...) -> Cursor: ... - # TODO: please check in executemany() if seq_of_parameters type is possible like this - def executemany(self, sql: str, seq_of_parameters: Iterable[Iterable]) -> Cursor: ... - def executescript(self, sql_script: Union[bytes, unicode]) -> Cursor: ... - def interrupt(self, *args, **kwargs) -> None: ... - def iterdump(self, *args, **kwargs) -> None: ... - def rollback(self, *args, **kwargs) -> None: ... - # TODO: set_authorizer(authorzer_callback) - # see https://docs.python.org/2/library/sqlite3.html#sqlite3.Connection.set_authorizer - # returns [SQLITE_OK, SQLITE_DENY, SQLITE_IGNORE] so perhaps int - def set_authorizer(self, *args, **kwargs) -> None: ... - # set_progress_handler(handler, n) -> see https://docs.python.org/2/library/sqlite3.html#sqlite3.Connection.set_progress_handler - def set_progress_handler(self, *args, **kwargs) -> None: ... - def set_trace_callback(self, *args, **kwargs): ... - def __call__(self, *args, **kwargs): ... - def __enter__(self, *args, **kwargs): ... - def __exit__(self, *args, **kwargs): ... - -class Cursor(Iterator[Any]): - arraysize = ... # type: Any - connection = ... # type: Any - description = ... # type: Any - lastrowid = ... # type: Any - row_factory = ... # type: Any - rowcount = ... # type: Any - # TODO: Cursor class accepts exactly 1 argument - # required type is sqlite3.Connection (which is imported as _Connection) - # however, the name of the __init__ variable is unknown - def __init__(self, *args, **kwargs): ... - def close(self, *args, **kwargs): ... - def execute(self, sql: str, parameters: Iterable = ...) -> Cursor: ... - def executemany(self, sql: str, seq_of_parameters: Iterable[Iterable]): ... - def executescript(self, sql_script: Union[bytes, unicode]) -> Cursor: ... - def fetchall(self) -> List[Any]: ... - def fetchmany(self, size: Optional[int] = ...) -> List[Any]: ... - def fetchone(self) -> Any: ... - def setinputsizes(self, *args, **kwargs): ... - def setoutputsize(self, *args, **kwargs): ... - def __iter__(self) -> Cursor: ... - def __next__(self) -> Any: ... - - -class DataError(DatabaseError): ... - -class DatabaseError(Error): ... - -class Error(Exception): ... - -class IntegrityError(DatabaseError): ... - -class InterfaceError(Error): ... - -class InternalError(DatabaseError): ... - -class NotSupportedError(DatabaseError): ... - -class OperationalError(DatabaseError): ... - -class OptimizedUnicode(object): - maketrans = ... # type: Any - def __init__(self, *args, **kwargs): ... - def capitalize(self, *args, **kwargs): ... - def casefold(self, *args, **kwargs): ... - def center(self, *args, **kwargs): ... - def count(self, *args, **kwargs): ... - def encode(self, *args, **kwargs): ... - def endswith(self, *args, **kwargs): ... - def expandtabs(self, *args, **kwargs): ... - def find(self, *args, **kwargs): ... - def format(self, *args, **kwargs): ... - def format_map(self, *args, **kwargs): ... - def index(self, *args, **kwargs): ... - def isalnum(self, *args, **kwargs): ... - def isalpha(self, *args, **kwargs): ... - def isdecimal(self, *args, **kwargs): ... - def isdigit(self, *args, **kwargs): ... - def isidentifier(self, *args, **kwargs): ... - def islower(self, *args, **kwargs): ... - def isnumeric(self, *args, **kwargs): ... - def isprintable(self, *args, **kwargs): ... - def isspace(self, *args, **kwargs): ... - def istitle(self, *args, **kwargs): ... - def isupper(self, *args, **kwargs): ... - def join(self, *args, **kwargs): ... - def ljust(self, *args, **kwargs): ... - def lower(self, *args, **kwargs): ... - def lstrip(self, *args, **kwargs): ... - def partition(self, *args, **kwargs): ... - def replace(self, *args, **kwargs): ... - def rfind(self, *args, **kwargs): ... - def rindex(self, *args, **kwargs): ... - def rjust(self, *args, **kwargs): ... - def rpartition(self, *args, **kwargs): ... - def rsplit(self, *args, **kwargs): ... - def rstrip(self, *args, **kwargs): ... - def split(self, *args, **kwargs): ... - def splitlines(self, *args, **kwargs): ... - def startswith(self, *args, **kwargs): ... - def strip(self, *args, **kwargs): ... - def swapcase(self, *args, **kwargs): ... - def title(self, *args, **kwargs): ... - def translate(self, *args, **kwargs): ... - def upper(self, *args, **kwargs): ... - def zfill(self, *args, **kwargs): ... - def __add__(self, other): ... - def __contains__(self, *args, **kwargs): ... - def __eq__(self, other): ... - def __format__(self, *args, **kwargs): ... - def __ge__(self, other): ... - def __getitem__(self, index): ... - def __getnewargs__(self, *args, **kwargs): ... - def __gt__(self, other): ... - def __hash__(self): ... - def __iter__(self): ... - def __le__(self, other): ... - def __len__(self, *args, **kwargs): ... - def __lt__(self, other): ... - def __mod__(self, other): ... - def __mul__(self, other): ... - def __ne__(self, other): ... - def __rmod__(self, other): ... - def __rmul__(self, other): ... - -class PrepareProtocol(object): - def __init__(self, *args, **kwargs): ... - -class ProgrammingError(DatabaseError): ... - -class Row(object): - def __init__(self, *args, **kwargs): ... - def keys(self, *args, **kwargs): ... - def __eq__(self, other): ... - def __ge__(self, other): ... - def __getitem__(self, index): ... - def __gt__(self, other): ... - def __hash__(self): ... - def __iter__(self): ... - def __le__(self, other): ... - def __len__(self, *args, **kwargs): ... - def __lt__(self, other): ... - def __ne__(self, other): ... - -class Statement(object): - def __init__(self, *args, **kwargs): ... - -class Warning(Exception): ... diff --git a/python/helpers/typeshed/stdlib/2/unittest.pyi b/python/helpers/typeshed/stdlib/2/unittest.pyi index f79ec5e86843..8e8665034a7f 100644 --- a/python/helpers/typeshed/stdlib/2/unittest.pyi +++ b/python/helpers/typeshed/stdlib/2/unittest.pyi @@ -192,12 +192,12 @@ class TestLoader: suiteClass = ... # type: Callable[[List[TestCase]], TestSuite] def loadTestsFromTestCase(self, testCaseClass: Type[TestCase]) -> TestSuite: ... - def loadTestsFromModule(self, module: str = ..., + def loadTestsFromModule(self, module: types.ModuleType = ..., use_load_tests: bool = ...) -> TestSuite: ... def loadTestsFromName(self, name: str = ..., - module: Optional[str] = ...) -> TestSuite: ... + module: Optional[types.ModuleType] = ...) -> TestSuite: ... def loadTestsFromNames(self, names: List[str] = ..., - module: Optional[str] = ...) -> TestSuite: ... + module: Optional[types.ModuleType] = ...) -> TestSuite: ... def discover(self, start_dir: str, pattern: str = ..., top_level_dir: Optional[str] = ...) -> TestSuite: ... def getTestCaseNames(self, testCaseClass: Type[TestCase] = ...) -> List[str]: ... diff --git a/python/helpers/typeshed/stdlib/2and3/argparse.pyi b/python/helpers/typeshed/stdlib/2and3/argparse.pyi index 9e0df2ee5e1e..4cbf83bc832a 100644 --- a/python/helpers/typeshed/stdlib/2and3/argparse.pyi +++ b/python/helpers/typeshed/stdlib/2and3/argparse.pyi @@ -1,41 +1,97 @@ # Stubs for argparse (Python 2.7 and 3.4) from typing import ( - Any, Callable, Iterable, List, IO, Optional, Sequence, Tuple, Type, Union, - TypeVar, overload + Any, Callable, Dict, Generator, Iterable, List, IO, NoReturn, Optional, + Pattern, Sequence, Tuple, Type, Union, TypeVar, overload ) import sys _T = TypeVar('_T') +_ActionT = TypeVar('_ActionT', bound='Action') if sys.version_info >= (3,): _Text = str else: _Text = Union[str, unicode] -ONE_OR_MORE = ... # type: str -OPTIONAL = ... # type: str -PARSER = ... # type: str -REMAINDER = ... # type: str -SUPPRESS = ... # type: str -ZERO_OR_MORE = ... # type: str +ONE_OR_MORE: str +OPTIONAL: str +PARSER: str +REMAINDER: str +SUPPRESS: str +ZERO_OR_MORE: str +_UNRECOGNIZED_ARGS_ATTR: str # undocumented class ArgumentError(Exception): ... -class ArgumentParser: - prog = ... # type: _Text - usage = ... # type: Optional[_Text] - description = ... # type: Optional[_Text] - epilog = ... # type: Optional[_Text] - formatter_class = ... # type: Type[HelpFormatter] - prefix_chars = ... # type: _Text - fromfile_prefix_chars = ... # type: Optional[_Text] - argument_default = ... # type: Optional[_Text] - conflict_handler = ... # type: _Text - add_help = ... # type: bool +# undocumented +class _AttributeHolder: + def _get_kwargs(self) -> List[Tuple[str, Any]]: ... + def _get_args(self) -> List[Any]: ... + +# undocumented +class _ActionsContainer: + description: Optional[_Text] + prefix_chars: _Text + argument_default: Optional[_Text] + conflict_handler: _Text + + _registries: Dict[_Text, Dict[Any, Any]] + _actions: List[Action] + _option_string_actions: Dict[_Text, Action] + _action_groups: List[_ArgumentGroup] + _mutually_exclusive_groups: List[_MutuallyExclusiveGroup] + _defaults: Dict[str, Any] + _negative_number_matcher: Pattern[str] + _has_negative_number_optionals: List[bool] + + def __init__(self, description: Optional[_Text], prefix_chars: _Text, + argument_default: Optional[_Text], conflict_handler: _Text) -> None: ... + def register(self, registry_name: _Text, value: Any, object: Any) -> None: ... + def _registry_get(self, registry_name: _Text, value: Any, default: Any = ...) -> Any: ... + def set_defaults(self, **kwargs: Any) -> None: ... + def get_default(self, dest: _Text) -> Any: ... + def add_argument(self, + *name_or_flags: _Text, + action: Union[_Text, Type[Action]] = ..., + nargs: Union[int, _Text] = ..., + const: Any = ..., + default: Any = ..., + type: Union[Callable[[str], _T], FileType] = ..., + choices: Iterable[_T] = ..., + required: bool = ..., + help: Optional[_Text] = ..., + metavar: Union[_Text, Tuple[_Text, ...]] = ..., + dest: Optional[_Text] = ..., + version: _Text = ...) -> Action: ... + def add_argument_group(self, *args: Any, **kwargs: Any) -> _ArgumentGroup: ... + def add_mutually_exclusive_group(self, **kwargs: Any) -> _MutuallyExclusiveGroup: ... + def _add_action(self, action: _ActionT) -> _ActionT: ... + def _remove_action(self, action: Action) -> None: ... + def _add_container_actions(self, container: _ActionsContainer) -> None: ... + def _get_positional_kwargs(self, dest: _Text, **kwargs: Any) -> Dict[str, Any]: ... + def _get_optional_kwargs(self, *args: Any, **kwargs: Any) -> Dict[str, Any]: ... + def _pop_action_class(self, kwargs: Any, default: Optional[Type[Action]] = ...) -> Type[Action]: ... + def _get_handler(self) -> Callable[[Action, Iterable[Tuple[_Text, Action]]], Any]: ... + def _check_conflict(self, action: Action) -> None: ... + def _handle_conflict_error(self, action: Action, conflicting_actions: Iterable[Tuple[_Text, Action]]) -> NoReturn: ... + def _handle_conflict_resolve(self, action: Action, conflicting_actions: Iterable[Tuple[_Text, Action]]) -> None: ... + +class ArgumentParser(_AttributeHolder, _ActionsContainer): + prog: _Text + usage: Optional[_Text] + epilog: Optional[_Text] + formatter_class: Type[HelpFormatter] + fromfile_prefix_chars: Optional[_Text] + add_help: bool if sys.version_info >= (3, 5): - allow_abbrev = ... # type: bool + allow_abbrev: bool + + # undocumented + _positionals: _ArgumentGroup + _optionals: _ArgumentGroup + _subparsers: Optional[_ArgumentGroup] if sys.version_info >= (3, 5): def __init__(self, @@ -64,19 +120,6 @@ class ArgumentParser: argument_default: Optional[_Text] = ..., conflict_handler: _Text = ..., add_help: bool = ...) -> None: ... - def add_argument(self, - *name_or_flags: Union[_Text, Sequence[_Text]], - action: Union[_Text, Type[Action]] = ..., - nargs: Union[int, _Text] = ..., - const: Any = ..., - default: Any = ..., - type: Union[Callable[[str], _T], FileType] = ..., - choices: Iterable[_T] = ..., - required: bool = ..., - help: _Text = ..., - metavar: Union[_Text, Tuple[_Text, ...]] = ..., - dest: Optional[_Text] = ..., - version: _Text = ...) -> Action: ... def parse_args(self, args: Optional[Sequence[_Text]] = ..., namespace: Optional[Namespace] = ...) -> Namespace: ... def add_subparsers(self, title: _Text = ..., @@ -88,11 +131,6 @@ class ArgumentParser: dest: Optional[_Text] = ..., help: Optional[_Text] = ..., metavar: Optional[_Text] = ...) -> _SubParsersAction: ... - def add_argument_group(self, title: Optional[_Text] = ..., - description: Optional[_Text] = ...) -> _ArgumentGroup: ... - def add_mutually_exclusive_group(self, required: bool = ...) -> _MutuallyExclusiveGroup: ... - def set_defaults(self, **kwargs: Any) -> None: ... - def get_default(self, dest: _Text) -> Any: ... def print_usage(self, file: Optional[IO[str]] = ...) -> None: ... def print_help(self, file: Optional[IO[str]] = ...) -> None: ... def format_usage(self) -> str: ... @@ -102,19 +140,78 @@ class ArgumentParser: def convert_arg_line_to_args(self, arg_line: _Text) -> List[str]: ... def exit(self, status: int = ..., message: Optional[_Text] = ...) -> None: ... def error(self, message: _Text) -> None: ... + if sys.version_info >= (3, 7): + def parse_intermixed_args(self, args: Optional[Sequence[_Text]] = ..., + namespace: Optional[Namespace] = ...) -> Namespace: ... + def parse_known_intermixed_args(self, + args: Optional[Sequence[_Text]] = ..., + namespace: Optional[Namespace] = ...) -> Tuple[Namespace, List[str]]: ... + # undocumented + def _get_optional_actions(self) -> List[Action]: ... + def _get_positional_actions(self) -> List[Action]: ... + def _parse_known_args(self, arg_strings: List[_Text], namespace: Namespace) -> Tuple[Namespace, List[str]]: ... + def _read_args_from_files(self, arg_strings: List[_Text]) -> List[_Text]: ... + def _match_argument(self, action: Action, arg_strings_pattern: _Text) -> int: ... + def _match_arguments_partial(self, actions: Sequence[Action], arg_strings_pattern: _Text) -> List[int]: ... + def _parse_optional(self, arg_string: _Text) -> Optional[Tuple[Optional[Action], _Text, Optional[_Text]]]: ... + def _get_option_tuples(self, option_string: _Text) -> List[Tuple[Action, _Text, Optional[_Text]]]: ... + def _get_nargs_pattern(self, action: Action) -> _Text: ... + def _get_values(self, action: Action, arg_strings: List[_Text]) -> Any: ... + def _get_value(self, action: Action, arg_string: _Text) -> Any: ... + def _check_value(self, action: Action, value: Any) -> None: ... + def _get_formatter(self) -> HelpFormatter: ... + def _print_message(self, message: str, file: Optional[IO[str]] = ...) -> None: ... class HelpFormatter: - # not documented + # undocumented + _prog: _Text + _indent_increment: int + _max_help_position: int + _width: int + _current_indent: int + _level: int + _action_max_length: int + _root_section: Any + _current_section: Any + _whitespace_matcher: Pattern[str] + _long_break_matcher: Pattern[str] + _Section: Type[Any] # Nested class def __init__(self, prog: _Text, indent_increment: int = ..., max_help_position: int = ..., width: Optional[int] = ...) -> None: ... + def _indent(self) -> None: ... + def _dedent(self) -> None: ... + def _add_item(self, func: Callable[..., _Text], args: Iterable[Any]) -> None: ... + def start_section(self, heading: Optional[_Text]) -> None: ... + def end_section(self) -> None: ... + def add_text(self, text: Optional[_Text]) -> None: ... + def add_usage(self, usage: _Text, actions: Iterable[Action], groups: Iterable[_ArgumentGroup], prefix: Optional[_Text] = ...) -> None: ... + def add_argument(self, action: Action) -> None: ... + def add_arguments(self, actions: Iterable[Action]) -> None: ... + def format_help(self) -> _Text: ... + def _join_parts(self, part_strings: Iterable[_Text]) -> _Text: ... + def _format_usage(self, usage: _Text, actions: Iterable[Action], groups: Iterable[_ArgumentGroup], prefix: Optional[_Text]) -> _Text: ... + def _format_actions_usage(self, actions: Iterable[Action], groups: Iterable[_ArgumentGroup]) -> _Text: ... + def _format_text(self, text: _Text) -> _Text: ... + def _format_action(self, action: Action) -> _Text: ... + def _format_action_invocation(self, action: Action) -> _Text: ... + def _metavar_formatter(self, action: Action, default_metavar: _Text) -> Callable[[int], Tuple[_Text, ...]]: ... + def _format_args(self, action: Action, default_metavar: _Text) -> _Text: ... + def _expand_help(self, action: Action) -> _Text: ... + def _iter_indented_subactions(self, action: Action) -> Generator[Action, None, None]: ... + def _split_lines(self, text: _Text, width: int) -> List[_Text]: ... + def _fill_text(self, text: _Text, width: int, indent: int) -> _Text: ... + def _get_help_string(self, action: Action) -> Optional[_Text]: ... + def _get_default_metavar_for_optional(self, action: Action) -> _Text: ... + def _get_default_metavar_for_positional(self, action: Action) -> _Text: ... + class RawDescriptionHelpFormatter(HelpFormatter): ... class RawTextHelpFormatter(HelpFormatter): ... class ArgumentDefaultsHelpFormatter(HelpFormatter): ... if sys.version_info >= (3,): class MetavarTypeHelpFormatter(HelpFormatter): ... -class Action: +class Action(_AttributeHolder): option_strings: Sequence[_Text] dest: _Text nargs: Optional[Union[int, _Text]] @@ -128,7 +225,7 @@ class Action: def __init__(self, option_strings: Sequence[_Text], - dest: _Text = ..., + dest: _Text, nargs: Optional[Union[int, _Text]] = ..., const: Any = ..., default: Any = ..., @@ -141,13 +238,19 @@ class Action: values: Union[_Text, Sequence[Any], None], option_string: Optional[_Text] = ...) -> None: ... -class Namespace: +class Namespace(_AttributeHolder): def __init__(self, **kwargs: Any) -> None: ... def __getattr__(self, name: _Text) -> Any: ... def __setattr__(self, name: _Text, value: Any) -> None: ... def __contains__(self, key: str) -> bool: ... class FileType: + # undocumented + _mode: _Text + _bufsize: int + if sys.version_info >= (3, 4): + _encoding: Optional[_Text] + _errors: Optional[_Text] if sys.version_info >= (3, 4): def __init__(self, mode: _Text = ..., bufsize: int = ..., encoding: Optional[_Text] = ..., @@ -160,27 +263,118 @@ class FileType: mode: _Text = ..., bufsize: Optional[int] = ...) -> None: ... def __call__(self, string: _Text) -> IO[Any]: ... -class _ArgumentGroup: - def add_argument(self, - *name_or_flags: Union[_Text, Sequence[_Text]], - action: Union[_Text, Type[Action]] = ..., - nargs: Union[int, _Text] = ..., - const: Any = ..., - default: Any = ..., - type: Union[Callable[[str], _T], FileType] = ..., - choices: Iterable[_T] = ..., - required: bool = ..., - help: _Text = ..., - metavar: Union[_Text, Tuple[_Text, ...]] = ..., - dest: Optional[_Text] = ..., - version: _Text = ...) -> Action: ... - def add_mutually_exclusive_group(self, required: bool = ...) -> _MutuallyExclusiveGroup: ... +# undocumented +class _ArgumentGroup(_ActionsContainer): + title: Optional[_Text] + _group_actions: List[Action] + def __init__(self, container: _ActionsContainer, + title: Optional[_Text] = ..., + description: Optional[_Text] = ..., **kwargs: Any) -> None: ... -class _MutuallyExclusiveGroup(_ArgumentGroup): ... +# undocumented +class _MutuallyExclusiveGroup(_ArgumentGroup): + required: bool + _container: _ActionsContainer + def __init__(self, container: _ActionsContainer, required: bool = ...) -> None: ... -class _SubParsersAction: +# undocumented +class _StoreAction(Action): ... + +# undocumented +class _StoreConstAction(Action): + def __init__(self, + option_strings: Sequence[_Text], + dest: _Text, + const: Any, + default: Any = ..., + required: bool = ..., + help: Optional[_Text] = ..., + metavar: Optional[Union[_Text, Tuple[_Text, ...]]] = ...) -> None: ... + +# undocumented +class _StoreTrueAction(_StoreConstAction): + def __init__(self, + option_strings: Sequence[_Text], + dest: _Text, + default: bool = ..., + required: bool = ..., + help: Optional[_Text] = ...) -> None: ... + +# undocumented +class _StoreFalseAction(_StoreConstAction): + def __init__(self, + option_strings: Sequence[_Text], + dest: _Text, + default: bool = ..., + required: bool = ..., + help: Optional[_Text] = ...) -> None: ... + +# undocumented +class _AppendAction(Action): ... + +# undocumented +class _AppendConstAction(Action): + def __init__(self, + option_strings: Sequence[_Text], + dest: _Text, + const: Any, + default: Any = ..., + required: bool = ..., + help: Optional[_Text] = ..., + metavar: Optional[Union[_Text, Tuple[_Text, ...]]] = ...) -> None: ... + +# undocumented +class _CountAction(Action): + def __init__(self, + option_strings: Sequence[_Text], + dest: _Text, + default: Any = ..., + required: bool = ..., + help: Optional[_Text] = ...) -> None: ... + +# undocumented +class _HelpAction(Action): + def __init__(self, + option_strings: Sequence[_Text], + dest: _Text = ..., + default: _Text = ..., + help: Optional[_Text] = ...) -> None: ... + +# undocumented +class _VersionAction(Action): + version: Optional[_Text] + def __init__(self, + option_strings: Sequence[_Text], + version: Optional[_Text] = ..., + dest: _Text = ..., + default: _Text = ..., + help: _Text = ...) -> None: ... + +# undocumented +class _SubParsersAction(Action): + _ChoicesPseudoAction: Type[Any] # nested class + _prog_prefix: _Text + _parser_class: Type[ArgumentParser] + _name_parser_map: Dict[_Text, ArgumentParser] + _choices_actions: List[Action] + 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: ... # TODO: Type keyword args properly. def add_parser(self, name: _Text, **kwargs: Any) -> ArgumentParser: ... + def _get_subactions(self) -> List[Action]: ... -# not documented +# undocumented class ArgumentTypeError(Exception): ... + +if sys.version_info < (3, 7): + # undocumented + def _ensure_value(namespace: Namespace, name: _Text, value: Any) -> Any: ... + +# undocumented +def _get_action_name(argument: Optional[Action]) -> Optional[str]: ... diff --git a/python/helpers/typeshed/stdlib/2and3/code.pyi b/python/helpers/typeshed/stdlib/2and3/code.pyi index e775851754a9..293ab9b98b61 100644 --- a/python/helpers/typeshed/stdlib/2and3/code.pyi +++ b/python/helpers/typeshed/stdlib/2and3/code.pyi @@ -1,5 +1,6 @@ # Stubs for code +import sys from typing import Any, Callable, Mapping, Optional from types import CodeType @@ -15,13 +16,23 @@ class InteractiveInterpreter: class InteractiveConsole(InteractiveInterpreter): def __init__(self, locals: Optional[Mapping[str, Any]] = ..., filename: str = ...) -> None: ... - def interact(self, banner: Optional[str] = ...) -> None: ... + if sys.version_info >= (3, 6): + def interact(self, banner: Optional[str] = ..., + exitmsg: Optional[str] = ...) -> None: ... + else: + def interact(self, banner: Optional[str] = ...) -> None: ... def push(self, line: str) -> bool: ... def resetbuffer(self) -> None: ... def raw_input(self, prompt: str = ...) -> str: ... -def interact(banner: Optional[str] = ..., - readfunc: Optional[Callable[[str], str]] = ..., - local: Optional[Mapping[str, Any]] = ...) -> None: ... +if sys.version_info >= (3, 6): + def interact(banner: Optional[str] = ..., + readfunc: Optional[Callable[[str], str]] = ..., + local: Optional[Mapping[str, Any]] = ..., + exitmsg: Optional[str] = ...) -> None: ... +else: + def interact(banner: Optional[str] = ..., + readfunc: Optional[Callable[[str], str]] = ..., + local: Optional[Mapping[str, Any]] = ...) -> None: ... def compile_command(source: str, filename: str = ..., symbol: str = ...) -> Optional[CodeType]: ... diff --git a/python/helpers/typeshed/stdlib/2and3/distutils/errors.pyi b/python/helpers/typeshed/stdlib/2and3/distutils/errors.pyi index 49ca06f016c2..e483362bfbf1 100644 --- a/python/helpers/typeshed/stdlib/2and3/distutils/errors.pyi +++ b/python/helpers/typeshed/stdlib/2and3/distutils/errors.pyi @@ -1,4 +1,19 @@ -# Stubs for distutils.errors - -class DistutilsExecError(Exception): ... -class DistutilsFileError(Exception): ... +class DistutilsError(Exception): ... +class DistutilsModuleError(DistutilsError): ... +class DistutilsClassError(DistutilsError): ... +class DistutilsGetoptError(DistutilsError): ... +class DistutilsArgError(DistutilsError): ... +class DistutilsFileError(DistutilsError): ... +class DistutilsOptionError(DistutilsError): ... +class DistutilsSetupError(DistutilsError): ... +class DistutilsPlatformError(DistutilsError): ... +class DistutilsExecError(DistutilsError): ... +class DistutilsInternalError(DistutilsError): ... +class DistutilsTemplateError(DistutilsError): ... +class DistutilsByteCompileError(DistutilsError): ... +class CCompilerError(Exception): ... +class PreprocessError(CCompilerError): ... +class CompileError(CCompilerError): ... +class LibError(CCompilerError): ... +class LinkError(CCompilerError): ... +class UnknownFileError(CCompilerError): ... diff --git a/python/helpers/typeshed/stdlib/2and3/ftplib.pyi b/python/helpers/typeshed/stdlib/2and3/ftplib.pyi index 128b91da99f1..010961313816 100644 --- a/python/helpers/typeshed/stdlib/2and3/ftplib.pyi +++ b/python/helpers/typeshed/stdlib/2and3/ftplib.pyi @@ -1,6 +1,6 @@ # Stubs for ftplib (Python 2.7/3) import sys -from typing import Optional, BinaryIO, Tuple, TextIO, Iterable, Callable, List, Union, Iterator, Dict, Text, TypeVar, Generic, Any +from typing import Optional, BinaryIO, Tuple, TextIO, Iterable, Callable, List, Union, Iterator, Dict, Text, Type, TypeVar, Generic, Any from types import TracebackType from socket import socket from ssl import SSLContext @@ -43,7 +43,7 @@ class FTP: file = ... # type: Optional[TextIO] encoding = ... # type: str def __enter__(self: _T) -> _T: ... - def __exit__(self, exc_type: Optional[type], exc_val: Optional[Exception], + def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> bool: ... else: file = ... # type: Optional[BinaryIO] diff --git a/python/helpers/typeshed/stdlib/2and3/pdb.pyi b/python/helpers/typeshed/stdlib/2and3/pdb.pyi index 83f2c544baef..f70a9a4397ea 100644 --- a/python/helpers/typeshed/stdlib/2and3/pdb.pyi +++ b/python/helpers/typeshed/stdlib/2and3/pdb.pyi @@ -1,30 +1,19 @@ # NOTE: This stub is incomplete - only contains some global functions +import sys from typing import Any, Dict, Optional -def run(statement: str, - globals: Optional[Dict[str, Any]] = ..., - locals: Optional[Dict[str, Any]] = ...) -> None: - ... +def run(statement: str, globals: Optional[Dict[str, Any]] = ..., + locals: Optional[Dict[str, Any]] = ...) -> None: ... +def runeval(expression: str, globals: Optional[Dict[str, Any]] = ..., + locals: Optional[Dict[str, Any]] = ...) -> Any: ... +def runctx(statement: str, globals: Dict[str, Any], locals: Dict[str, Any]) -> None: ... +def runcall(*args: Any, **kwds: Any) -> Any: ... -def runeval(expression: str, - globals: Optional[Dict[str, Any]] = ..., - locals: Optional[Dict[str, Any]] = ...) -> Any: - ... +if sys.version_info >= (3, 7): + def set_trace(*, header: Optional[str] = ...) -> None: ... +else: + def set_trace() -> None: ... -def runctx(statement: str, - globals: Dict[str, Any], - locals: Dict[str, Any]) -> None: - ... - -def runcall(*args: Any, **kwds: Any) -> Any: - ... - -def set_trace() -> None: - ... - -def post_mortem(t: Optional[Any] = ...) -> None: - ... - -def pm() -> None: - ... +def post_mortem(t: Optional[Any] = ...) -> None: ... +def pm() -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/pkgutil.pyi b/python/helpers/typeshed/stdlib/2and3/pkgutil.pyi index 3f4903624828..5d4ff1e54df5 100644 --- a/python/helpers/typeshed/stdlib/2and3/pkgutil.pyi +++ b/python/helpers/typeshed/stdlib/2and3/pkgutil.pyi @@ -1,6 +1,6 @@ # Stubs for pkgutil -from typing import Any, Callable, Generator, IO, Iterable, List, Optional, Tuple +from typing import Any, Callable, Generator, IO, Iterable, List, Optional, Tuple, NamedTuple import sys if sys.version_info >= (3,): @@ -8,7 +8,11 @@ if sys.version_info >= (3,): else: Loader = Any -_YMFNI = Generator[Tuple[Any, str, bool], None, None] +if sys.version_info >= (3, 6): + ModuleInfo = NamedTuple('ModuleInfo', [('module_finder', Any), ('name', str), ('ispkg', bool)]) + _YMFNI = Generator[ModuleInfo, None, None] +else: + _YMFNI = Generator[Tuple[Any, str, bool], None, None] def extend_path(path: Iterable[str], name: str) -> Iterable[str]: ... diff --git a/python/helpers/typeshed/stdlib/2and3/plistlib.pyi b/python/helpers/typeshed/stdlib/2and3/plistlib.pyi index 6b65496c271d..df8cdb7dba29 100644 --- a/python/helpers/typeshed/stdlib/2and3/plistlib.pyi +++ b/python/helpers/typeshed/stdlib/2and3/plistlib.pyi @@ -46,7 +46,7 @@ if sys.version_info < (3,): def readPlistFromString(data: str) -> DictT[str, Any]: ... def writePlistToString(rootObject: Mapping[str, Any]) -> str: ... -if sys.version_info >= (3,): +if sys.version_info < (3, 7): class Dict(dict): def __getattr__(self, attr: str) -> Any: ... def __setattr__(self, attr: str, value: Any) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/sched.pyi b/python/helpers/typeshed/stdlib/2and3/sched.pyi index b8e7b2b0ac1c..5d5cf33d23f3 100644 --- a/python/helpers/typeshed/stdlib/2and3/sched.pyi +++ b/python/helpers/typeshed/stdlib/2and3/sched.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Callable, Dict, List, NamedTuple, Text, Tuple +from typing import Any, Callable, Dict, List, NamedTuple, Optional, Text, Tuple Event = NamedTuple('Event', [ ('time', float), @@ -14,12 +14,12 @@ class scheduler: def __init__(self, timefunc: Callable[[], float] = ..., delayfunc: Callable[[float], None] = ...) -> None: ... def enterabs(self, time: float, priority: Any, action: Callable[..., Any], argument: Tuple[Any, ...] = ..., kwargs: Dict[str, Any] = ...) -> Event: ... def enter(self, delay: float, priority: Any, action: Callable[..., Any], argument: Tuple[Any, ...] = ..., kwargs: Dict[str, Any] = ...) -> Event: ... - def run(self, blocking: bool = ...) -> float: ... + def run(self, blocking: bool = ...) -> Optional[float]: ... else: def __init__(self, timefunc: Callable[[], float], delayfunc: Callable[[float], None]) -> None: ... def enterabs(self, time: float, priority: Any, action: Callable[..., Any], argument: Tuple[Any, ...]) -> Event: ... def enter(self, delay: float, priority: Any, action: Callable[..., Any], argument: Tuple[Any, ...]) -> Event: ... - def run(self) -> float: ... + def run(self) -> None: ... def cancel(self, event: Event) -> None: ... def empty(self) -> bool: ... diff --git a/python/helpers/typeshed/stdlib/2/sqlite3/__init__.pyi b/python/helpers/typeshed/stdlib/2and3/sqlite3/__init__.pyi similarity index 100% rename from python/helpers/typeshed/stdlib/2/sqlite3/__init__.pyi rename to python/helpers/typeshed/stdlib/2and3/sqlite3/__init__.pyi diff --git a/python/helpers/typeshed/stdlib/3/sqlite3/dbapi2.pyi b/python/helpers/typeshed/stdlib/2and3/sqlite3/dbapi2.pyi similarity index 83% rename from python/helpers/typeshed/stdlib/3/sqlite3/dbapi2.pyi rename to python/helpers/typeshed/stdlib/2and3/sqlite3/dbapi2.pyi index fc748e2da9df..fd223a4e057e 100644 --- a/python/helpers/typeshed/stdlib/3/sqlite3/dbapi2.pyi +++ b/python/helpers/typeshed/stdlib/2and3/sqlite3/dbapi2.pyi @@ -2,26 +2,25 @@ # based heavily on Andrey Vlasovskikh's python-skeletons https://github.com/JetBrains/python-skeletons/blob/master/sqlite3.py import sys -from typing import Any, Union, List, Iterator, Optional, TypeVar, Callable -from datetime import time, datetime -from collections import Iterable +from typing import Any, Callable, Iterable, Iterator, List, Optional, Text, Tuple, Type, TypeVar, Union +from datetime import date, time, datetime _T = TypeVar('_T') -paramstyle = ... # type: str -threadsafety = ... # type: int -apilevel = ... # type: str -Date = ... # type: datetime -Time = ... # type: time -Timestamp = ... # type: datetime +paramstyle: str +threadsafety: int +apilevel: str +Date = date +Time = time +Timestamp = datetime def DateFromTicks(ticks): ... def TimeFromTicks(ticks): ... def TimestampFromTicks(ticks): ... -version_info = ... # type: Any -sqlite_version_info = ... # type: Any -Binary = ... # type: Any +version_info: str +sqlite_version_info: Tuple[int, int, int] +Binary: Type[Any] def register_adapters_and_converters(): ... @@ -69,21 +68,33 @@ version = ... # type: str def adapt(obj, protocol, alternate): ... def complete_statement(sql: str) -> bool: ... if sys.version_info >= (3, 4): - def connect(database: Union[bytes, str], timeout: float = ..., detect_types: int = ..., isolation_level: Union[str, None] = ..., check_same_thread: bool = ..., factory: Union[Connection, None] = ..., cached_statements: int = ..., uri: bool = ...) -> Connection: ... + def connect(database: Union[bytes, Text], + timeout: float = ..., + detect_types: int = ..., + isolation_level: Optional[str] = ..., + check_same_thread: bool = ..., + factory: Optional[Type[Connection]] = ..., + cached_statements: int = ..., + uri: bool = ...) -> Connection: ... else: - def connect(database: Union[bytes, str], timeout: float = ..., detect_types: int = ..., isolation_level: Union[str, None] = ..., check_same_thread: bool = ..., factory: Union[Connection, None] = ..., cached_statements: int = ...) -> Connection: ... + def connect(database: Union[bytes, Text], + timeout: float = ..., + detect_types: int = ..., + isolation_level: Optional[str] = ..., + check_same_thread: bool = ..., + factory: Optional[Type[Connection]] = ..., + cached_statements: int = ...) -> Connection: ... def enable_callback_tracebacks(flag: bool) -> None: ... def enable_shared_cache(do_enable: int) -> None: ... -def register_adapter(type: _T, callable: Callable[[_T], Union[int, float, str, bytes]]) -> None: ... -# TODO: sqlite3.register_converter.__doc__ specifies callable as unknown +def register_adapter(type: Type[_T], callable: Callable[[_T], Union[int, float, str, bytes]]) -> None: ... def register_converter(typename: str, callable: Callable[[bytes], Any]) -> None: ... -class Cache: +class Cache(object): def __init__(self, *args, **kwargs) -> None: ... def display(self, *args, **kwargs) -> None: ... def get(self, *args, **kwargs) -> None: ... -class Connection: +class Connection(object): DataError = ... # type: Any DatabaseError = ... # type: Any Error = ... # type: Any @@ -109,7 +120,7 @@ class Connection: def execute(self, sql: str, parameters: Iterable = ...) -> Cursor: ... # TODO: please check in executemany() if seq_of_parameters type is possible like this def executemany(self, sql: str, seq_of_parameters: Iterable[Iterable]) -> Cursor: ... - def executescript(self, sql_script: Union[bytes, str]) -> Cursor: ... + def executescript(self, sql_script: Union[bytes, Text]) -> Cursor: ... def interrupt(self, *args, **kwargs) -> None: ... def iterdump(self, *args, **kwargs) -> None: ... def rollback(self, *args, **kwargs) -> None: ... @@ -120,6 +131,10 @@ class Connection: # set_progress_handler(handler, n) -> see https://docs.python.org/2/library/sqlite3.html#sqlite3.Connection.set_progress_handler def set_progress_handler(self, *args, **kwargs) -> None: ... def set_trace_callback(self, *args, **kwargs): ... + if sys.version_info >= (3, 7): + def backup(self, target: Connection, *, pages: int = ..., + progress: Optional[Callable[[int, int, int], object]] = ..., name: str = ..., + sleep: float = ...) -> None: ... def __call__(self, *args, **kwargs): ... def __enter__(self, *args, **kwargs): ... def __exit__(self, *args, **kwargs): ... @@ -138,7 +153,7 @@ class Cursor(Iterator[Any]): def close(self, *args, **kwargs): ... def execute(self, sql: str, parameters: Iterable = ...) -> Cursor: ... def executemany(self, sql: str, seq_of_parameters: Iterable[Iterable]): ... - def executescript(self, sql_script: Union[bytes, str]) -> Cursor: ... + def executescript(self, sql_script: Union[bytes, Text]) -> Cursor: ... def fetchall(self) -> List[Any]: ... def fetchmany(self, size: Optional[int] = ...) -> List[Any]: ... def fetchone(self) -> Any: ... @@ -164,7 +179,7 @@ class NotSupportedError(DatabaseError): ... class OperationalError(DatabaseError): ... -class OptimizedUnicode: +class OptimizedUnicode(object): maketrans = ... # type: Any def __init__(self, *args, **kwargs): ... def capitalize(self, *args, **kwargs): ... @@ -229,12 +244,12 @@ class OptimizedUnicode: def __rmod__(self, other): ... def __rmul__(self, other): ... -class PrepareProtocol: +class PrepareProtocol(object): def __init__(self, *args, **kwargs): ... class ProgrammingError(DatabaseError): ... -class Row: +class Row(object): def __init__(self, *args, **kwargs): ... def keys(self, *args, **kwargs): ... def __eq__(self, other): ... @@ -248,7 +263,7 @@ class Row: def __lt__(self, other): ... def __ne__(self, other): ... -class Statement: +class Statement(object): def __init__(self, *args, **kwargs): ... class Warning(Exception): ... diff --git a/python/helpers/typeshed/stdlib/2and3/struct.pyi b/python/helpers/typeshed/stdlib/2and3/struct.pyi index be4474ecdb80..cbc5e8315a8a 100644 --- a/python/helpers/typeshed/stdlib/2and3/struct.pyi +++ b/python/helpers/typeshed/stdlib/2and3/struct.pyi @@ -27,7 +27,10 @@ if sys.version_info >= (3, 4): def calcsize(fmt: _FmtType) -> int: ... class Struct: - format = ... # type: bytes + if sys.version_info >= (3, 7): + format: str + else: + format: bytes size = ... # type: int def __init__(self, format: _FmtType) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/tarfile.pyi b/python/helpers/typeshed/stdlib/2and3/tarfile.pyi index 22fa951b3f74..02cb5797074d 100644 --- a/python/helpers/typeshed/stdlib/2and3/tarfile.pyi +++ b/python/helpers/typeshed/stdlib/2and3/tarfile.pyi @@ -119,7 +119,11 @@ class TarFile(Iterable[TarInfo]): path: _Path = ...) -> None: ... def extractfile(self, member: Union[str, TarInfo]) -> Optional[IO[bytes]]: ... - if sys.version_info >= (3,): + if sys.version_info >= (3, 7): + def add(self, name: str, arcname: Optional[str] = ..., + recursive: bool = ..., *, + filter: Optional[Callable[[TarInfo], Optional[TarInfo]]] = ...) -> None: ... + elif sys.version_info >= (3,): def add(self, name: str, arcname: Optional[str] = ..., recursive: bool = ..., exclude: Optional[Callable[[str], bool]] = ..., *, diff --git a/python/helpers/typeshed/stdlib/2and3/time.pyi b/python/helpers/typeshed/stdlib/2and3/time.pyi index 7d46ade8ad43..b04e6164b652 100644 --- a/python/helpers/typeshed/stdlib/2and3/time.pyi +++ b/python/helpers/typeshed/stdlib/2and3/time.pyi @@ -15,6 +15,11 @@ daylight: int timezone: int tzname: Tuple[str, str] +if sys.version_info >= (3, 7) and sys.platform != 'win32': + CLOCK_BOOTTIME: int # Linux + CLOCK_PROF: int # FreeBSD, NetBSD, OpenBSD + CLOCK_UPTIME: int # FreeBSD, OpenBSD + if sys.version_info >= (3, 3) and sys.platform != 'win32': CLOCK_HIGHRES: int = ... # Solaris only CLOCK_MONOTONIC: int = ... # Unix only @@ -94,3 +99,5 @@ if sys.version_info >= (3, 7): def perf_counter_ns() -> int: ... def process_time_ns() -> int: ... def time_ns() -> int: ... + def thread_time() -> float: ... + def thread_time_ns() -> int: ... diff --git a/python/helpers/typeshed/stdlib/2and3/traceback.pyi b/python/helpers/typeshed/stdlib/2and3/traceback.pyi index 29bdf67d24e5..94e4153fb38d 100644 --- a/python/helpers/typeshed/stdlib/2and3/traceback.pyi +++ b/python/helpers/typeshed/stdlib/2and3/traceback.pyi @@ -41,11 +41,11 @@ else: def extract_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ...) -> List[_PT]: ... def format_list(extracted_list: List[_PT]) -> List[str]: ... -def format_exception_only(etype: Type[BaseException], - value: BaseException) -> List[str]: ... +def format_exception_only(etype: Optional[Type[BaseException]], + value: Optional[BaseException]) -> List[str]: ... if sys.version_info >= (3,): - def format_exception(etype: Type[BaseException], value: BaseException, - tb: TracebackType, limit: Optional[int] = ..., + def format_exception(etype: Optional[Type[BaseException]], value: Optional[BaseException], + tb: Optional[TracebackType], limit: Optional[int] = ..., chain: bool = ...) -> List[str]: ... def format_exc(limit: Optional[int] = ..., chain: bool = ...) -> str: ... else: diff --git a/python/helpers/typeshed/stdlib/2and3/uu.pyi b/python/helpers/typeshed/stdlib/2and3/uu.pyi index ee01c35967ef..c926dbba2a37 100644 --- a/python/helpers/typeshed/stdlib/2and3/uu.pyi +++ b/python/helpers/typeshed/stdlib/2and3/uu.pyi @@ -1,10 +1,13 @@ # Stubs for uu (Python 2 and 3) - +import sys from typing import BinaryIO, Union, Optional, Text _File = Union[Text, BinaryIO] class Error(Exception): ... -def encode(in_file: _File, out_file: _File, name: Optional[str] = ..., mode: Optional[int] = ...) -> None: ... +if sys.version_info >= (3, 7): + def encode(in_file: _File, out_file: _File, name: Optional[str] = ..., mode: Optional[int] = ..., backtick: bool = ...) -> None: ... +else: + def encode(in_file: _File, out_file: _File, name: Optional[str] = ..., mode: Optional[int] = ...) -> None: ... def decode(in_file: _File, out_file: Optional[_File] = ..., mode: Optional[int] = ..., quiet: int = ...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/2and3/zipfile.pyi b/python/helpers/typeshed/stdlib/2and3/zipfile.pyi index 2785b380a86c..28e0f902b9fe 100644 --- a/python/helpers/typeshed/stdlib/2and3/zipfile.pyi +++ b/python/helpers/typeshed/stdlib/2and3/zipfile.pyi @@ -26,7 +26,7 @@ class ZipFile: allowZip64: bool = ...) -> None: ... def __enter__(self) -> ZipFile: ... def __exit__(self, exc_type: Optional[Type[BaseException]], - exc_val: Optional[Exception], + exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> bool: ... def close(self) -> None: ... def getinfo(self, name: Text) -> ZipInfo: ... diff --git a/python/helpers/typeshed/stdlib/3.4/asyncio/streams.pyi b/python/helpers/typeshed/stdlib/3.4/asyncio/streams.pyi index e46904e11ac2..2892d95ab8a3 100644 --- a/python/helpers/typeshed/stdlib/3.4/asyncio/streams.pyi +++ b/python/helpers/typeshed/stdlib/3.4/asyncio/streams.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Awaitable, Callable, Generator, Iterable, List, Optional, Tuple +from typing import Any, Awaitable, Callable, Generator, Iterable, List, Optional, Tuple, Union from . import coroutines from . import events @@ -23,7 +23,7 @@ class LimitOverrunError(Exception): @coroutines.coroutine def open_connection( host: str = ..., - port: int = ..., + port: Union[int, str] = ..., *, loop: Optional[events.AbstractEventLoop] = ..., limit: int = ..., @@ -33,8 +33,8 @@ def open_connection( @coroutines.coroutine def start_server( client_connected_cb: _ClientConnectedCallback, - host: str = ..., - port: int = ..., + host: Optional[str] = ..., + port: Optional[Union[int, str]] = ..., *, loop: Optional[events.AbstractEventLoop] = ..., limit: int = ..., diff --git a/python/helpers/typeshed/stdlib/3.4/pathlib.pyi b/python/helpers/typeshed/stdlib/3.4/pathlib.pyi index 0051266bee7f..307979b55a27 100644 --- a/python/helpers/typeshed/stdlib/3.4/pathlib.pyi +++ b/python/helpers/typeshed/stdlib/3.4/pathlib.pyi @@ -1,6 +1,7 @@ # Stubs for pathlib (Python 3.4) from typing import Any, Generator, IO, Optional, Sequence, Tuple, Type, TypeVar, Union, List +from types import TracebackType import os import sys @@ -52,6 +53,10 @@ class PurePosixPath(PurePath): ... class PureWindowsPath(PurePath): ... class Path(PurePath): + def __enter__(self) -> Path: ... + def __exit__(self, exc_type: Optional[Type[BaseException]], + exc_value: Optional[BaseException], + traceback: Optional[TracebackType]) -> Optional[bool]: ... @classmethod def cwd(cls: Type[_P]) -> _P: ... def stat(self) -> os.stat_result: ... diff --git a/python/helpers/typeshed/stdlib/3.5/zipapp.pyi b/python/helpers/typeshed/stdlib/3.5/zipapp.pyi index 9fac5a026aff..b90b7559ce1d 100644 --- a/python/helpers/typeshed/stdlib/3.5/zipapp.pyi +++ b/python/helpers/typeshed/stdlib/3.5/zipapp.pyi @@ -1,11 +1,16 @@ # Stubs for zipapp (Python 3.5+) from pathlib import Path -from typing import BinaryIO, Optional, Union +import sys +from typing import BinaryIO, Callable, Optional, Union _Path = Union[str, Path, BinaryIO] class ZipAppError(Exception): ... -def create_archive(source: _Path, target: Optional[_Path] = ..., interpreter: Optional[str] = ..., main: Optional[str] = ...) -> None: ... +if sys.version_info >= (3, 7): + def create_archive(source: _Path, target: Optional[_Path] = ..., interpreter: Optional[str] = ..., main: Optional[str] = ..., + filter: Optional[Callable[[Path], bool]] = ..., compressed: bool = ...) -> None: ... +else: + def create_archive(source: _Path, target: Optional[_Path] = ..., interpreter: Optional[str] = ..., main: Optional[str] = ...) -> None: ... def get_interpreter(archive: _Path) -> str: ... diff --git a/python/helpers/typeshed/stdlib/3/_ast.pyi b/python/helpers/typeshed/stdlib/3/_ast.pyi index ca75bcac5b35..c903b246c51f 100644 --- a/python/helpers/typeshed/stdlib/3/_ast.pyi +++ b/python/helpers/typeshed/stdlib/3/_ast.pyi @@ -1,4 +1,4 @@ -# Python 3.5 _ast +import sys import typing from typing import Any, Optional, Union @@ -16,6 +16,8 @@ class mod(AST): class Module(mod): body = ... # type: typing.List[stmt] + if sys.version_info >= (3, 7): + docstring: Optional[str] class Interactive(mod): body = ... # type: typing.List[stmt] @@ -37,6 +39,8 @@ class FunctionDef(stmt): body = ... # type: typing.List[stmt] decorator_list = ... # type: typing.List[expr] returns = ... # type: Optional[expr] + if sys.version_info >= (3, 7): + docstring: Optional[str] class AsyncFunctionDef(stmt): name = ... # type: _identifier @@ -44,6 +48,8 @@ class AsyncFunctionDef(stmt): body = ... # type: typing.List[stmt] decorator_list = ... # type: typing.List[expr] returns = ... # type: Optional[expr] + if sys.version_info >= (3, 7): + docstring: Optional[str] class ClassDef(stmt): name = ... # type: _identifier @@ -51,6 +57,8 @@ class ClassDef(stmt): keywords = ... # type: typing.List[keyword] body = ... # type: typing.List[stmt] decorator_list = ... # type: typing.List[expr] + if sys.version_info >= (3, 7): + docstring: Optional[str] class Return(stmt): value = ... # type: Optional[expr] diff --git a/python/helpers/typeshed/stdlib/3/collections/__init__.pyi b/python/helpers/typeshed/stdlib/3/collections/__init__.pyi index 29eed2e3255a..cad3de72834a 100644 --- a/python/helpers/typeshed/stdlib/3/collections/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3/collections/__init__.pyi @@ -52,7 +52,10 @@ _VT = TypeVar('_VT') # namedtuple is special-cased in the type checker; the initializer is ignored. -if sys.version_info >= (3, 6): +if sys.version_info >= (3, 7): + def namedtuple(typename: str, field_names: Union[str, Iterable[str]], *, + rename: bool = ..., module: Optional[str] = ...) -> Type[tuple]: ... +elif sys.version_info >= (3, 6): def namedtuple(typename: str, field_names: Union[str, Iterable[str]], *, verbose: bool = ..., rename: bool = ..., module: Optional[str] = ...) -> Type[tuple]: ... else: diff --git a/python/helpers/typeshed/stdlib/3/http/client.pyi b/python/helpers/typeshed/stdlib/3/http/client.pyi index 6bf90c9a2204..5bcb00c4cb6a 100644 --- a/python/helpers/typeshed/stdlib/3/http/client.pyi +++ b/python/helpers/typeshed/stdlib/3/http/client.pyi @@ -1,5 +1,5 @@ from typing import ( - Any, Dict, IO, Iterable, List, Iterator, Mapping, Optional, Tuple, TypeVar, + Any, Dict, IO, Iterable, List, Iterator, Mapping, Optional, Tuple, Type, TypeVar, Union, overload, ) @@ -98,8 +98,8 @@ if sys.version_info >= (3, 5): def isclosed(self) -> bool: ... def __iter__(self) -> Iterator[bytes]: ... def __enter__(self) -> 'HTTPResponse': ... - def __exit__(self, exc_type: Optional[type], - exc_val: Optional[Exception], + def __exit__(self, exc_type: Optional[Type[BaseException]], + exc_val: Optional[BaseException], exc_tb: Optional[types.TracebackType]) -> bool: ... else: class HTTPResponse: diff --git a/python/helpers/typeshed/stdlib/3/io.pyi b/python/helpers/typeshed/stdlib/3/io.pyi index f7d0df3431b0..f43e76d7d21e 100644 --- a/python/helpers/typeshed/stdlib/3/io.pyi +++ b/python/helpers/typeshed/stdlib/3/io.pyi @@ -1,5 +1,5 @@ from typing import ( - List, BinaryIO, TextIO, Iterator, Union, Optional, Callable, Tuple, Any, IO, Iterable + List, BinaryIO, TextIO, Iterator, Union, Optional, Callable, Tuple, Type, Any, IO, Iterable ) import builtins import codecs @@ -32,7 +32,7 @@ class IOBase: def __iter__(self) -> Iterator[bytes]: ... def __next__(self) -> bytes: ... def __enter__(self: _T) -> _T: ... - def __exit__(self, exc_type: Optional[type], exc_val: Optional[Exception], + def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> bool: ... def close(self) -> None: ... def fileno(self) -> int: ... @@ -109,8 +109,8 @@ class BytesIO(BinaryIO): def __iter__(self) -> Iterator[bytes]: ... def __next__(self) -> bytes: ... def __enter__(self) -> 'BytesIO': ... - def __exit__(self, t: Optional[type] = ..., value: Optional[BaseException] = ..., - traceback: Optional[Any] = ...) -> bool: ... + def __exit__(self, t: Optional[Type[BaseException]] = ..., value: Optional[BaseException] = ..., + traceback: Optional[TracebackType] = ...) -> bool: ... def close(self) -> None: ... def fileno(self) -> int: ... def flush(self) -> None: ... @@ -212,8 +212,8 @@ class TextIOWrapper(TextIO): write_through: bool = ... ) -> None: ... # copied from IOBase - def __exit__(self, t: Optional[type] = ..., value: Optional[BaseException] = ..., - traceback: Optional[Any] = ...) -> bool: ... + def __exit__(self, t: Optional[Type[BaseException]] = ..., value: Optional[BaseException] = ..., + traceback: Optional[TracebackType] = ...) -> bool: ... def close(self) -> None: ... def fileno(self) -> int: ... def flush(self) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/itertools.pyi b/python/helpers/typeshed/stdlib/3/itertools.pyi index 6421163ff161..51a2ab374560 100644 --- a/python/helpers/typeshed/stdlib/3/itertools.pyi +++ b/python/helpers/typeshed/stdlib/3/itertools.pyi @@ -40,9 +40,9 @@ def groupby(iterable: Iterable[_T], key: Callable[[_T], _S]) -> Iterator[Tuple[_S, Iterator[_T]]]: ... @overload -def islice(iterable: Iterable[_T], stop: int) -> Iterator[_T]: ... +def islice(iterable: Iterable[_T], stop: Optional[int]) -> Iterator[_T]: ... @overload -def islice(iterable: Iterable[_T], start: int, stop: Optional[int], +def islice(iterable: Iterable[_T], start: Optional[int], stop: Optional[int], step: int = ...) -> Iterator[_T]: ... def starmap(func: Callable[..., _S], iterable: Iterable[Iterable[Any]]) -> Iterator[_S]: ... diff --git a/python/helpers/typeshed/stdlib/3/multiprocessing/__init__.pyi b/python/helpers/typeshed/stdlib/3/multiprocessing/__init__.pyi index 70080935e124..2914c99f1c27 100644 --- a/python/helpers/typeshed/stdlib/3/multiprocessing/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3/multiprocessing/__init__.pyi @@ -57,6 +57,9 @@ class Process(): def start(self) -> None: ... def run(self) -> None: ... def terminate(self) -> None: ... + if sys.version_info >= (3, 7): + def kill(self) -> None: ... + def close(self) -> None: ... def is_alive(self) -> bool: ... def join(self, timeout: Optional[float] = ...) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/multiprocessing/managers.pyi b/python/helpers/typeshed/stdlib/3/multiprocessing/managers.pyi index 74634e3aafbc..656ee8d2c41c 100644 --- a/python/helpers/typeshed/stdlib/3/multiprocessing/managers.pyi +++ b/python/helpers/typeshed/stdlib/3/multiprocessing/managers.pyi @@ -6,7 +6,7 @@ import queue import threading from typing import ( Any, Callable, ContextManager, Dict, Iterable, List, Mapping, Optional, - Sequence, TypeVar, + Sequence, Tuple, TypeVar, Union, ) _T = TypeVar('_T') @@ -18,6 +18,8 @@ class Namespace: ... _Namespace = Namespace class BaseManager(ContextManager[BaseManager]): + address: Union[str, Tuple[str, int]] + def connect(self) -> None: ... def register(self, typeid: str, callable: Any = ...) -> None: ... def shutdown(self) -> None: ... def start(self, initializer: Optional[Callable[..., Any]] = ..., diff --git a/python/helpers/typeshed/stdlib/3/os/__init__.pyi b/python/helpers/typeshed/stdlib/3/os/__init__.pyi index 33686542b8d5..9b56a86336a7 100644 --- a/python/helpers/typeshed/stdlib/3/os/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3/os/__init__.pyi @@ -454,7 +454,16 @@ if sys.version_info >= (3, 3): def rmdir(path: _PathType, *, dir_fd: Optional[int] = ...) -> None: ... else: def rmdir(path: _PathType) -> None: ... -if sys.version_info >= (3, 6): +if sys.version_info >= (3, 7): + class _ScandirIterator(Iterator[DirEntry[AnyStr]], ContextManager[_ScandirIterator[AnyStr]]): + def close(self) -> None: ... + @overload + def scandir() -> _ScandirIterator[str]: ... + @overload + def scandir(path: int) -> _ScandirIterator[str]: ... + @overload + def scandir(path: Union[AnyStr, PathLike[AnyStr]]) -> _ScandirIterator[AnyStr]: ... +elif sys.version_info >= (3, 6): class _ScandirIterator(Iterator[DirEntry[AnyStr]], ContextManager[_ScandirIterator[AnyStr]]): def close(self) -> None: ... @overload @@ -471,10 +480,11 @@ if sys.version_info >= (3, 3): follow_symlinks: bool = ...) -> stat_result: ... else: def stat(path: _PathType) -> stat_result: ... -@overload -def stat_float_times() -> bool: ... -@overload -def stat_float_times(__newvalue: bool) -> None: ... +if sys.version_info < (3, 7): + @overload + def stat_float_times() -> bool: ... + @overload + def stat_float_times(__newvalue: bool) -> None: ... def statvfs(path: _FdOrPathType) -> statvfs_result: ... # Unix only if sys.version_info >= (3, 3): def symlink(source: _PathType, link_name: _PathType, @@ -502,9 +512,23 @@ else: followlinks: bool = ...) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr]]]: ... if sys.version_info >= (3, 3): - def fwalk(top: _PathType = ..., topdown: bool = ..., - onerror: Optional[Callable] = ..., *, follow_symlinks: bool = ..., - dir_fd: Optional[int] = ...) -> Iterator[Tuple[str, List[str], List[str], int]]: ... # Unix only + if sys.version_info >= (3, 7): + @overload + def fwalk(top: Union[str, PathLike[str]] = ..., topdown: bool = ..., + onerror: Optional[Callable] = ..., *, follow_symlinks: bool = ..., + dir_fd: Optional[int] = ...) -> Iterator[Tuple[str, List[str], List[str], int]]: ... # Unix only + @overload + def fwalk(top: bytes, topdown: bool = ..., + onerror: Optional[Callable] = ..., *, follow_symlinks: bool = ..., + dir_fd: Optional[int] = ...) -> Iterator[Tuple[bytes, List[bytes], List[bytes], int]]: ... # Unix only + elif sys.version_info >= (3, 6): + def fwalk(top: Union[str, PathLike[str]] = ..., topdown: bool = ..., + onerror: Optional[Callable] = ..., *, follow_symlinks: bool = ..., + dir_fd: Optional[int] = ...) -> Iterator[Tuple[str, List[str], List[str], int]]: ... # Unix only + else: + def fwalk(top: str = ..., topdown: bool = ..., + onerror: Optional[Callable] = ..., *, follow_symlinks: bool = ..., + dir_fd: Optional[int] = ...) -> Iterator[Tuple[str, List[str], List[str], int]]: ... # Unix only def getxattr(path: _FdOrPathType, attribute: _PathType, *, follow_symlinks: bool = ...) -> bytes: ... # Linux only def listxattr(path: _FdOrPathType, *, follow_symlinks: bool = ...) -> List[str]: ... # Linux only def removexattr(path: _FdOrPathType, attribute: _PathType, *, follow_symlinks: bool = ...) -> None: ... # Linux only @@ -608,3 +632,6 @@ if sys.version_info >= (3, 6): def urandom(size: int) -> bytes: ... else: def urandom(n: int) -> bytes: ... + +if sys.version_info >= (3, 7): + def register_at_fork(func: Callable[..., object], when: str) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/posixpath.pyi b/python/helpers/typeshed/stdlib/3/posixpath.pyi index 7d8bb0948d92..05e0c2094257 100644 --- a/python/helpers/typeshed/stdlib/3/posixpath.pyi +++ b/python/helpers/typeshed/stdlib/3/posixpath.pyi @@ -2,7 +2,7 @@ # Ron Murawski # based on http://docs.python.org/3.2/library/os.path.html - +import sys from typing import Any, List, Tuple, IO # ----- os.path variables ----- @@ -43,4 +43,5 @@ def sameopenfile(fp1: IO[Any], fp2: IO[Any]) -> bool: ... def split(path: str) -> Tuple[str, str]: ... def splitdrive(path: str) -> Tuple[str, str]: ... def splitext(path: str) -> Tuple[str, str]: ... -# def splitunc(path: str) -> Tuple[str, str] : ... # Windows only, deprecated +if sys.version_info < (3, 7) and sys.platform == 'win32': + def splitunc(path: str) -> Tuple[str, str]: ... diff --git a/python/helpers/typeshed/stdlib/3/socketserver.pyi b/python/helpers/typeshed/stdlib/3/socketserver.pyi index 91f781ddb60e..ba23e0a036b9 100644 --- a/python/helpers/typeshed/stdlib/3/socketserver.pyi +++ b/python/helpers/typeshed/stdlib/3/socketserver.pyi @@ -1,6 +1,6 @@ # Stubs for socketserver -from typing import Any, BinaryIO, Optional, Tuple +from typing import Any, BinaryIO, Optional, Tuple, Type from socket import SocketType import sys import types @@ -35,8 +35,8 @@ class BaseServer: client_address: Tuple[str, int]) -> bool: ... if sys.version_info >= (3, 6): def __enter__(self) -> 'BaseServer': ... - def __exit__(self, exc_type: Optional[type], - exc_val: Optional[Exception], + def __exit__(self, exc_type: Optional[Type[BaseException]], + exc_val: Optional[BaseException], exc_tb: Optional[types.TracebackType]) -> bool: ... if sys.version_info >= (3, 3): def service_actions(self) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/sqlite3/__init__.pyi b/python/helpers/typeshed/stdlib/3/sqlite3/__init__.pyi deleted file mode 100644 index d5d20d67b58e..000000000000 --- a/python/helpers/typeshed/stdlib/3/sqlite3/__init__.pyi +++ /dev/null @@ -1 +0,0 @@ -from sqlite3.dbapi2 import * # noqa: F403 diff --git a/python/helpers/typeshed/stdlib/3/ssl.pyi b/python/helpers/typeshed/stdlib/3/ssl.pyi index 060bccdcd471..927547d4fe8e 100644 --- a/python/helpers/typeshed/stdlib/3/ssl.pyi +++ b/python/helpers/typeshed/stdlib/3/ssl.pyi @@ -207,7 +207,10 @@ class SSLContext: if sys.version_info >= (3, 4): verify_flags = ... # type: int verify_mode = ... # type: int - def __init__(self, protocol: int) -> None: ... + if sys.version_info >= (3, 5): + def __init__(self, protocol: int = ...) -> None: ... + else: + def __init__(self, protocol: int) -> None: ... if sys.version_info >= (3, 4): def cert_store_stats(self) -> Dict[str, int]: ... def load_cert_chain(self, certfile: str, keyfile: Optional[str] = ..., diff --git a/python/helpers/typeshed/stdlib/3/subprocess.pyi b/python/helpers/typeshed/stdlib/3/subprocess.pyi index 3705a8358e06..53944ea90603 100644 --- a/python/helpers/typeshed/stdlib/3/subprocess.pyi +++ b/python/helpers/typeshed/stdlib/3/subprocess.pyi @@ -371,4 +371,34 @@ def getoutput(cmd: _TXT) -> str: ... def list2cmdline(seq: Sequence[str]) -> str: ... # undocumented -# Windows-only: STARTUPINFO etc. +if sys.platform == 'win32': + class STARTUPINFO: + if sys.version_info >= (3, 7): + def __init__(self, *, dwFlags: int = ..., hStdInput: Optional[Any] = ..., hStdOutput: Optional[Any] = ..., hStdError: Optional[Any] = ..., wShowWindow: int = ..., lpAttributeList: Optional[Mapping[str, Any]] = ...) -> None: ... + dwFlags: int + hStdInput: Optional[Any] + hStdOutput: Optional[Any] + hStdError: Optional[Any] + wShowWindow: int + if sys.version_info >= (3, 7): + lpAttributeList: Mapping[str, Any] + + STD_INPUT_HANDLE: Any + STD_OUTPUT_HANDLE: Any + STD_ERROR_HANDLE: Any + SW_HIDE: int + STARTF_USESTDHANDLES: int + STARTF_USESHOWWINDOW: int + CREATE_NEW_CONSOLE: int + CREATE_NEW_PROCESS_GROUP: int + if sys.version_info >= (3, 7): + ABOVE_NORMAL_PRIORITY_CLASS: int + BELOW_NORMAL_PRIORITY_CLASS: int + HIGH_PRIORITY_CLASS: int + IDLE_PRIORITY_CLASS: int + NORMAL_PRIORITY_CLASS: int + REALTIME_PRIORITY_CLASS: int + CREATE_NO_WINDOW: int + DETACHED_PROCESS: int + CREATE_DEFAULT_ERROR_MODE: int + CREATE_BREAKAWAY_FROM_JOB: int diff --git a/python/helpers/typeshed/stdlib/3/sys.pyi b/python/helpers/typeshed/stdlib/3/sys.pyi index e50e93aa5b4d..0af8ea5ffa5e 100644 --- a/python/helpers/typeshed/stdlib/3/sys.pyi +++ b/python/helpers/typeshed/stdlib/3/sys.pyi @@ -15,6 +15,8 @@ _T = TypeVar('_T') # ----- sys variables ----- abiflags = ... # type: str argv = ... # type: List[str] +base_exec_prefix: str +base_prefix: str byteorder = ... # type: str builtin_module_names = ... # type: Sequence[str] # actually a tuple of strings copyright = ... # type: str @@ -72,6 +74,8 @@ class _flags: bytes_warning = 0 quiet = 0 hash_randomization = 0 + if sys.version_info >= (3, 7): + dev_mode: int float_info = ... # type: _float_info class _float_info: diff --git a/python/helpers/typeshed/stdlib/3/tkinter/ttk.pyi b/python/helpers/typeshed/stdlib/3/tkinter/ttk.pyi index 2ce9dc0c898e..b8073d0fe692 100644 --- a/python/helpers/typeshed/stdlib/3/tkinter/ttk.pyi +++ b/python/helpers/typeshed/stdlib/3/tkinter/ttk.pyi @@ -1,3 +1,4 @@ +import sys from typing import Any import tkinter @@ -105,6 +106,11 @@ class Separator(Widget): class Sizegrip(Widget): def __init__(self, master=None, **kw): ... +if sys.version_info >= (3, 7): + class Spinbox(Entry): + def __init__(self, master: Any = ..., **kw: Any) -> None: ... + def set(self, value: Any) -> None: ... + class Treeview(Widget, tkinter.XView, tkinter.YView): def __init__(self, master=None, **kw): ... def bbox(self, item, column=None): ... diff --git a/python/helpers/typeshed/stdlib/3/types.pyi b/python/helpers/typeshed/stdlib/3/types.pyi index 34ab3379ee3b..634ac39b0e2c 100644 --- a/python/helpers/typeshed/stdlib/3/types.pyi +++ b/python/helpers/typeshed/stdlib/3/types.pyi @@ -175,6 +175,9 @@ class FrameType: f_lineno = ... # type: int f_locals = ... # type: Dict[str, Any] f_trace = ... # type: Callable[[], None] + if sys.version_info >= (3, 7): + f_frace_lines: bool + f_trace_opcodes: bool def clear(self) -> None: ... diff --git a/python/helpers/typeshed/stdlib/3/unittest/__init__.pyi b/python/helpers/typeshed/stdlib/3/unittest/__init__.pyi index 81af43281f0d..febc718830ca 100644 --- a/python/helpers/typeshed/stdlib/3/unittest/__init__.pyi +++ b/python/helpers/typeshed/stdlib/3/unittest/__init__.pyi @@ -191,7 +191,7 @@ class FunctionTestCase(TestCase): class _AssertRaisesContext(Generic[_E]): exception = ... # type: _E def __enter__(self) -> _AssertRaisesContext[_E]: ... - def __exit__(self, exc_type: Optional[type], exc_val: Optional[Exception], + def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> bool: ... class _AssertWarnsContext: @@ -199,14 +199,14 @@ class _AssertWarnsContext: filename = ... # type: str lineno = ... # type: int def __enter__(self) -> _AssertWarnsContext: ... - def __exit__(self, exc_type: Optional[type], exc_val: Optional[Exception], + def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> bool: ... class _AssertLogsContext: records = ... # type: List[logging.LogRecord] output = ... # type: List[str] def __enter__(self) -> _AssertLogsContext: ... - def __exit__(self, exc_type: Optional[type], exc_val: Optional[Exception], + def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> bool: ... diff --git a/python/helpers/typeshed/stdlib/3/unittest/mock.pyi b/python/helpers/typeshed/stdlib/3/unittest/mock.pyi index 888d61c3d130..f4a91521e9d2 100644 --- a/python/helpers/typeshed/stdlib/3/unittest/mock.pyi +++ b/python/helpers/typeshed/stdlib/3/unittest/mock.pyi @@ -176,3 +176,6 @@ if sys.version_info >= (3, 3): class PropertyMock(Mock): def __get__(self, obj: Any, obj_type: Any) -> Any: ... def __set__(self, obj: Any, val: Any) -> Any: ... + +if sys.version_info >= (3, 7): + def seal(mock: Any) -> None: ... diff --git a/python/helpers/typeshed/tests/mypy_test.py b/python/helpers/typeshed/tests/mypy_test.py index a90667e039cd..cb042d83f830 100755 --- a/python/helpers/typeshed/tests/mypy_test.py +++ b/python/helpers/typeshed/tests/mypy_test.py @@ -131,6 +131,7 @@ def main(): runs += 1 flags = ['--python-version', '%d.%d' % (major, minor)] flags.append('--strict-optional') + flags.append('--no-site-packages') if args.no_implicit_optional: flags.append('--no-implicit-optional') if args.warn_unused_ignores: diff --git a/python/helpers/typeshed/third_party/2/enum.pyi b/python/helpers/typeshed/third_party/2/enum.pyi index 2bab1a883858..6fb5960e38c8 100644 --- a/python/helpers/typeshed/third_party/2/enum.pyi +++ b/python/helpers/typeshed/third_party/2/enum.pyi @@ -1,7 +1,7 @@ from typing import List, Any, TypeVar, Union, Iterable, Iterator, TypeVar, Generic, Type, Sized, Reversible, Container, Mapping from abc import ABCMeta -_T = TypeVar('_T', bound=Enum) +_T = TypeVar('_T') _S = TypeVar('_S', bound=Type[Enum]) # Note: EnumMeta actually subclasses type directly, not ABCMeta. diff --git a/python/helpers/typeshed/third_party/2/gflags.pyi b/python/helpers/typeshed/third_party/2/gflags.pyi index cdec93a95e12..4242e040b4c4 100644 --- a/python/helpers/typeshed/third_party/2/gflags.pyi +++ b/python/helpers/typeshed/third_party/2/gflags.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, Iterable, IO, List, Union +from typing import Any, Callable, Dict, Iterable, IO, List, Optional, Union from types import ModuleType class FlagsError(Exception): ... @@ -114,7 +114,7 @@ def DEFINE(parser: ArgumentParser, name: str, default: Any, help: str, def DEFINE_flag(flag: Flag, flag_values: FlagValues = ...) -> None: ... def DECLARE_key_flag(flag_name: str, flag_values: FlagValues = ...) -> None: ... def ADOPT_module_key_flags(module: ModuleType, flag_values: FlagValues = ...) -> None: ... -def DEFINE_string(name: str, default: str, help: str, flag_values: FlagValues = ..., **args: Any): ... +def DEFINE_string(name: str, default: Optional[str], help: str, flag_values: FlagValues = ..., **args: Any): ... class BooleanParser(ArgumentParser): def Convert(self, argument: Any) -> bool: ... diff --git a/python/helpers/typeshed/third_party/2/six/moves/__init__.pyi b/python/helpers/typeshed/third_party/2/six/moves/__init__.pyi index 574717245c60..f83d49178507 100644 --- a/python/helpers/typeshed/third_party/2/six/moves/__init__.pyi +++ b/python/helpers/typeshed/third_party/2/six/moves/__init__.pyi @@ -25,7 +25,7 @@ import __builtin__ as builtins import ConfigParser as configparser # import copy_reg as copyreg # import gdbm as dbm_gnu -# import dummy_thread as _dummy_thread +import dummy_thread as _dummy_thread import cookielib as http_cookiejar import Cookie as http_cookies import htmlentitydefs as html_entities @@ -62,5 +62,5 @@ import six.moves.urllib.parse as urllib_parse import six.moves.urllib.error as urllib_error import six.moves.urllib as urllib import robotparser as urllib_robotparser -# import xmlrpclib as xmlrpc_client +import xmlrpclib as xmlrpc_client # import SimpleXMLRPCServer as xmlrpc_server diff --git a/python/helpers/typeshed/third_party/2and3/boto/compat.pyi b/python/helpers/typeshed/third_party/2and3/boto/compat.pyi index b0534a42476d..ef4a7c6d5d2f 100644 --- a/python/helpers/typeshed/third_party/2and3/boto/compat.pyi +++ b/python/helpers/typeshed/third_party/2and3/boto/compat.pyi @@ -1,10 +1,17 @@ +import sys + from typing import Any from base64 import encodestring as encodebytes from six.moves import http_client expanduser = ... # type: Any -StandardError = ... # type: Any + +if sys.version_info >= (3, 0): + StandardError = Exception +else: + StandardError = __builtins__.StandardError + long_type = ... # type: Any unquote_str = ... # type: Any parse_qs_safe = ... # type: Any diff --git a/python/helpers/typeshed/third_party/2and3/requests/structures.pyi b/python/helpers/typeshed/third_party/2and3/requests/structures.pyi index 9956e9c5a714..92cf27aa1cd5 100644 --- a/python/helpers/typeshed/third_party/2and3/requests/structures.pyi +++ b/python/helpers/typeshed/third_party/2and3/requests/structures.pyi @@ -1,8 +1,9 @@ -from typing import Any, Iterator, MutableMapping, Tuple, TypeVar, Generic +from typing import Any, Dict, Iterable, Iterator, Mapping, MutableMapping, Optional, Tuple, TypeVar, Union, Generic _VT = TypeVar('_VT') class CaseInsensitiveDict(MutableMapping[str, _VT], Generic[_VT]): + def __init__(self, data: Optional[Union[Mapping[str, _VT], Iterable[Tuple[str, _VT]]]] = ..., **kwargs: _VT) -> None: ... def lower_items(self) -> Iterator[Tuple[str, _VT]]: ... def __setitem__(self, key: str, value: _VT) -> None: ... def __getitem__(self, key: str) -> _VT: ... @@ -10,8 +11,9 @@ class CaseInsensitiveDict(MutableMapping[str, _VT], Generic[_VT]): def __iter__(self) -> Iterator[str]: ... def __len__(self) -> int: ... -class LookupDict(dict): - name = ... # type: Any - def __init__(self, name=...) -> None: ... - def __getitem__(self, key): ... - def get(self, key, default=...): ... +class LookupDict(Dict[str, _VT]): + name: Any + def __init__(self, name: Any = ...) -> None: ... + def __getitem__(self, key: str) -> Optional[_VT]: ... # type: ignore + def __getattr__(self, attr: str) -> _VT: ... + def __setattr__(self, attr: str, value: _VT) -> None: ... diff --git a/python/helpers/typeshed/third_party/2and3/yaml/__init__.pyi b/python/helpers/typeshed/third_party/2and3/yaml/__init__.pyi index 9c6c197fe48d..4a5d2cda5a49 100644 --- a/python/helpers/typeshed/third_party/2and3/yaml/__init__.pyi +++ b/python/helpers/typeshed/third_party/2and3/yaml/__init__.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterator, Union, IO +from typing import Any, Iterator, Sequence, Union, IO from yaml.error import * # noqa: F403 from yaml.tokens import * # noqa: F403 from yaml.events import * # noqa: F403 @@ -22,10 +22,10 @@ def safe_load_all(stream: Union[str, IO[str]]) -> Iterator[Any]: ... def emit(events, stream=..., Dumper=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=...): ... def serialize_all(nodes, stream=..., Dumper=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=...): ... def serialize(node, stream=..., Dumper=..., **kwds): ... -def dump_all(documents, stream=..., Dumper=..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=...): ... -def dump(data, stream=..., Dumper=..., **kwds): ... -def safe_dump_all(documents, stream=..., **kwds): ... -def safe_dump(data, stream=..., **kwds): ... +def dump_all(documents: Sequence[Any], stream: IO[str]=..., Dumper=..., default_style=..., default_flow_style=..., canonical=..., indent=..., width=..., allow_unicode=..., line_break=..., encoding=..., explicit_start=..., explicit_end=..., version=..., tags=...) -> Any: ... +def dump(data: Any, stream: IO[str]=..., Dumper=..., **kwds) -> Any: ... +def safe_dump_all(documents: Sequence[Any], stream: IO[str]=..., **kwds) -> Any: ... +def safe_dump(data: Any, stream: IO[str]=..., **kwds) -> Any: ... def add_implicit_resolver(tag, regexp, first=..., Loader=..., Dumper=...): ... def add_path_resolver(tag, path, kind=..., Loader=..., Dumper=...): ... def add_constructor(tag, constructor, Loader=...): ... diff --git a/python/helpers/typeshed/third_party/3/itsdangerous.pyi b/python/helpers/typeshed/third_party/3/itsdangerous.pyi index 445c998b353d..96d7ccfee7b4 100644 --- a/python/helpers/typeshed/third_party/3/itsdangerous.pyi +++ b/python/helpers/typeshed/third_party/3/itsdangerous.pyi @@ -1,7 +1,7 @@ from datetime import datetime from typing import Any, Callable, IO, MutableMapping, Optional, Text, Tuple, TypeVar, Union -PY2 = ... # type: bool +PY2: bool text_type = str int_to_byte = Callable[[int], bytes] number_types = (int, float) @@ -82,7 +82,7 @@ class Signer: def get_signature(self, value: _bytes_like) -> bytes: ... def sign(self, value: _bytes_like) -> bytes: ... def verify_signature(self, value: _bytes_like, sig: _can_become_bytes) -> bool: ... - def unsign(self, signed_value: _can_become_bytes) -> str: ... + def unsign(self, signed_value: _bytes_like) -> bytes: ... def validate(self, signed_value: _can_become_bytes) -> bool: ... class TimestampSigner(Signer): diff --git a/python/helpers/typeshed/third_party/3/six/moves/__init__.pyi b/python/helpers/typeshed/third_party/3/six/moves/__init__.pyi index 744c95dd455f..4afc91def004 100644 --- a/python/helpers/typeshed/third_party/3/six/moves/__init__.pyi +++ b/python/helpers/typeshed/third_party/3/six/moves/__init__.pyi @@ -41,7 +41,7 @@ import http.server as CGIHTTPServer import http.server as SimpleHTTPServer import pickle as cPickle import queue as queue -# import reprlib as reprlib +import reprlib as reprlib import socketserver as socketserver import _thread as _thread import tkinter as tkinter