Sync with typeshed @ d854d7e2a08b3aaf2192609f641d6c16dfd77d6c

This commit is contained in:
Semyon Proshev
2018-05-07 21:57:30 +03:00
parent fe6f9e6187
commit 9eaf835b52
19 changed files with 343 additions and 183 deletions
@@ -3,6 +3,7 @@
# True and False are deliberately omitted because they are keywords in
# Python 3, and stub files conform to Python 3 syntax.
from abc import ABCMeta
from typing import (
TypeVar, Iterator, Iterable, NoReturn, overload,
Sequence, Mapping, Tuple, List, Any, Dict, Callable, Generic, Set,
@@ -10,7 +11,6 @@ from typing import (
SupportsComplex, SupportsRound, IO, BinaryIO, Union, AnyStr, MutableSequence, MutableMapping,
MutableSet, ItemsView, KeysView, ValuesView, Optional, Container, Type
)
from abc import abstractmethod, ABCMeta
_T = TypeVar('_T')
_T_co = TypeVar('_T_co', covariant=True)
@@ -1012,8 +1012,22 @@ class SystemError(StandardError): ...
class TypeError(StandardError): ...
class UnboundLocalError(NameError): ...
class UnicodeError(ValueError): ...
class UnicodeDecodeError(UnicodeError): ...
class UnicodeEncodeError(UnicodeError): ...
class UnicodeDecodeError(UnicodeError):
encoding: bytes
object: bytes
start: int
end: int
reason: bytes
def __init__(self, __encoding: bytes, __object: bytes, __start: int, __end: int,
__reason: bytes) -> None: ...
class UnicodeEncodeError(UnicodeError):
encoding: bytes
object: unicode
start: int
end: int
reason: bytes
def __init__(self, __encoding: bytes, __object: unicode, __start: int, __end: int,
__reason: bytes) -> None: ...
class UnicodeTranslateError(UnicodeError): ...
class ZeroDivisionError(ArithmeticError): ...
@@ -1,10 +1,10 @@
# Stubs for argparse (Python 2.7 and 3.4)
import sys
from typing import (
Any, Callable, Dict, Generator, Iterable, List, IO, NoReturn, Optional,
Pattern, Sequence, Tuple, Type, Union, TypeVar, overload
Pattern, Sequence, Tuple, Type, Union, TypeVar
)
import sys
_T = TypeVar('_T')
_ActionT = TypeVar('_ActionT', bound='Action')
@@ -138,8 +138,8 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
def parse_known_args(self, args: Optional[Sequence[_Text]] = ...,
namespace: Optional[Namespace] = ...) -> Tuple[Namespace, List[str]]: ...
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: ...
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[_Text]] = ...,
namespace: Optional[Namespace] = ...) -> Namespace: ...
@@ -1,14 +1,13 @@
# Based on https://docs.python.org/2.7/library/difflib.html and https://docs.python.org/3.2/library/difflib.html
# TODO: Support unicode in Python 2?
import sys
from typing import (
TypeVar, Callable, Iterable, Iterator, List, NamedTuple, Sequence, Tuple,
Generic, Optional
Generic, Optional, Text, Union
)
_T = TypeVar('_T')
_JunkCallback = Union[Callable[[Text], bool], Callable[[str], bool]]
Match = NamedTuple('Match', [
('a', int),
@@ -37,36 +36,35 @@ def get_close_matches(word: Sequence[_T], possibilities: Iterable[Sequence[_T]],
n: int = ..., cutoff: float = ...) -> List[Sequence[_T]]: ...
class Differ:
def __init__(self, linejunk: Callable[[str], bool] = ...,
charjunk: Callable[[str], bool] = ...) -> None: ...
def compare(self, a: Sequence[str], b: Sequence[str]) -> Iterator[str]: ...
def __init__(self, linejunk: _JunkCallback = ..., charjunk: _JunkCallback = ...) -> None: ...
def compare(self, a: Sequence[Text], b: Sequence[Text]) -> Iterator[Text]: ...
def IS_LINE_JUNK(str) -> bool: ...
def IS_CHARACTER_JUNK(str) -> bool: ...
def unified_diff(a: Sequence[str], b: Sequence[str], fromfile: str = ...,
tofile: str = ..., fromfiledate: str = ..., tofiledate: str = ...,
n: int = ..., lineterm: str = ...) -> Iterator[str]: ...
def context_diff(a: Sequence[str], b: Sequence[str], fromfile: str=...,
tofile: str = ..., fromfiledate: str = ..., tofiledate: str = ...,
n: int = ..., lineterm: str = ...) -> Iterator[str]: ...
def ndiff(a: Sequence[str], b: Sequence[str],
linejunk: Callable[[str], bool] = ...,
charjunk: Callable[[str], bool] = ...
) -> Iterator[str]: ...
def IS_LINE_JUNK(line: Text) -> bool: ...
def IS_CHARACTER_JUNK(line: Text) -> bool: ...
def unified_diff(a: Sequence[Text], b: Sequence[Text], fromfile: Text = ...,
tofile: Text = ..., fromfiledate: Text = ..., tofiledate: Text = ...,
n: int = ..., lineterm: Text = ...) -> Iterator[Text]: ...
def context_diff(a: Sequence[Text], b: Sequence[Text], fromfile: Text=...,
tofile: Text = ..., fromfiledate: Text = ..., tofiledate: Text = ...,
n: int = ..., lineterm: Text = ...) -> Iterator[Text]: ...
def ndiff(a: Sequence[Text], b: Sequence[Text],
linejunk: _JunkCallback = ...,
charjunk: _JunkCallback = ...
) -> Iterator[Text]: ...
class HtmlDiff(object):
def __init__(self, tabsize: int = ..., wrapcolumn: int = ...,
linejunk: Callable[[str], bool] = ...,
charjunk: Callable[[str], bool] = ...
linejunk: _JunkCallback = ...,
charjunk: _JunkCallback = ...
) -> None: ...
def make_file(self, fromlines: Sequence[str], tolines: Sequence[str],
fromdesc: str = ..., todesc: str = ..., context: bool = ...,
numlines: int = ...) -> str: ...
def make_table(self, fromlines: Sequence[str], tolines: Sequence[str],
fromdesc: str = ..., todesc: str = ..., context: bool = ...,
numlines: int = ...) -> str: ...
def make_file(self, fromlines: Sequence[Text], tolines: Sequence[Text],
fromdesc: Text = ..., todesc: Text = ..., context: bool = ...,
numlines: int = ...) -> Text: ...
def make_table(self, fromlines: Sequence[Text], tolines: Sequence[Text],
fromdesc: Text = ..., todesc: Text = ..., context: bool = ...,
numlines: int = ...) -> Text: ...
def restore(delta: Iterable[str], which: int) -> Iterator[int]: ...
def restore(delta: Iterable[Text], which: int) -> Iterator[Text]: ...
if sys.version_info >= (3, 5):
def diff_bytes(
@@ -1,8 +1,8 @@
# Stubs for locale
from decimal import Decimal
from typing import Any, Iterable, List, Mapping, Optional, Sequence, Tuple, Union
import sys
from decimal import Decimal
from typing import Any, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, Union
# workaround for mypy#2010
if sys.version_info < (3,):
@@ -107,3 +107,6 @@ if sys.version_info >= (3, 5):
def atof(string: _str) -> float: ...
def atoi(string: _str) -> int: ...
def str(float: float) -> _str: ...
locale_alias: Dict[_str, _str] # undocumented
locale_encoding_alias: Dict[_str, _str] # undocumented
@@ -0,0 +1,19 @@
from typing import Dict, List, Optional, Tuple
class NetrcParseError(Exception):
filename: Optional[str]
lineno: Optional[int]
msg: str
# (login, account, password) tuple
_NetrcTuple = Tuple[str, Optional[str], Optional[str]]
class netrc:
hosts: Dict[str, _NetrcTuple]
macros: Dict[str, List[str]]
def __init__(self, file: str = ...) -> None: ...
def authenticators(self, host: str) -> Optional[_NetrcTuple]: ...
@@ -2,8 +2,8 @@
# based heavily on Andrey Vlasovskikh's python-skeletons https://github.com/JetBrains/python-skeletons/blob/master/sqlite3.py
import sys
from typing import Any, Callable, Iterable, Iterator, List, Optional, Text, Tuple, Type, TypeVar, Union
from datetime import date, time, datetime
from typing import Any, Callable, Iterable, Iterator, List, Optional, Text, Tuple, Type, TypeVar, Union
_T = TypeVar('_T')
@@ -20,7 +20,10 @@ def TimestampFromTicks(ticks): ...
version_info: str
sqlite_version_info: Tuple[int, int, int]
Binary: Type[Any]
if sys.version_info >= (3,):
Binary = memoryview
else:
Binary = buffer
def register_adapters_and_converters(): ...
@@ -1,11 +1,11 @@
# Stubs for threading
import sys
from types import FrameType, TracebackType
from typing import (
Any, Callable, Iterable, List, Mapping, Optional, Tuple, Type, Union,
Any, Callable, Iterable, List, Mapping, Optional, Type, Union,
TypeVar,
)
from types import FrameType, TracebackType
import sys
# TODO recursive type
_TF = Callable[[FrameType, str, Any], Optional[Callable[..., Any]]]
@@ -40,10 +40,10 @@ if sys.version_info >= (3,):
class ThreadError(Exception): ...
# TODO: Change to a class with __getattr__ and __setattr__
# once mypy supports universal __setattr__.
# See https://github.com/python/mypy/issues/521
local = ... # type: Any
class local(object):
def __getattribute__(self, name: str) -> Any: ...
def __setattr__(self, name: str, value: Any) -> None: ...
def __delattr__(self, name: str) -> None: ...
class Thread:
@@ -5,46 +5,29 @@
# These are not exported.
import sys
import typing
from typing import (
TypeVar, Generic, Dict, overload, List, Tuple,
Any, Type, Optional, Union
)
# These are exported.
from . import abc
from typing import (
Callable as Callable,
Container as Container,
Hashable as Hashable,
Iterable as Iterable,
Iterator as Iterator,
Sized as Sized,
Generator as Generator,
ByteString as ByteString,
Reversible as Reversible,
Mapping as Mapping,
MappingView as MappingView,
ItemsView as ItemsView,
KeysView as KeysView,
ValuesView as ValuesView,
MutableMapping as MutableMapping,
Sequence as Sequence,
MutableSequence as MutableSequence,
MutableSet as MutableSet,
AbstractSet as Set,
)
from typing import (
TypeVar, Generic, Dict, overload, List, Tuple,
Any, Type, Optional, Union
)
# These are exported.
if sys.version_info >= (3, 6):
from typing import (
Collection as Collection,
AsyncGenerator as AsyncGenerator,
)
pass
if sys.version_info >= (3, 5):
from typing import (
Awaitable as Awaitable,
Coroutine as Coroutine,
AsyncIterable as AsyncIterable,
AsyncIterator as AsyncIterator,
)
pass
_T = TypeVar('_T')
_KT = TypeVar('_KT')
@@ -65,7 +48,8 @@ else:
_UserDictT = TypeVar('_UserDictT', bound=UserDict)
class UserDict(MutableMapping[_KT, _VT]):
data = ... # type: Mapping[_KT, _VT]
data: Mapping[_KT, _VT]
def __init__(self, dict: Optional[Mapping[_KT, _VT]] = ..., **kwargs: _VT) -> None: ...
def __len__(self) -> int: ...
def __getitem__(self, key: _KT) -> _VT: ...
def __setitem__(self, key: _KT, item: _VT) -> None: ...
@@ -285,11 +269,18 @@ class Counter(Dict[_T, int], Generic[_T]):
_OrderedDictT = TypeVar('_OrderedDictT', bound=OrderedDict)
class _OrderedDictKeysView(KeysView[_KT], Reversible[_KT]): ...
class _OrderedDictItemsView(ItemsView[_KT, _VT], Reversible[Tuple[_KT, _VT]]): ...
class _OrderedDictValuesView(ValuesView[_VT], Reversible[_VT]): ...
class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):
def popitem(self, last: bool = ...) -> Tuple[_KT, _VT]: ...
def move_to_end(self, key: _KT, last: bool = ...) -> None: ...
def copy(self: _OrderedDictT) -> _OrderedDictT: ...
def __reversed__(self) -> Iterator[_KT]: ...
def keys(self) -> _OrderedDictKeysView[_KT]: ...
def items(self) -> _OrderedDictItemsView[_KT, _VT]: ...
def values(self) -> _OrderedDictValuesView[_VT]: ...
_DefaultDictT = TypeVar('_DefaultDictT', bound=defaultdict)
+108 -80
View File
@@ -3,114 +3,127 @@
# based on http://docs.python.org/3.2/library/sys.html
import sys
from types import FrameType, ModuleType, TracebackType
from typing import (
List, NoReturn, Sequence, Any, Dict, Tuple, TextIO, overload, Optional,
Union, TypeVar, Callable, Type,
TypeVar, Callable, Type
)
import sys
from types import FrameType, TracebackType
if sys.version_info >= (3, 3):
from importlib.abc import MetaPathFinder
else:
MetaPathFinder = Any
_T = TypeVar('_T')
# ----- sys variables -----
abiflags = ... # type: str
argv = ... # type: List[str]
abiflags: str
argv: 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
byteorder: str
builtin_module_names: Sequence[str] # actually a tuple of strings
copyright: str
# dllhandle = 0 # Windows only
dont_write_bytecode: bool
__displayhook__ = ... # type: Any # contains the original value of displayhook
__excepthook__ = ... # type: Any # contains the original value of excepthook
exec_prefix = ... # type: str
executable = ... # type: str
float_repr_style = ... # type: str
__displayhook__: Any # contains the original value of displayhook
__excepthook__: Any # contains the original value of excepthook
exec_prefix: str
executable: str
float_repr_style: str
hexversion: int
last_type = ... # type: Any
last_value = ... # type: Any
last_traceback = ... # type: Any
last_type: Optional[Type[BaseException]]
last_value: Optional[BaseException]
last_traceback: Optional[TracebackType]
maxsize: int
maxunicode: int
meta_path = ... # type: List[Any]
modules = ... # type: Dict[str, Any]
path = ... # type: List[str]
path_hooks = ... # type: List[Any] # TODO precise type; function, path to finder
path_importer_cache = ... # type: Dict[str, Any] # TODO precise type
platform = ... # type: str
prefix = ... # type: str
ps1 = ... # type: str
ps2 = ... # type: str
stdin = ... # type: TextIO
stdout = ... # type: TextIO
stderr = ... # type: TextIO
__stdin__ = ... # type: TextIO
__stdout__ = ... # type: TextIO
__stderr__ = ... # type: TextIO
meta_path: List[MetaPathFinder]
modules: Dict[str, ModuleType]
path: List[str]
path_hooks: List[Any] # TODO precise type; function, path to finder
path_importer_cache: Dict[str, Any] # TODO precise type
platform: str
prefix: str
ps1: str
ps2: str
stdin: TextIO
stdout: TextIO
stderr: TextIO
__stdin__: TextIO
__stdout__: TextIO
__stderr__: TextIO
# deprecated and removed in Python 3.3:
subversion = ... # type: Tuple[str, str, str]
tracebacklimit = 0
version = ... # type: str
api_version = 0
warnoptions = ... # type: Any
subversion: Tuple[str, str, str]
tracebacklimit: int
version: str
api_version: int
warnoptions: Any
# Each entry is a tuple of the form (action, message, category, module,
# lineno)
# winver = '' # Windows only
_xoptions = ... # type: Dict[Any, Any]
_xoptions: Dict[Any, Any]
flags = ... # type: _flags
flags: _flags
class _flags:
debug = 0
division_warning = 0
inspect = 0
interactive = 0
optimize = 0
dont_write_bytecode = 0
no_user_site = 0
no_site = 0
ignore_environment = 0
verbose = 0
bytes_warning = 0
quiet = 0
hash_randomization = 0
debug: int
division_warning: int
inspect: int
interactive: int
optimize: int
dont_write_bytecode: int
no_user_site: int
no_site: int
ignore_environment: int
verbose: int
bytes_warning: int
quiet: int
hash_randomization: int
if sys.version_info >= (3, 7):
dev_mode: int
float_info = ... # type: _float_info
float_info: _float_info
class _float_info:
epsilon = 0.0 # DBL_EPSILON
dig = 0 # DBL_DIG
mant_dig = 0 # DBL_MANT_DIG
max = 0.0 # DBL_MAX
max_exp = 0 # DBL_MAX_EXP
max_10_exp = 0 # DBL_MAX_10_EXP
min = 0.0 # DBL_MIN
min_exp = 0 # DBL_MIN_EXP
min_10_exp = 0 # DBL_MIN_10_EXP
radix = 0 # FLT_RADIX
rounds = 0 # FLT_ROUNDS
epsilon: float # DBL_EPSILON
dig: int # DBL_DIG
mant_dig: int # DBL_MANT_DIG
max: float # DBL_MAX
max_exp: int # DBL_MAX_EXP
max_10_exp: int # DBL_MAX_10_EXP
min: float # DBL_MIN
min_exp: int # DBL_MIN_EXP
min_10_exp: int # DBL_MIN_10_EXP
radix: int # FLT_RADIX
rounds: int # FLT_ROUNDS
hash_info = ... # type: _hash_info
hash_info: _hash_info
class _hash_info:
width = 0
modulus = 0
inf = 0
nan = 0
imag = 0
width: int
modulus: int
inf: int
nan: int
imag: int
int_info = ... # type: _int_info
implementation: _implementation
class _implementation:
name: str
version: _version_info
hexversion: int
cache_tag: str
int_info: _int_info
class _int_info:
bits_per_digit = 0
sizeof_digit = 0
bits_per_digit: int
sizeof_digit: int
class _version_info(Tuple[int, int, int, str, int]):
major = 0
minor = 0
micro = 0
releaselevel = ... # type: str
serial = 0
version_info = ... # type: _version_info
major: int
minor: int
micro: int
releaselevel: str
serial: int
version_info: _version_info
def call_tracing(fn: Callable[..., _T], args: Any) -> _T: ...
def _clear_type_cache() -> None: ...
@@ -118,7 +131,6 @@ def _current_frames() -> Dict[int, Any]: ...
def displayhook(value: Optional[int]) -> None: ...
def excepthook(type_: Type[BaseException], value: BaseException,
traceback: TracebackType) -> None: ...
# TODO should be a union of tuple, see mypy#1178
def exc_info() -> Tuple[Optional[Type[BaseException]],
Optional[BaseException],
Optional[TracebackType]]: ...
@@ -152,7 +164,23 @@ _TraceFunc = Callable[[FrameType, str, Any], Optional[Callable[[FrameType, str,
def gettrace() -> Optional[_TraceFunc]: ...
def settrace(tracefunc: _TraceFunc) -> None: ...
def getwindowsversion() -> Any: ... # Windows only, TODO return type
class _WinVersion(Tuple[int, int, int, int,
str, int, int, int, int,
Tuple[int, int, int]]):
major: int
minor: int
build: int
platform: int
service_pack: str
service_pack_minor: int
service_pack_major: int
suite_mast: int
product_type: int
platform_version: Tuple[int, int, int]
def getwindowsversion() -> _WinVersion: ... # Windows only
def intern(string: str) -> str: ...
if sys.version_info >= (3, 5):
@@ -0,0 +1,8 @@
from typing import Any, Mapping, Optional
class Dialog:
command: Optional[Any] = ...
master: Optional[Any] = ...
options: Mapping[str, Any] = ...
def __init__(self, master: Optional[Any] = ..., **options) -> None: ...
def show(self, **options) -> Any: ...
@@ -0,0 +1,10 @@
from tkinter import Widget
from typing import Any, Mapping, Optional
DIALOG_ICON: str
class Dialog(Widget):
widgetName: str = ...
num: int = ...
def __init__(self, master: Optional[Any] = ..., cnf: Mapping[str, Any] = ..., **kw) -> None: ...
def destroy(self) -> None: ...
@@ -0,0 +1,65 @@
from tkinter import Button, commondialog, Entry, Frame, Listbox, Scrollbar, Toplevel
from typing import Any, Dict, Optional, Tuple
dialogstates: Dict[Any, Tuple[Any, Any]]
class FileDialog:
title: str = ...
master: Any = ...
directory: Optional[Any] = ...
top: Toplevel = ...
botframe: Frame = ...
selection: Entry = ...
filter: Entry = ...
midframe: Entry = ...
filesbar: Scrollbar = ...
files: Listbox = ...
dirsbar: Scrollbar = ...
dirs: Listbox = ...
ok_button: Button = ...
filter_button: Button = ...
cancel_button: Button = ...
def __init__(self, master, title: Optional[Any] = ...) -> None: ... # title is usually a str or None, but e.g. int doesn't raise en exception either
how: Optional[Any] = ...
def go(self, dir_or_file: Any = ..., pattern: str = ..., default: str = ..., key: Optional[Any] = ...): ...
def quit(self, how: Optional[Any] = ...) -> None: ...
def dirs_double_event(self, event) -> None: ...
def dirs_select_event(self, event) -> None: ...
def files_double_event(self, event) -> None: ...
def files_select_event(self, event) -> None: ...
def ok_event(self, event) -> None: ...
def ok_command(self) -> None: ...
def filter_command(self, event: Optional[Any] = ...) -> None: ...
def get_filter(self): ...
def get_selection(self): ...
def cancel_command(self, event: Optional[Any] = ...) -> None: ...
def set_filter(self, dir, pat) -> None: ...
def set_selection(self, file) -> None: ...
class LoadFileDialog(FileDialog):
title: str = ...
def ok_command(self) -> None: ...
class SaveFileDialog(FileDialog):
title: str = ...
def ok_command(self): ...
class _Dialog(commondialog.Dialog): ...
class Open(_Dialog):
command: str = ...
class SaveAs(_Dialog):
command: str = ...
class Directory(commondialog.Dialog):
command: str = ...
def askopenfilename(**options): ...
def asksaveasfilename(**options): ...
def askopenfilenames(**options): ...
def askopenfile(mode: str = ..., **options): ...
def askopenfiles(mode: str = ..., **options): ...
def asksaveasfile(mode: str = ..., **options): ...
def askdirectory(**options): ...
def test() -> None: ...
+7 -6
View File
@@ -4,15 +4,14 @@
# TODO parts of this should be conditional on version
import sys
# ModuleType is exported from this module, but for circular import
# reasons exists in its own stub file (with ModuleSpec and Loader).
from _importlib_modulespec import ModuleType as ModuleType # Exported
from typing import (
Any, Awaitable, Callable, Dict, Generic, Iterator, Mapping, Optional, Tuple, TypeVar,
Union, overload, Type
)
# ModuleType is exported from this module, but for circular import
# reasons exists in its own stub file (with ModuleSpec and Loader).
from _importlib_modulespec import ModuleType as ModuleType # Exported
_T = TypeVar('_T')
_T_co = TypeVar('_T_co', covariant=True)
_T_contra = TypeVar('_T_contra', contravariant=True)
@@ -78,8 +77,10 @@ class MappingProxyType(Mapping[_KT, _VT], Generic[_KT, _VT]):
def __iter__(self) -> Iterator[_KT]: ...
def __len__(self) -> int: ...
# TODO: use __getattr__ and __setattr__ instead of inheriting from Any, pending mypy#521.
class SimpleNamespace(Any): ... # type: ignore
class SimpleNamespace:
def __getattribute__(self, name: str) -> Any: ...
def __setattr__(self, name: str, value: Any) -> None: ...
def __delattr__(self, name: str) -> None: ...
class GeneratorType:
gi_code = ... # type: CodeType
@@ -2,6 +2,7 @@ from typing import Any
from .message import Message
class Error(Exception): ...
class TypeTransformationError(Error): ...
@@ -82,7 +83,7 @@ class FieldDescriptor(DescriptorBase):
MAX_FIELD_NUMBER = ... # type: Any
FIRST_RESERVED_FIELD_NUMBER = ... # type: Any
LAST_RESERVED_FIELD_NUMBER = ... # type: Any
def __new__(cls, name, full_name, index, number, type, cpp_type, label, default_value, message_type, enum_type, containing_type, is_extension, extension_scope, options=..., has_default_value=..., containing_oneof=...): ...
def __new__(cls, name, full_name, index, number, type, cpp_type, label, default_value, message_type, enum_type, containing_type, is_extension, extension_scope, options=..., file=..., has_default_value=..., containing_oneof=...): ...
name = ... # type: Any
full_name = ... # type: Any
index = ... # type: Any
@@ -98,7 +99,7 @@ class FieldDescriptor(DescriptorBase):
is_extension = ... # type: Any
extension_scope = ... # type: Any
containing_oneof = ... # type: Any
def __init__(self, name, full_name, index, number, type, cpp_type, label, default_value, message_type, enum_type, containing_type, is_extension, extension_scope, options=..., has_default_value=..., containing_oneof=...) -> None: ...
def __init__(self, name, full_name, index, number, type, cpp_type, label, default_value, message_type, enum_type, containing_type, is_extension, extension_scope, options=..., file=..., has_default_value=..., containing_oneof=...) -> None: ...
@staticmethod
def ProtoTypeToCppProtoType(proto_type): ...
+40 -19
View File
@@ -1,9 +1,5 @@
from typing import Any, Callable, Dict, Generic, List, Optional, Sequence, Mapping, Tuple, Type, TypeVar, Union, overload
# `import X as X` is required to make these public
from . import exceptions as exceptions
from . import filters as filters
from . import converters as converters
from . import validators as validators
_T = TypeVar('_T')
_C = TypeVar('_C', bound=type)
@@ -21,11 +17,11 @@ _ValidatorArgType = Union[_ValidatorType[_T], Sequence[_ValidatorType[_T]]]
NOTHING: object
# NOTE: Factory lies about its return type to make this possible: `x: List[int] = Factory(list)`
# Work around mypy issue #4554 by using an overload vs a Union.
# Work around mypy issue #4554 in the common case by using an overload.
@overload
def Factory(factory: Callable[[], _T], takes_self: bool = ...) -> _T: ...
def Factory(factory: Callable[[], _T]) -> _T: ...
@overload
def Factory(factory: Callable[[Any], _T], takes_self: bool = ...) -> _T: ...
def Factory(factory: Union[Callable[[Any], _T], Callable[[], _T]], takes_self: bool = ...) -> _T: ...
class Attribute(Generic[_T]):
name: str
@@ -81,7 +77,9 @@ def attrib(default: None = ...,
convert: Optional[_ConverterType[_T]] = ...,
metadata: Optional[Mapping[Any, Any]] = ...,
type: Optional[Type[_T]] = ...,
converter: Optional[_ConverterType[_T]] = ...) -> _T: ...
converter: Optional[_ConverterType[_T]] = ...,
factory: Optional[Callable[[], _T]] = ...,
) -> _T: ...
# This form catches an explicit default argument.
@overload
def attrib(default: _T,
@@ -93,7 +91,9 @@ def attrib(default: _T,
convert: Optional[_ConverterType[_T]] = ...,
metadata: Optional[Mapping[Any, Any]] = ...,
type: Optional[Type[_T]] = ...,
converter: Optional[_ConverterType[_T]] = ...) -> _T: ...
converter: Optional[_ConverterType[_T]] = ...,
factory: Optional[Callable[[], _T]] = ...,
) -> _T: ...
# This form catches explicit None or no default but with no other arguments returns Any.
@overload
def attrib(default: None = ...,
@@ -105,7 +105,9 @@ def attrib(default: None = ...,
convert: None = ...,
metadata: Optional[Mapping[Any, Any]] = ...,
type: None = ...,
converter: None = ...) -> Any: ...
converter: None = ...,
factory: None = ...,
) -> Any: ...
# This form covers type=non-Type: e.g. forward references (str), Any
@overload
def attrib(default: Optional[_T] = ...,
@@ -117,7 +119,9 @@ def attrib(default: Optional[_T] = ...,
convert: Optional[_ConverterType[_T]] = ...,
metadata: Optional[Mapping[Any, Any]] = ...,
type: object = ...,
converter: Optional[_ConverterType[_T]] = ...) -> Any: ...
converter: Optional[_ConverterType[_T]] = ...,
factory: Optional[Callable[[], _T]] = ...,
) -> Any: ...
# NOTE: If you update these, update `s` and `attributes` below.
@@ -152,6 +156,7 @@ class _Fields(Tuple[Attribute, ...]):
def __getattr__(self, name: str) -> Attribute: ...
def fields(cls: type) -> _Fields: ...
def fields_dict(cls: type) -> Dict[str, Attribute]: ...
def validate(inst: Any) -> None: ...
# TODO: add support for returning a proper attrs class from the mypy plugin
@@ -217,7 +222,9 @@ def ib(default: None = ...,
convert: Optional[_ConverterType[_T]] = ...,
metadata: Optional[Mapping[Any, Any]] = ...,
type: Optional[Type[_T]] = ...,
converter: Optional[_ConverterType[_T]] = ...) -> _T: ...
converter: Optional[_ConverterType[_T]] = ...,
factory: Optional[Callable[[], _T]] = ...,
) -> _T: ...
@overload
def ib(default: _T,
validator: Optional[_ValidatorArgType[_T]] = ...,
@@ -228,7 +235,9 @@ def ib(default: _T,
convert: Optional[_ConverterType[_T]] = ...,
metadata: Optional[Mapping[Any, Any]] = ...,
type: Optional[Type[_T]] = ...,
converter: Optional[_ConverterType[_T]] = ...) -> _T: ...
converter: Optional[_ConverterType[_T]] = ...,
factory: Optional[Callable[[], _T]] = ...,
) -> _T: ...
@overload
def ib(default: None = ...,
validator: None = ...,
@@ -239,7 +248,9 @@ def ib(default: None = ...,
convert: None = ...,
metadata: Optional[Mapping[Any, Any]] = ...,
type: None = ...,
converter: None = ...) -> Any: ...
converter: None = ...,
factory: None = ...,
) -> Any: ...
@overload
def ib(default: Optional[_T] = ...,
validator: Optional[_ValidatorArgType[_T]] = ...,
@@ -250,7 +261,9 @@ def ib(default: Optional[_T] = ...,
convert: Optional[_ConverterType[_T]] = ...,
metadata: Optional[Mapping[Any, Any]] = ...,
type: object = ...,
converter: Optional[_ConverterType[_T]] = ...) -> Any: ...
converter: Optional[_ConverterType[_T]] = ...,
factory: Optional[Callable[[], _T]] = ...,
) -> Any: ...
@overload
def attr(default: None = ...,
@@ -262,7 +275,9 @@ def attr(default: None = ...,
convert: Optional[_ConverterType[_T]] = ...,
metadata: Optional[Mapping[Any, Any]] = ...,
type: Optional[Type[_T]] = ...,
converter: Optional[_ConverterType[_T]] = ...) -> _T: ...
converter: Optional[_ConverterType[_T]] = ...,
factory: Optional[Callable[[], _T]] = ...,
) -> _T: ...
@overload
def attr(default: _T,
validator: Optional[_ValidatorArgType[_T]] = ...,
@@ -273,7 +288,9 @@ def attr(default: _T,
convert: Optional[_ConverterType[_T]] = ...,
metadata: Optional[Mapping[Any, Any]] = ...,
type: Optional[Type[_T]] = ...,
converter: Optional[_ConverterType[_T]] = ...) -> _T: ...
converter: Optional[_ConverterType[_T]] = ...,
factory: Optional[Callable[[], _T]] = ...,
) -> _T: ...
@overload
def attr(default: None = ...,
validator: None = ...,
@@ -284,7 +301,9 @@ def attr(default: None = ...,
convert: None = ...,
metadata: Optional[Mapping[Any, Any]] = ...,
type: None = ...,
converter: None = ...) -> Any: ...
converter: None = ...,
factory: None = ...,
) -> Any: ...
@overload
def attr(default: Optional[_T] = ...,
validator: Optional[_ValidatorArgType[_T]] = ...,
@@ -295,7 +314,9 @@ def attr(default: Optional[_T] = ...,
convert: Optional[_ConverterType[_T]] = ...,
metadata: Optional[Mapping[Any, Any]] = ...,
type: object = ...,
converter: Optional[_ConverterType[_T]] = ...) -> Any: ...
converter: Optional[_ConverterType[_T]] = ...,
factory: Optional[Callable[[], _T]] = ...,
) -> Any: ...
@overload
def attributes(maybe_cls: _C,
@@ -1,8 +1,5 @@
from typing import Any, IO, Text
from simplejson.scanner import JSONDecodeError as JSONDecodeError
from simplejson.decoder import JSONDecoder as JSONDecoder
from simplejson.encoder import JSONEncoder as JSONEncoder, JSONEncoderForHTML as JSONEncoderForHTML
def dumps(obj: Any, *args: Any, **kwds: Any) -> str: ...
def dump(obj: Any, fp: IO[str], *args: Any, **kwds: Any) -> None: ...
@@ -1,4 +1,4 @@
from typing import Any, Match
from typing import Match
class JSONDecoder(object):
def __init__(self, **kwargs): ...
@@ -1,4 +1,5 @@
from typing import Any, IO
from typing import Any
class JSONEncoder(object):
def __init__(self, *args, **kwargs): ...