diff --git a/stdlib/2/__builtin__.pyi b/stdlib/2/__builtin__.pyi index 9a5350ee273d..21640d187908 100644 --- a/stdlib/2/__builtin__.pyi +++ b/stdlib/2/__builtin__.pyi @@ -6,7 +6,7 @@ from typing import ( TypeVar, Iterator, Iterable, NoReturn, overload, - Sequence, Mapping, Tuple, List, Any, Dict, Callable, Generic, Set, + Sequence, Mapping, Tuple, List, Any, Dict, Callable, Generic, Set, Text, AbstractSet, FrozenSet, Sized, Reversible, SupportsInt, SupportsFloat, SupportsAbs, SupportsComplex, SupportsRound, IO, BinaryIO, Union, AnyStr, MutableSequence, MutableMapping, MutableSet, ItemsView, KeysView, ValuesView, Optional, Container, Type @@ -26,10 +26,10 @@ _T5 = TypeVar('_T5') _TT = TypeVar('_TT', bound='type') class object: - __doc__ = ... # type: Optional[str] - __dict__ = ... # type: Dict[str, Any] - __slots__ = ... # type: Union[str, unicode, Iterable[Union[str, unicode]]] - __module__ = ... # type: str + __doc__ = ... # type: Optional[Text] + __dict__ = ... # type: Dict[Text, Any] + __slots__ = ... # type: Union[Text, Iterable[Text]] + __module__ = ... # type: Text @property def __class__(self: _T) -> Type[_T]: ... @@ -37,15 +37,15 @@ class object: def __class__(self, __type: Type[object]) -> None: ... def __init__(self) -> None: ... def __new__(cls) -> Any: ... - def __setattr__(self, name: str, value: Any) -> None: ... + def __setattr__(self, name: Text, value: Any) -> None: ... def __eq__(self, o: object) -> bool: ... def __ne__(self, o: object) -> bool: ... def __str__(self) -> str: ... def __repr__(self) -> str: ... def __hash__(self) -> int: ... - def __format__(self, format_spec: str) -> str: ... - def __getattribute__(self, name: str) -> Any: ... - def __delattr__(self, name: str) -> None: ... + def __format__(self, format_spec: AnyStr) -> AnyStr: ... + def __getattribute__(self, name: Text) -> Any: ... + def __delattr__(self, name: Text) -> None: ... def __sizeof__(self) -> int: ... def __reduce__(self) -> tuple: ... def __reduce_ex__(self, protocol: int) -> tuple: ... @@ -66,18 +66,18 @@ class classmethod(object): # Special, only valid as a decorator. class type(object): __bases__ = ... # type: Tuple[type, ...] - __name__ = ... # type: str - __module__ = ... # type: str + __name__ = ... # type: Text + __module__ = ... # type: Text @overload def __init__(self, o: object) -> None: ... @overload - def __init__(self, name: str, bases: Tuple[type, ...], dict: Dict[str, Any]) -> None: ... + def __init__(self, name: Text, bases: Tuple[type, ...], dict: Dict[Text, Any]) -> None: ... # TODO: __new__ may have to be special and not a static method. @overload def __new__(cls, o: object) -> type: ... @overload - def __new__(cls, name: str, bases: Tuple[type, ...], namespace: Dict[str, Any]) -> type: ... + def __new__(cls, name: Text, bases: Tuple[type, ...], namespace: Dict[Text, Any]) -> type: ... def __call__(self, *args: Any, **kwds: Any) -> Any: ... # Only new-style classes @@ -160,7 +160,7 @@ class float: def hex(self) -> str: ... def is_integer(self) -> bool: ... @classmethod - def fromhex(cls, s: str) -> float: ... + def fromhex(cls, s: Text) -> float: ... @property def real(self) -> float: ... @@ -207,7 +207,7 @@ class complex: @overload def __init__(self, re: float = ..., im: float = ...) -> None: ... @overload - def __init__(self, s: str) -> None: ... + def __init__(self, s: Text) -> None: ... @overload def __init__(self, s: SupportsComplex) -> None: ... @@ -256,19 +256,19 @@ class unicode(basestring, Sequence[unicode]): @overload def __init__(self, o: object) -> None: ... @overload - def __init__(self, o: str, encoding: unicode = ..., errors: unicode = ...) -> None: ... + def __init__(self, o: Text, encoding: Text = ..., errors: Text = ...) -> None: ... def capitalize(self) -> unicode: ... - def center(self, width: int, fillchar: unicode = ...) -> unicode: ... - def count(self, x: unicode) -> int: ... - def decode(self, encoding: unicode = ..., errors: unicode = ...) -> unicode: ... - def encode(self, encoding: unicode = ..., errors: unicode = ...) -> str: ... - def endswith(self, suffix: Union[unicode, Tuple[unicode, ...]], start: int = ..., + def center(self, width: int, fillchar: Text = ...) -> unicode: ... + def count(self, x: Text) -> int: ... + def decode(self, encoding: Text = ..., errors: Text = ...) -> unicode: ... + def encode(self, encoding: Text = ..., errors: Text = ...) -> bytes: ... + def endswith(self, suffix: Union[Text, Tuple[Text, ...]], start: int = ..., end: int = ...) -> bool: ... def expandtabs(self, tabsize: int = ...) -> unicode: ... - def find(self, sub: unicode, start: int = ..., end: int = ...) -> int: ... + def find(self, sub: Text, start: int = ..., end: int = ...) -> int: ... def format(self, *args: Any, **kwargs: Any) -> unicode: ... - def format_map(self, map: Mapping[unicode, Any]) -> unicode: ... - def index(self, sub: unicode, start: int = ..., end: int = ...) -> int: ... + def format_map(self, map: Mapping[Text, Any]) -> unicode: ... + def index(self, sub: Text, start: int = ..., end: int = ...) -> int: ... def isalnum(self) -> bool: ... def isalpha(self) -> bool: ... def isdecimal(self) -> bool: ... @@ -280,26 +280,26 @@ class unicode(basestring, Sequence[unicode]): def isspace(self) -> bool: ... def istitle(self) -> bool: ... def isupper(self) -> bool: ... - def join(self, iterable: Iterable[unicode]) -> unicode: ... - def ljust(self, width: int, fillchar: unicode = ...) -> unicode: ... + def join(self, iterable: Iterable[Text]) -> unicode: ... + def ljust(self, width: int, fillchar: Text = ...) -> unicode: ... def lower(self) -> unicode: ... - def lstrip(self, chars: unicode = ...) -> unicode: ... - def partition(self, sep: unicode) -> Tuple[unicode, unicode, unicode]: ... - def replace(self, old: unicode, new: unicode, count: int = ...) -> unicode: ... - def rfind(self, sub: unicode, start: int = ..., end: int = ...) -> int: ... - def rindex(self, sub: unicode, start: int = ..., end: int = ...) -> int: ... - def rjust(self, width: int, fillchar: unicode = ...) -> unicode: ... - def rpartition(self, sep: unicode) -> Tuple[unicode, unicode, unicode]: ... - def rsplit(self, sep: Optional[unicode] = ..., maxsplit: int = ...) -> List[unicode]: ... - def rstrip(self, chars: unicode = ...) -> unicode: ... - def split(self, sep: Optional[unicode] = ..., maxsplit: int = ...) -> List[unicode]: ... + def lstrip(self, chars: Text = ...) -> unicode: ... + def partition(self, sep: Text) -> Tuple[unicode, unicode, unicode]: ... + def replace(self, old: Text, new: Text, count: int = ...) -> unicode: ... + def rfind(self, sub: Text, start: int = ..., end: int = ...) -> int: ... + def rindex(self, sub: Text, start: int = ..., end: int = ...) -> int: ... + def rjust(self, width: int, fillchar: Text = ...) -> unicode: ... + def rpartition(self, sep: Text) -> Tuple[unicode, unicode, unicode]: ... + def rsplit(self, sep: Optional[Text] = ..., maxsplit: int = ...) -> List[unicode]: ... + def rstrip(self, chars: Text = ...) -> unicode: ... + def split(self, sep: Optional[Text] = ..., maxsplit: int = ...) -> List[unicode]: ... def splitlines(self, keepends: bool = ...) -> List[unicode]: ... - def startswith(self, prefix: Union[unicode, Tuple[unicode, ...]], start: int = ..., + def startswith(self, prefix: Union[Text, Tuple[Text, ...]], start: int = ..., end: int = ...) -> bool: ... - def strip(self, chars: unicode = ...) -> unicode: ... + def strip(self, chars: Text = ...) -> unicode: ... def swapcase(self) -> unicode: ... def title(self) -> unicode: ... - def translate(self, table: Union[Dict[int, Any], unicode]) -> unicode: ... + def translate(self, table: Union[Dict[int, Any], Text]) -> unicode: ... def upper(self) -> unicode: ... def zfill(self, width: int) -> unicode: ... @@ -308,16 +308,16 @@ class unicode(basestring, Sequence[unicode]): @overload def __getitem__(self, s: slice) -> unicode: ... def __getslice__(self, start: int, stop: int) -> unicode: ... - def __add__(self, s: unicode) -> unicode: ... + def __add__(self, s: Text) -> unicode: ... def __mul__(self, n: int) -> unicode: ... def __rmul__(self, n: int) -> unicode: ... def __mod__(self, x: Any) -> unicode: ... def __eq__(self, x: object) -> bool: ... def __ne__(self, x: object) -> bool: ... - def __lt__(self, x: unicode) -> bool: ... - def __le__(self, x: unicode) -> bool: ... - def __gt__(self, x: unicode) -> bool: ... - def __ge__(self, x: unicode) -> bool: ... + def __lt__(self, x: Text) -> bool: ... + def __le__(self, x: Text) -> bool: ... + def __gt__(self, x: Text) -> bool: ... + def __ge__(self, x: Text) -> bool: ... def __len__(self) -> int: ... def __contains__(self, s: object) -> bool: ... @@ -331,15 +331,15 @@ class unicode(basestring, Sequence[unicode]): class str(basestring, Sequence[str]): def __init__(self, object: object = ...) -> None: ... def capitalize(self) -> str: ... - def center(self, width: int, fillchar: str = ...) -> str: ... - def count(self, x: unicode, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... - def decode(self, encoding: unicode = ..., errors: unicode = ...) -> unicode: ... - def encode(self, encoding: unicode = ..., errors: unicode = ...) -> str: ... - def endswith(self, suffix: Union[unicode, Tuple[unicode, ...]]) -> bool: ... + def center(self, width: int, fillchar: Text = ...) -> str: ... + def count(self, x: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... + def decode(self, encoding: Text = ..., errors: Text = ...) -> unicode: ... + def encode(self, encoding: Text = ..., errors: Text = ...) -> str: ... + def endswith(self, suffix: Union[Text, Tuple[Text, ...]]) -> bool: ... def expandtabs(self, tabsize: int = ...) -> str: ... - def find(self, sub: unicode, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... + def find(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... def format(self, *args: Any, **kwargs: Any) -> str: ... - def index(self, sub: unicode, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... + def index(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... def isalnum(self) -> bool: ... def isalpha(self) -> bool: ... def isdigit(self) -> bool: ... @@ -348,7 +348,7 @@ class str(basestring, Sequence[str]): def istitle(self) -> bool: ... def isupper(self) -> bool: ... def join(self, iterable: Iterable[AnyStr]) -> AnyStr: ... - def ljust(self, width: int, fillchar: str = ...) -> str: ... + def ljust(self, width: int, fillchar: Text = ...) -> str: ... def lower(self) -> str: ... @overload def lstrip(self, chars: str = ...) -> str: ... @@ -361,8 +361,8 @@ class str(basestring, Sequence[str]): @overload def partition(self, sep: unicode) -> Tuple[unicode, unicode, unicode]: ... def replace(self, old: AnyStr, new: AnyStr, count: int = ...) -> AnyStr: ... - def rfind(self, sub: unicode, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... - def rindex(self, sub: unicode, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... + def rfind(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... + def rindex(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... def rjust(self, width: int, fillchar: str = ...) -> str: ... @overload def rpartition(self, sep: bytearray) -> Tuple[str, bytearray, str]: ... @@ -383,7 +383,7 @@ class str(basestring, Sequence[str]): @overload def split(self, sep: unicode, maxsplit: int = ...) -> List[unicode]: ... def splitlines(self, keepends: bool = ...) -> List[str]: ... - def startswith(self, prefix: Union[unicode, Tuple[unicode, ...]]) -> bool: ... + def startswith(self, prefix: Union[Text, Tuple[Text, ...]]) -> bool: ... @overload def strip(self, chars: str = ...) -> str: ... @overload @@ -412,30 +412,30 @@ class str(basestring, Sequence[str]): def __contains__(self, o: object) -> bool: ... def __eq__(self, x: object) -> bool: ... def __ne__(self, x: object) -> bool: ... - def __lt__(self, x: unicode) -> bool: ... - def __le__(self, x: unicode) -> bool: ... - def __gt__(self, x: unicode) -> bool: ... - def __ge__(self, x: unicode) -> bool: ... + def __lt__(self, x: Text) -> bool: ... + def __le__(self, x: Text) -> bool: ... + def __gt__(self, x: Text) -> bool: ... + def __ge__(self, x: Text) -> bool: ... def __mod__(self, x: Any) -> str: ... class bytearray(MutableSequence[int]): @overload def __init__(self) -> None: ... @overload - def __init__(self, x: Union[Iterable[int], str]) -> None: ... + def __init__(self, x: Union[Iterable[int], bytes]) -> None: ... @overload - def __init__(self, x: unicode, encoding: unicode, - errors: unicode = ...) -> None: ... + def __init__(self, x: Text, encoding: Text, + errors: Text = ...) -> None: ... @overload def __init__(self, length: int) -> None: ... def capitalize(self) -> bytearray: ... - def center(self, width: int, fillchar: str = ...) -> bytearray: ... - def count(self, x: str) -> int: ... - def decode(self, encoding: unicode = ..., errors: unicode = ...) -> str: ... - def endswith(self, suffix: Union[str, Tuple[str, ...]]) -> bool: ... + def center(self, width: int, fillchar: bytes = ...) -> bytearray: ... + def count(self, x: bytes) -> int: ... + def decode(self, encoding: Text = ..., errors: Text = ...) -> unicode: ... + def endswith(self, suffix: Union[bytes, Tuple[bytes, ...]]) -> bool: ... def expandtabs(self, tabsize: int = ...) -> bytearray: ... - def find(self, sub: str, start: int = ..., end: int = ...) -> int: ... - def index(self, sub: str, start: int = ..., end: int = ...) -> int: ... + def find(self, sub: bytes, start: int = ..., end: int = ...) -> int: ... + def index(self, sub: bytes, start: int = ..., end: int = ...) -> int: ... def insert(self, index: int, object: int) -> None: ... def isalnum(self) -> bool: ... def isalpha(self) -> bool: ... @@ -444,29 +444,29 @@ class bytearray(MutableSequence[int]): def isspace(self) -> bool: ... def istitle(self) -> bool: ... def isupper(self) -> bool: ... - def join(self, iterable: Iterable[str]) -> bytearray: ... - def ljust(self, width: int, fillchar: str = ...) -> bytearray: ... + def join(self, iterable: Iterable[bytes]) -> bytearray: ... + def ljust(self, width: int, fillchar: bytes = ...) -> bytearray: ... def lower(self) -> bytearray: ... - def lstrip(self, chars: str = ...) -> bytearray: ... - def partition(self, sep: str) -> Tuple[bytearray, bytearray, bytearray]: ... - def replace(self, old: str, new: str, count: int = ...) -> bytearray: ... - def rfind(self, sub: str, start: int = ..., end: int = ...) -> int: ... - def rindex(self, sub: str, start: int = ..., end: int = ...) -> int: ... - def rjust(self, width: int, fillchar: str = ...) -> bytearray: ... - def rpartition(self, sep: str) -> Tuple[bytearray, bytearray, bytearray]: ... - def rsplit(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[bytearray]: ... - def rstrip(self, chars: str = ...) -> bytearray: ... - def split(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[bytearray]: ... + def lstrip(self, chars: bytes = ...) -> bytearray: ... + def partition(self, sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... + def replace(self, old: bytes, new: bytes, count: int = ...) -> bytearray: ... + def rfind(self, sub: bytes, start: int = ..., end: int = ...) -> int: ... + def rindex(self, sub: bytes, start: int = ..., end: int = ...) -> int: ... + def rjust(self, width: int, fillchar: bytes = ...) -> bytearray: ... + def rpartition(self, sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... + def rsplit(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytearray]: ... + def rstrip(self, chars: bytes = ...) -> bytearray: ... + def split(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytearray]: ... def splitlines(self, keepends: bool = ...) -> List[bytearray]: ... - def startswith(self, prefix: Union[str, Tuple[str, ...]]) -> bool: ... - def strip(self, chars: str = ...) -> bytearray: ... + def startswith(self, prefix: Union[bytes, Tuple[bytes, ...]]) -> bool: ... + def strip(self, chars: bytes = ...) -> bytearray: ... def swapcase(self) -> bytearray: ... def title(self) -> bytearray: ... - def translate(self, table: str) -> bytearray: ... + def translate(self, table: bytes) -> bytearray: ... def upper(self) -> bytearray: ... def zfill(self, width: int) -> bytearray: ... @staticmethod - def fromhex(x: str) -> bytearray: ... + def fromhex(x: bytes) -> bytearray: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[int]: ... @@ -483,19 +483,19 @@ class bytearray(MutableSequence[int]): @overload def __setitem__(self, i: int, x: int) -> None: ... @overload - def __setitem__(self, s: slice, x: Union[Iterable[int], str]) -> None: ... - def __setslice__(self, start: int, stop: int, x: Union[Sequence[int], str]) -> None: ... + def __setitem__(self, s: slice, x: Union[Iterable[int], bytes]) -> None: ... + def __setslice__(self, start: int, stop: int, x: Union[Sequence[int], bytes]) -> None: ... def __delitem__(self, i: Union[int, slice]) -> None: ... def __delslice__(self, start: int, stop: int) -> None: ... - def __add__(self, s: str) -> bytearray: ... + def __add__(self, s: bytes) -> bytearray: ... def __mul__(self, n: int) -> bytearray: ... def __contains__(self, o: object) -> bool: ... def __eq__(self, x: object) -> bool: ... def __ne__(self, x: object) -> bool: ... - def __lt__(self, x: str) -> bool: ... - def __le__(self, x: str) -> bool: ... - def __gt__(self, x: str) -> bool: ... - def __ge__(self, x: str) -> bool: ... + def __lt__(self, x: Text) -> bool: ... + def __le__(self, x: Text) -> bool: ... + def __gt__(self, x: Text) -> bool: ... + def __ge__(self, x: Text) -> bool: ... class bool(int): def __init__(self, o: object = ...) -> None: ... @@ -555,8 +555,8 @@ class tuple(Sequence[_T_co], Generic[_T_co]): class function: # TODO name of the class (corresponds to Python 'function' class) - __name__ = ... # type: str - __module__ = ... # type: str + __name__ = ... # type: Text + __module__ = ... # type: Text class list(MutableSequence[_T], Generic[_T]): @overload @@ -723,7 +723,7 @@ class xrange(Sized, Iterable[int], Reversible[int]): class property(object): def __init__(self, fget: Optional[Callable[[Any], Any]] = ..., fset: Optional[Callable[[Any, Any], None]] = ..., - fdel: Optional[Callable[[Any], None]] = ..., doc: Optional[str] = ...) -> None: ... + fdel: Optional[Callable[[Any], None]] = ..., doc: Optional[Text] = ...) -> None: ... def getter(self, fget: Callable[[Any], Any]) -> property: ... def setter(self, fset: Callable[[Any, Any], None]) -> property: ... def deleter(self, fdel: Callable[[Any], None]) -> property: ... @@ -745,9 +745,10 @@ def any(i: Iterable[object]) -> bool: ... def bin(number: int) -> str: ... def callable(o: object) -> bool: ... def chr(code: int) -> str: ... -def compile(source: Any, filename: unicode, mode: str, flags: int = ..., +def compile(source: Union[Text, mod], filename: Text, + mode: Text, flags: int = ..., dont_inherit: int = ...) -> Any: ... -def delattr(o: Any, name: unicode) -> None: ... +def delattr(o: Any, name: Text) -> None: ... def dir(o: object = ...) -> List[str]: ... @overload def divmod(a: int, b: int) -> Tuple[int, int]: ... @@ -769,9 +770,9 @@ def filter(__function: None, @overload def filter(__function: Callable[[_T], Any], __iterable: Iterable[_T]) -> List[_T]: ... -def format(o: object, format_spec: str = ...) -> str: ... # TODO unicode -def getattr(o: Any, name: unicode, default: Optional[Any] = ...) -> Any: ... -def hasattr(o: Any, name: unicode) -> bool: ... +def format(o: object, format_spec: AnyStr = ...) -> AnyStr: ... +def getattr(o: Any, name: Text, default: Optional[Any] = ...) -> Any: ... +def hasattr(o: Any, name: Text) -> bool: ... def hash(o: object) -> int: ... def hex(i: int) -> str: ... # TODO __index__ def id(o: object) -> int: ... @@ -864,14 +865,14 @@ def next(i: Iterator[_T]) -> _T: ... def next(i: Iterator[_T], default: _VT) -> Union[_T, _VT]: ... def oct(i: int) -> str: ... # TODO __index__ @overload -def open(file: str, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ... +def open(file: str, mode: Text = ..., buffering: int = ...) -> BinaryIO: ... @overload -def open(file: unicode, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ... +def open(file: unicode, mode: Text = ..., buffering: int = ...) -> BinaryIO: ... @overload -def open(file: int, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ... -def ord(c: unicode) -> int: ... +def open(file: int, mode: Text = ..., buffering: int = ...) -> BinaryIO: ... +def ord(c: Text) -> int: ... # This is only available after from __future__ import print_function. -def print(*values: Any, sep: unicode = ..., end: unicode = ..., file: IO[Any] = ...) -> None: ... +def print(*values: Any, sep: Text = ..., end: Text = ..., file: IO[Any] = ...) -> None: ... @overload def pow(x: int, y: int) -> Any: ... # The return type can be int or float, depending on y. @overload @@ -903,7 +904,7 @@ def round(number: float, ndigits: int) -> float: ... # Always return a float if def round(number: SupportsRound[_T]) -> _T: ... @overload def round(number: SupportsRound[_T], ndigits: int) -> _T: ... -def setattr(object: Any, name: unicode, value: Any) -> None: ... +def setattr(object: Any, name: Text, value: Any) -> None: ... def sorted(iterable: Iterable[_T], *, cmp: Callable[[_T, _T], int] = ..., key: Callable[[_T], Any] = ..., @@ -932,10 +933,10 @@ def zip(iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], def zip(iter1: Iterable[Any], iter2: Iterable[Any], iter3: Iterable[Any], iter4: Iterable[Any], iter5: Iterable[Any], iter6: Iterable[Any], *iterables: Iterable[Any]) -> List[Tuple[Any, ...]]: ... -def __import__(name: unicode, - globals: Dict[str, Any] = ..., - locals: Dict[str, Any] = ..., - fromlist: List[str] = ..., level: int = ...) -> Any: ... +def __import__(name: Text, + globals: Dict[Text, Any] = ..., + locals: Dict[Text, Any] = ..., + fromlist: List[Text] = ..., level: int = ...) -> Any: ... def globals() -> Dict[str, Any]: ... def locals() -> Dict[str, Any]: ... @@ -1040,21 +1041,21 @@ class TypeError(StandardError): ... class UnboundLocalError(NameError): ... class UnicodeError(ValueError): ... class UnicodeDecodeError(UnicodeError): - encoding: bytes + encoding: str object: bytes start: int end: int - reason: bytes - def __init__(self, __encoding: bytes, __object: bytes, __start: int, __end: int, - __reason: bytes) -> None: ... + reason: str + def __init__(self, __encoding: str, __object: bytes, __start: int, __end: int, + __reason: str) -> None: ... class UnicodeEncodeError(UnicodeError): - encoding: bytes + encoding: str object: unicode start: int end: int - reason: bytes - def __init__(self, __encoding: bytes, __object: unicode, __start: int, __end: int, - __reason: bytes) -> None: ... + reason: str + def __init__(self, __encoding: str, __object: unicode, __start: int, __end: int, + __reason: str) -> None: ... class UnicodeTranslateError(UnicodeError): ... class ZeroDivisionError(ArithmeticError): ... @@ -1069,25 +1070,25 @@ class ImportWarning(Warning): ... class UnicodeWarning(Warning): ... class BytesWarning(Warning): ... -def eval(s: Union[str, unicode], globals: Dict[str, Any] = ..., locals: Dict[str, Any] = ...) -> Any: ... -def exec(object: str, - globals: Optional[Dict[str, Any]] = ..., - locals: Optional[Dict[str, Any]] = ...) -> Any: ... # TODO code object as source +def eval(s: Union[str, unicode], globals: Dict[Text, Any] = ..., locals: Dict[Text, Any] = ...) -> Any: ... +def exec(object: Text, + globals: Optional[Dict[Text, Any]] = ..., + locals: Optional[Dict[Text, Any]] = ...) -> Any: ... # TODO code object as source def cmp(x: Any, y: Any) -> int: ... -def execfile(filename: str, globals: Optional[Dict[str, Any]] = ..., locals: Optional[Dict[str, Any]] = ...) -> None: ... +def execfile(filename: Text, globals: Optional[Dict[Text, Any]] = ..., locals: Optional[Dict[str, Any]] = ...) -> None: ... class file(BinaryIO): @overload - def __init__(self, file: str, mode: str = ..., buffering: int = ...) -> None: ... + def __init__(self, file: str, mode: Text = ..., buffering: int = ...) -> None: ... @overload - def __init__(self, file: unicode, mode: str = ..., buffering: int = ...) -> None: ... + def __init__(self, file: unicode, mode: Text = ..., buffering: int = ...) -> None: ... @overload - def __init__(self, file: int, mode: str = ..., buffering: int = ...) -> None: ... - def __iter__(self) -> Iterator[str]: ... - def next(self) -> str: ... - def read(self, n: int = ...) -> str: ... + def __init__(self, file: int, mode: Text = ..., buffering: int = ...) -> None: ... + def __iter__(self) -> Iterator[bytes]: ... + def next(self) -> bytes: ... + def read(self, n: int = ...) -> bytes: ... def __enter__(self) -> BinaryIO: ... def __exit__(self, t: Optional[type] = ..., exc: Optional[BaseException] = ..., tb: Optional[Any] = ...) -> bool: ... def flush(self) -> None: ... @@ -1100,10 +1101,10 @@ class file(BinaryIO): def seekable(self) -> bool: ... def seek(self, offset: int, whence: int = ...) -> int: ... def tell(self) -> int: ... - def readline(self, limit: int = ...) -> str: ... - def readlines(self, hint: int = ...) -> List[str]: ... - def write(self, data: str) -> int: ... - def writelines(self, data: Iterable[str]) -> None: ... + def readline(self, limit: int = ...) -> bytes: ... + def readlines(self, hint: int = ...) -> List[bytes]: ... + def write(self, data: bytes) -> int: ... + def writelines(self, data: Iterable[bytes]) -> None: ... def truncate(self, pos: Optional[int] = ...) -> int: ... # Very old builtins diff --git a/stdlib/2/_threading_local.pyi b/stdlib/2/_threading_local.pyi index 512bf5874df7..28cdc893a3c6 100644 --- a/stdlib/2/_threading_local.pyi +++ b/stdlib/2/_threading_local.pyi @@ -1,14 +1,14 @@ # Source: https://hg.python.org/cpython/file/2.7/Lib/_threading_local.py -from typing import Any, List +from typing import Any, List, Text -__all__: List[str] +__all__: List[Text] class _localbase(object): ... class local(_localbase): - def __getattribute__(self, name: str) -> Any: ... - def __setattr__(self, name: str, value: Any) -> None: ... - def __delattr__(self, name: str) -> None: ... + def __getattribute__(self, name: Text) -> Any: ... + def __setattr__(self, name: Text, value: Any) -> None: ... + def __delattr__(self, name: Text) -> None: ... def __del__(self) -> None: ... def _patch(self: local) -> None: ... diff --git a/stdlib/2/builtins.pyi b/stdlib/2/builtins.pyi index 9a5350ee273d..21640d187908 100644 --- a/stdlib/2/builtins.pyi +++ b/stdlib/2/builtins.pyi @@ -6,7 +6,7 @@ from typing import ( TypeVar, Iterator, Iterable, NoReturn, overload, - Sequence, Mapping, Tuple, List, Any, Dict, Callable, Generic, Set, + Sequence, Mapping, Tuple, List, Any, Dict, Callable, Generic, Set, Text, AbstractSet, FrozenSet, Sized, Reversible, SupportsInt, SupportsFloat, SupportsAbs, SupportsComplex, SupportsRound, IO, BinaryIO, Union, AnyStr, MutableSequence, MutableMapping, MutableSet, ItemsView, KeysView, ValuesView, Optional, Container, Type @@ -26,10 +26,10 @@ _T5 = TypeVar('_T5') _TT = TypeVar('_TT', bound='type') class object: - __doc__ = ... # type: Optional[str] - __dict__ = ... # type: Dict[str, Any] - __slots__ = ... # type: Union[str, unicode, Iterable[Union[str, unicode]]] - __module__ = ... # type: str + __doc__ = ... # type: Optional[Text] + __dict__ = ... # type: Dict[Text, Any] + __slots__ = ... # type: Union[Text, Iterable[Text]] + __module__ = ... # type: Text @property def __class__(self: _T) -> Type[_T]: ... @@ -37,15 +37,15 @@ class object: def __class__(self, __type: Type[object]) -> None: ... def __init__(self) -> None: ... def __new__(cls) -> Any: ... - def __setattr__(self, name: str, value: Any) -> None: ... + def __setattr__(self, name: Text, value: Any) -> None: ... def __eq__(self, o: object) -> bool: ... def __ne__(self, o: object) -> bool: ... def __str__(self) -> str: ... def __repr__(self) -> str: ... def __hash__(self) -> int: ... - def __format__(self, format_spec: str) -> str: ... - def __getattribute__(self, name: str) -> Any: ... - def __delattr__(self, name: str) -> None: ... + def __format__(self, format_spec: AnyStr) -> AnyStr: ... + def __getattribute__(self, name: Text) -> Any: ... + def __delattr__(self, name: Text) -> None: ... def __sizeof__(self) -> int: ... def __reduce__(self) -> tuple: ... def __reduce_ex__(self, protocol: int) -> tuple: ... @@ -66,18 +66,18 @@ class classmethod(object): # Special, only valid as a decorator. class type(object): __bases__ = ... # type: Tuple[type, ...] - __name__ = ... # type: str - __module__ = ... # type: str + __name__ = ... # type: Text + __module__ = ... # type: Text @overload def __init__(self, o: object) -> None: ... @overload - def __init__(self, name: str, bases: Tuple[type, ...], dict: Dict[str, Any]) -> None: ... + def __init__(self, name: Text, bases: Tuple[type, ...], dict: Dict[Text, Any]) -> None: ... # TODO: __new__ may have to be special and not a static method. @overload def __new__(cls, o: object) -> type: ... @overload - def __new__(cls, name: str, bases: Tuple[type, ...], namespace: Dict[str, Any]) -> type: ... + def __new__(cls, name: Text, bases: Tuple[type, ...], namespace: Dict[Text, Any]) -> type: ... def __call__(self, *args: Any, **kwds: Any) -> Any: ... # Only new-style classes @@ -160,7 +160,7 @@ class float: def hex(self) -> str: ... def is_integer(self) -> bool: ... @classmethod - def fromhex(cls, s: str) -> float: ... + def fromhex(cls, s: Text) -> float: ... @property def real(self) -> float: ... @@ -207,7 +207,7 @@ class complex: @overload def __init__(self, re: float = ..., im: float = ...) -> None: ... @overload - def __init__(self, s: str) -> None: ... + def __init__(self, s: Text) -> None: ... @overload def __init__(self, s: SupportsComplex) -> None: ... @@ -256,19 +256,19 @@ class unicode(basestring, Sequence[unicode]): @overload def __init__(self, o: object) -> None: ... @overload - def __init__(self, o: str, encoding: unicode = ..., errors: unicode = ...) -> None: ... + def __init__(self, o: Text, encoding: Text = ..., errors: Text = ...) -> None: ... def capitalize(self) -> unicode: ... - def center(self, width: int, fillchar: unicode = ...) -> unicode: ... - def count(self, x: unicode) -> int: ... - def decode(self, encoding: unicode = ..., errors: unicode = ...) -> unicode: ... - def encode(self, encoding: unicode = ..., errors: unicode = ...) -> str: ... - def endswith(self, suffix: Union[unicode, Tuple[unicode, ...]], start: int = ..., + def center(self, width: int, fillchar: Text = ...) -> unicode: ... + def count(self, x: Text) -> int: ... + def decode(self, encoding: Text = ..., errors: Text = ...) -> unicode: ... + def encode(self, encoding: Text = ..., errors: Text = ...) -> bytes: ... + def endswith(self, suffix: Union[Text, Tuple[Text, ...]], start: int = ..., end: int = ...) -> bool: ... def expandtabs(self, tabsize: int = ...) -> unicode: ... - def find(self, sub: unicode, start: int = ..., end: int = ...) -> int: ... + def find(self, sub: Text, start: int = ..., end: int = ...) -> int: ... def format(self, *args: Any, **kwargs: Any) -> unicode: ... - def format_map(self, map: Mapping[unicode, Any]) -> unicode: ... - def index(self, sub: unicode, start: int = ..., end: int = ...) -> int: ... + def format_map(self, map: Mapping[Text, Any]) -> unicode: ... + def index(self, sub: Text, start: int = ..., end: int = ...) -> int: ... def isalnum(self) -> bool: ... def isalpha(self) -> bool: ... def isdecimal(self) -> bool: ... @@ -280,26 +280,26 @@ class unicode(basestring, Sequence[unicode]): def isspace(self) -> bool: ... def istitle(self) -> bool: ... def isupper(self) -> bool: ... - def join(self, iterable: Iterable[unicode]) -> unicode: ... - def ljust(self, width: int, fillchar: unicode = ...) -> unicode: ... + def join(self, iterable: Iterable[Text]) -> unicode: ... + def ljust(self, width: int, fillchar: Text = ...) -> unicode: ... def lower(self) -> unicode: ... - def lstrip(self, chars: unicode = ...) -> unicode: ... - def partition(self, sep: unicode) -> Tuple[unicode, unicode, unicode]: ... - def replace(self, old: unicode, new: unicode, count: int = ...) -> unicode: ... - def rfind(self, sub: unicode, start: int = ..., end: int = ...) -> int: ... - def rindex(self, sub: unicode, start: int = ..., end: int = ...) -> int: ... - def rjust(self, width: int, fillchar: unicode = ...) -> unicode: ... - def rpartition(self, sep: unicode) -> Tuple[unicode, unicode, unicode]: ... - def rsplit(self, sep: Optional[unicode] = ..., maxsplit: int = ...) -> List[unicode]: ... - def rstrip(self, chars: unicode = ...) -> unicode: ... - def split(self, sep: Optional[unicode] = ..., maxsplit: int = ...) -> List[unicode]: ... + def lstrip(self, chars: Text = ...) -> unicode: ... + def partition(self, sep: Text) -> Tuple[unicode, unicode, unicode]: ... + def replace(self, old: Text, new: Text, count: int = ...) -> unicode: ... + def rfind(self, sub: Text, start: int = ..., end: int = ...) -> int: ... + def rindex(self, sub: Text, start: int = ..., end: int = ...) -> int: ... + def rjust(self, width: int, fillchar: Text = ...) -> unicode: ... + def rpartition(self, sep: Text) -> Tuple[unicode, unicode, unicode]: ... + def rsplit(self, sep: Optional[Text] = ..., maxsplit: int = ...) -> List[unicode]: ... + def rstrip(self, chars: Text = ...) -> unicode: ... + def split(self, sep: Optional[Text] = ..., maxsplit: int = ...) -> List[unicode]: ... def splitlines(self, keepends: bool = ...) -> List[unicode]: ... - def startswith(self, prefix: Union[unicode, Tuple[unicode, ...]], start: int = ..., + def startswith(self, prefix: Union[Text, Tuple[Text, ...]], start: int = ..., end: int = ...) -> bool: ... - def strip(self, chars: unicode = ...) -> unicode: ... + def strip(self, chars: Text = ...) -> unicode: ... def swapcase(self) -> unicode: ... def title(self) -> unicode: ... - def translate(self, table: Union[Dict[int, Any], unicode]) -> unicode: ... + def translate(self, table: Union[Dict[int, Any], Text]) -> unicode: ... def upper(self) -> unicode: ... def zfill(self, width: int) -> unicode: ... @@ -308,16 +308,16 @@ class unicode(basestring, Sequence[unicode]): @overload def __getitem__(self, s: slice) -> unicode: ... def __getslice__(self, start: int, stop: int) -> unicode: ... - def __add__(self, s: unicode) -> unicode: ... + def __add__(self, s: Text) -> unicode: ... def __mul__(self, n: int) -> unicode: ... def __rmul__(self, n: int) -> unicode: ... def __mod__(self, x: Any) -> unicode: ... def __eq__(self, x: object) -> bool: ... def __ne__(self, x: object) -> bool: ... - def __lt__(self, x: unicode) -> bool: ... - def __le__(self, x: unicode) -> bool: ... - def __gt__(self, x: unicode) -> bool: ... - def __ge__(self, x: unicode) -> bool: ... + def __lt__(self, x: Text) -> bool: ... + def __le__(self, x: Text) -> bool: ... + def __gt__(self, x: Text) -> bool: ... + def __ge__(self, x: Text) -> bool: ... def __len__(self) -> int: ... def __contains__(self, s: object) -> bool: ... @@ -331,15 +331,15 @@ class unicode(basestring, Sequence[unicode]): class str(basestring, Sequence[str]): def __init__(self, object: object = ...) -> None: ... def capitalize(self) -> str: ... - def center(self, width: int, fillchar: str = ...) -> str: ... - def count(self, x: unicode, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... - def decode(self, encoding: unicode = ..., errors: unicode = ...) -> unicode: ... - def encode(self, encoding: unicode = ..., errors: unicode = ...) -> str: ... - def endswith(self, suffix: Union[unicode, Tuple[unicode, ...]]) -> bool: ... + def center(self, width: int, fillchar: Text = ...) -> str: ... + def count(self, x: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... + def decode(self, encoding: Text = ..., errors: Text = ...) -> unicode: ... + def encode(self, encoding: Text = ..., errors: Text = ...) -> str: ... + def endswith(self, suffix: Union[Text, Tuple[Text, ...]]) -> bool: ... def expandtabs(self, tabsize: int = ...) -> str: ... - def find(self, sub: unicode, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... + def find(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... def format(self, *args: Any, **kwargs: Any) -> str: ... - def index(self, sub: unicode, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... + def index(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... def isalnum(self) -> bool: ... def isalpha(self) -> bool: ... def isdigit(self) -> bool: ... @@ -348,7 +348,7 @@ class str(basestring, Sequence[str]): def istitle(self) -> bool: ... def isupper(self) -> bool: ... def join(self, iterable: Iterable[AnyStr]) -> AnyStr: ... - def ljust(self, width: int, fillchar: str = ...) -> str: ... + def ljust(self, width: int, fillchar: Text = ...) -> str: ... def lower(self) -> str: ... @overload def lstrip(self, chars: str = ...) -> str: ... @@ -361,8 +361,8 @@ class str(basestring, Sequence[str]): @overload def partition(self, sep: unicode) -> Tuple[unicode, unicode, unicode]: ... def replace(self, old: AnyStr, new: AnyStr, count: int = ...) -> AnyStr: ... - def rfind(self, sub: unicode, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... - def rindex(self, sub: unicode, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... + def rfind(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... + def rindex(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ... def rjust(self, width: int, fillchar: str = ...) -> str: ... @overload def rpartition(self, sep: bytearray) -> Tuple[str, bytearray, str]: ... @@ -383,7 +383,7 @@ class str(basestring, Sequence[str]): @overload def split(self, sep: unicode, maxsplit: int = ...) -> List[unicode]: ... def splitlines(self, keepends: bool = ...) -> List[str]: ... - def startswith(self, prefix: Union[unicode, Tuple[unicode, ...]]) -> bool: ... + def startswith(self, prefix: Union[Text, Tuple[Text, ...]]) -> bool: ... @overload def strip(self, chars: str = ...) -> str: ... @overload @@ -412,30 +412,30 @@ class str(basestring, Sequence[str]): def __contains__(self, o: object) -> bool: ... def __eq__(self, x: object) -> bool: ... def __ne__(self, x: object) -> bool: ... - def __lt__(self, x: unicode) -> bool: ... - def __le__(self, x: unicode) -> bool: ... - def __gt__(self, x: unicode) -> bool: ... - def __ge__(self, x: unicode) -> bool: ... + def __lt__(self, x: Text) -> bool: ... + def __le__(self, x: Text) -> bool: ... + def __gt__(self, x: Text) -> bool: ... + def __ge__(self, x: Text) -> bool: ... def __mod__(self, x: Any) -> str: ... class bytearray(MutableSequence[int]): @overload def __init__(self) -> None: ... @overload - def __init__(self, x: Union[Iterable[int], str]) -> None: ... + def __init__(self, x: Union[Iterable[int], bytes]) -> None: ... @overload - def __init__(self, x: unicode, encoding: unicode, - errors: unicode = ...) -> None: ... + def __init__(self, x: Text, encoding: Text, + errors: Text = ...) -> None: ... @overload def __init__(self, length: int) -> None: ... def capitalize(self) -> bytearray: ... - def center(self, width: int, fillchar: str = ...) -> bytearray: ... - def count(self, x: str) -> int: ... - def decode(self, encoding: unicode = ..., errors: unicode = ...) -> str: ... - def endswith(self, suffix: Union[str, Tuple[str, ...]]) -> bool: ... + def center(self, width: int, fillchar: bytes = ...) -> bytearray: ... + def count(self, x: bytes) -> int: ... + def decode(self, encoding: Text = ..., errors: Text = ...) -> unicode: ... + def endswith(self, suffix: Union[bytes, Tuple[bytes, ...]]) -> bool: ... def expandtabs(self, tabsize: int = ...) -> bytearray: ... - def find(self, sub: str, start: int = ..., end: int = ...) -> int: ... - def index(self, sub: str, start: int = ..., end: int = ...) -> int: ... + def find(self, sub: bytes, start: int = ..., end: int = ...) -> int: ... + def index(self, sub: bytes, start: int = ..., end: int = ...) -> int: ... def insert(self, index: int, object: int) -> None: ... def isalnum(self) -> bool: ... def isalpha(self) -> bool: ... @@ -444,29 +444,29 @@ class bytearray(MutableSequence[int]): def isspace(self) -> bool: ... def istitle(self) -> bool: ... def isupper(self) -> bool: ... - def join(self, iterable: Iterable[str]) -> bytearray: ... - def ljust(self, width: int, fillchar: str = ...) -> bytearray: ... + def join(self, iterable: Iterable[bytes]) -> bytearray: ... + def ljust(self, width: int, fillchar: bytes = ...) -> bytearray: ... def lower(self) -> bytearray: ... - def lstrip(self, chars: str = ...) -> bytearray: ... - def partition(self, sep: str) -> Tuple[bytearray, bytearray, bytearray]: ... - def replace(self, old: str, new: str, count: int = ...) -> bytearray: ... - def rfind(self, sub: str, start: int = ..., end: int = ...) -> int: ... - def rindex(self, sub: str, start: int = ..., end: int = ...) -> int: ... - def rjust(self, width: int, fillchar: str = ...) -> bytearray: ... - def rpartition(self, sep: str) -> Tuple[bytearray, bytearray, bytearray]: ... - def rsplit(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[bytearray]: ... - def rstrip(self, chars: str = ...) -> bytearray: ... - def split(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[bytearray]: ... + def lstrip(self, chars: bytes = ...) -> bytearray: ... + def partition(self, sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... + def replace(self, old: bytes, new: bytes, count: int = ...) -> bytearray: ... + def rfind(self, sub: bytes, start: int = ..., end: int = ...) -> int: ... + def rindex(self, sub: bytes, start: int = ..., end: int = ...) -> int: ... + def rjust(self, width: int, fillchar: bytes = ...) -> bytearray: ... + def rpartition(self, sep: bytes) -> Tuple[bytearray, bytearray, bytearray]: ... + def rsplit(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytearray]: ... + def rstrip(self, chars: bytes = ...) -> bytearray: ... + def split(self, sep: Optional[bytes] = ..., maxsplit: int = ...) -> List[bytearray]: ... def splitlines(self, keepends: bool = ...) -> List[bytearray]: ... - def startswith(self, prefix: Union[str, Tuple[str, ...]]) -> bool: ... - def strip(self, chars: str = ...) -> bytearray: ... + def startswith(self, prefix: Union[bytes, Tuple[bytes, ...]]) -> bool: ... + def strip(self, chars: bytes = ...) -> bytearray: ... def swapcase(self) -> bytearray: ... def title(self) -> bytearray: ... - def translate(self, table: str) -> bytearray: ... + def translate(self, table: bytes) -> bytearray: ... def upper(self) -> bytearray: ... def zfill(self, width: int) -> bytearray: ... @staticmethod - def fromhex(x: str) -> bytearray: ... + def fromhex(x: bytes) -> bytearray: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[int]: ... @@ -483,19 +483,19 @@ class bytearray(MutableSequence[int]): @overload def __setitem__(self, i: int, x: int) -> None: ... @overload - def __setitem__(self, s: slice, x: Union[Iterable[int], str]) -> None: ... - def __setslice__(self, start: int, stop: int, x: Union[Sequence[int], str]) -> None: ... + def __setitem__(self, s: slice, x: Union[Iterable[int], bytes]) -> None: ... + def __setslice__(self, start: int, stop: int, x: Union[Sequence[int], bytes]) -> None: ... def __delitem__(self, i: Union[int, slice]) -> None: ... def __delslice__(self, start: int, stop: int) -> None: ... - def __add__(self, s: str) -> bytearray: ... + def __add__(self, s: bytes) -> bytearray: ... def __mul__(self, n: int) -> bytearray: ... def __contains__(self, o: object) -> bool: ... def __eq__(self, x: object) -> bool: ... def __ne__(self, x: object) -> bool: ... - def __lt__(self, x: str) -> bool: ... - def __le__(self, x: str) -> bool: ... - def __gt__(self, x: str) -> bool: ... - def __ge__(self, x: str) -> bool: ... + def __lt__(self, x: Text) -> bool: ... + def __le__(self, x: Text) -> bool: ... + def __gt__(self, x: Text) -> bool: ... + def __ge__(self, x: Text) -> bool: ... class bool(int): def __init__(self, o: object = ...) -> None: ... @@ -555,8 +555,8 @@ class tuple(Sequence[_T_co], Generic[_T_co]): class function: # TODO name of the class (corresponds to Python 'function' class) - __name__ = ... # type: str - __module__ = ... # type: str + __name__ = ... # type: Text + __module__ = ... # type: Text class list(MutableSequence[_T], Generic[_T]): @overload @@ -723,7 +723,7 @@ class xrange(Sized, Iterable[int], Reversible[int]): class property(object): def __init__(self, fget: Optional[Callable[[Any], Any]] = ..., fset: Optional[Callable[[Any, Any], None]] = ..., - fdel: Optional[Callable[[Any], None]] = ..., doc: Optional[str] = ...) -> None: ... + fdel: Optional[Callable[[Any], None]] = ..., doc: Optional[Text] = ...) -> None: ... def getter(self, fget: Callable[[Any], Any]) -> property: ... def setter(self, fset: Callable[[Any, Any], None]) -> property: ... def deleter(self, fdel: Callable[[Any], None]) -> property: ... @@ -745,9 +745,10 @@ def any(i: Iterable[object]) -> bool: ... def bin(number: int) -> str: ... def callable(o: object) -> bool: ... def chr(code: int) -> str: ... -def compile(source: Any, filename: unicode, mode: str, flags: int = ..., +def compile(source: Union[Text, mod], filename: Text, + mode: Text, flags: int = ..., dont_inherit: int = ...) -> Any: ... -def delattr(o: Any, name: unicode) -> None: ... +def delattr(o: Any, name: Text) -> None: ... def dir(o: object = ...) -> List[str]: ... @overload def divmod(a: int, b: int) -> Tuple[int, int]: ... @@ -769,9 +770,9 @@ def filter(__function: None, @overload def filter(__function: Callable[[_T], Any], __iterable: Iterable[_T]) -> List[_T]: ... -def format(o: object, format_spec: str = ...) -> str: ... # TODO unicode -def getattr(o: Any, name: unicode, default: Optional[Any] = ...) -> Any: ... -def hasattr(o: Any, name: unicode) -> bool: ... +def format(o: object, format_spec: AnyStr = ...) -> AnyStr: ... +def getattr(o: Any, name: Text, default: Optional[Any] = ...) -> Any: ... +def hasattr(o: Any, name: Text) -> bool: ... def hash(o: object) -> int: ... def hex(i: int) -> str: ... # TODO __index__ def id(o: object) -> int: ... @@ -864,14 +865,14 @@ def next(i: Iterator[_T]) -> _T: ... def next(i: Iterator[_T], default: _VT) -> Union[_T, _VT]: ... def oct(i: int) -> str: ... # TODO __index__ @overload -def open(file: str, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ... +def open(file: str, mode: Text = ..., buffering: int = ...) -> BinaryIO: ... @overload -def open(file: unicode, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ... +def open(file: unicode, mode: Text = ..., buffering: int = ...) -> BinaryIO: ... @overload -def open(file: int, mode: unicode = ..., buffering: int = ...) -> BinaryIO: ... -def ord(c: unicode) -> int: ... +def open(file: int, mode: Text = ..., buffering: int = ...) -> BinaryIO: ... +def ord(c: Text) -> int: ... # This is only available after from __future__ import print_function. -def print(*values: Any, sep: unicode = ..., end: unicode = ..., file: IO[Any] = ...) -> None: ... +def print(*values: Any, sep: Text = ..., end: Text = ..., file: IO[Any] = ...) -> None: ... @overload def pow(x: int, y: int) -> Any: ... # The return type can be int or float, depending on y. @overload @@ -903,7 +904,7 @@ def round(number: float, ndigits: int) -> float: ... # Always return a float if def round(number: SupportsRound[_T]) -> _T: ... @overload def round(number: SupportsRound[_T], ndigits: int) -> _T: ... -def setattr(object: Any, name: unicode, value: Any) -> None: ... +def setattr(object: Any, name: Text, value: Any) -> None: ... def sorted(iterable: Iterable[_T], *, cmp: Callable[[_T, _T], int] = ..., key: Callable[[_T], Any] = ..., @@ -932,10 +933,10 @@ def zip(iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], def zip(iter1: Iterable[Any], iter2: Iterable[Any], iter3: Iterable[Any], iter4: Iterable[Any], iter5: Iterable[Any], iter6: Iterable[Any], *iterables: Iterable[Any]) -> List[Tuple[Any, ...]]: ... -def __import__(name: unicode, - globals: Dict[str, Any] = ..., - locals: Dict[str, Any] = ..., - fromlist: List[str] = ..., level: int = ...) -> Any: ... +def __import__(name: Text, + globals: Dict[Text, Any] = ..., + locals: Dict[Text, Any] = ..., + fromlist: List[Text] = ..., level: int = ...) -> Any: ... def globals() -> Dict[str, Any]: ... def locals() -> Dict[str, Any]: ... @@ -1040,21 +1041,21 @@ class TypeError(StandardError): ... class UnboundLocalError(NameError): ... class UnicodeError(ValueError): ... class UnicodeDecodeError(UnicodeError): - encoding: bytes + encoding: str object: bytes start: int end: int - reason: bytes - def __init__(self, __encoding: bytes, __object: bytes, __start: int, __end: int, - __reason: bytes) -> None: ... + reason: str + def __init__(self, __encoding: str, __object: bytes, __start: int, __end: int, + __reason: str) -> None: ... class UnicodeEncodeError(UnicodeError): - encoding: bytes + encoding: str object: unicode start: int end: int - reason: bytes - def __init__(self, __encoding: bytes, __object: unicode, __start: int, __end: int, - __reason: bytes) -> None: ... + reason: str + def __init__(self, __encoding: str, __object: unicode, __start: int, __end: int, + __reason: str) -> None: ... class UnicodeTranslateError(UnicodeError): ... class ZeroDivisionError(ArithmeticError): ... @@ -1069,25 +1070,25 @@ class ImportWarning(Warning): ... class UnicodeWarning(Warning): ... class BytesWarning(Warning): ... -def eval(s: Union[str, unicode], globals: Dict[str, Any] = ..., locals: Dict[str, Any] = ...) -> Any: ... -def exec(object: str, - globals: Optional[Dict[str, Any]] = ..., - locals: Optional[Dict[str, Any]] = ...) -> Any: ... # TODO code object as source +def eval(s: Union[str, unicode], globals: Dict[Text, Any] = ..., locals: Dict[Text, Any] = ...) -> Any: ... +def exec(object: Text, + globals: Optional[Dict[Text, Any]] = ..., + locals: Optional[Dict[Text, Any]] = ...) -> Any: ... # TODO code object as source def cmp(x: Any, y: Any) -> int: ... -def execfile(filename: str, globals: Optional[Dict[str, Any]] = ..., locals: Optional[Dict[str, Any]] = ...) -> None: ... +def execfile(filename: Text, globals: Optional[Dict[Text, Any]] = ..., locals: Optional[Dict[str, Any]] = ...) -> None: ... class file(BinaryIO): @overload - def __init__(self, file: str, mode: str = ..., buffering: int = ...) -> None: ... + def __init__(self, file: str, mode: Text = ..., buffering: int = ...) -> None: ... @overload - def __init__(self, file: unicode, mode: str = ..., buffering: int = ...) -> None: ... + def __init__(self, file: unicode, mode: Text = ..., buffering: int = ...) -> None: ... @overload - def __init__(self, file: int, mode: str = ..., buffering: int = ...) -> None: ... - def __iter__(self) -> Iterator[str]: ... - def next(self) -> str: ... - def read(self, n: int = ...) -> str: ... + def __init__(self, file: int, mode: Text = ..., buffering: int = ...) -> None: ... + def __iter__(self) -> Iterator[bytes]: ... + def next(self) -> bytes: ... + def read(self, n: int = ...) -> bytes: ... def __enter__(self) -> BinaryIO: ... def __exit__(self, t: Optional[type] = ..., exc: Optional[BaseException] = ..., tb: Optional[Any] = ...) -> bool: ... def flush(self) -> None: ... @@ -1100,10 +1101,10 @@ class file(BinaryIO): def seekable(self) -> bool: ... def seek(self, offset: int, whence: int = ...) -> int: ... def tell(self) -> int: ... - def readline(self, limit: int = ...) -> str: ... - def readlines(self, hint: int = ...) -> List[str]: ... - def write(self, data: str) -> int: ... - def writelines(self, data: Iterable[str]) -> None: ... + def readline(self, limit: int = ...) -> bytes: ... + def readlines(self, hint: int = ...) -> List[bytes]: ... + def write(self, data: bytes) -> int: ... + def writelines(self, data: Iterable[bytes]) -> None: ... def truncate(self, pos: Optional[int] = ...) -> int: ... # Very old builtins diff --git a/stdlib/2/encodings/utf_8.pyi b/stdlib/2/encodings/utf_8.pyi index d38bd58d0e43..d2cc9bb3da3b 100644 --- a/stdlib/2/encodings/utf_8.pyi +++ b/stdlib/2/encodings/utf_8.pyi @@ -1,11 +1,12 @@ import codecs +from six import text_type as unicode from typing import Text, Tuple class IncrementalEncoder(codecs.IncrementalEncoder): def encode(self, input: Text, final: bool = ...) -> bytes: ... class IncrementalDecoder(codecs.BufferedIncrementalDecoder): - def _buffer_decode(self, input: bytes, errors: str, final: bool) -> Tuple[Text, int]: ... + def _buffer_decode(self, input: bytes, errors: str, final: bool) -> Tuple[unicode, int]: ... class StreamWriter(codecs.StreamWriter): ... class StreamReader(codecs.StreamReader): ... diff --git a/stdlib/2/json.pyi b/stdlib/2/json.pyi index 4a6fad49c5c8..c64e61dd7388 100644 --- a/stdlib/2/json.pyi +++ b/stdlib/2/json.pyi @@ -20,7 +20,7 @@ def dumps(obj: Any, **kwds: Any) -> str: ... def dump(obj: Any, - fp: Union[IO[str], IO[Text]], + fp: Union[IO[str], IO[unicode]], skipkeys: bool = ..., ensure_ascii: bool = ..., check_circular: bool = ..., diff --git a/stdlib/2/string.pyi b/stdlib/2/string.pyi index 751fd28a064f..71a0e9244080 100644 --- a/stdlib/2/string.pyi +++ b/stdlib/2/string.pyi @@ -2,7 +2,7 @@ # Based on http://docs.python.org/3.2/library/string.html -from typing import Mapping, Sequence, Any, Optional, Union, List, Tuple, Iterable, AnyStr +from typing import Mapping, Sequence, Any, Optional, Union, List, Text, Tuple, Iterable, AnyStr ascii_letters = ... # type: str ascii_lowercase = ... # type: str @@ -70,5 +70,5 @@ class Formatter(object): raise KeyError() def check_unused_args(self, used_args: Sequence[Union[int, str]], args: Sequence[Any], kwargs: Mapping[str, Any]) -> None: ... - def format_field(self, value: Any, format_spec: str) -> Any: ... + def format_field(self, value: Any, format_spec: Text) -> Any: ... def convert_field(self, value: Any, conversion: str) -> Any: ... diff --git a/stdlib/2/tempfile.pyi b/stdlib/2/tempfile.pyi index bad5b837a557..621bc7ab31eb 100644 --- a/stdlib/2/tempfile.pyi +++ b/stdlib/2/tempfile.pyi @@ -25,7 +25,7 @@ class _TemporaryFileWrapper(IO[str]): def __del__(self) -> None: ... def __enter__(self) -> _TemporaryFileWrapper: ... def __exit__(self, exc, value, tb) -> bool: ... - def __getattr__(self, name: unicode) -> Any: ... + def __getattr__(self, name: Text) -> Any: ... def close(self) -> None: ... def unlink(self, path: unicode) -> None: ... # These methods don't exist directly on this object, but diff --git a/stdlib/2/toaiff.pyi b/stdlib/2/toaiff.pyi index 77334c7f525e..9d641b741c72 100644 --- a/stdlib/2/toaiff.pyi +++ b/stdlib/2/toaiff.pyi @@ -2,10 +2,10 @@ # Source: https://hg.python.org/cpython/file/2.7/Lib/toaiff.py from pipes import Template -from typing import Dict, List +from typing import Dict, List, Text -__all__: List[str] +__all__: List[Text] table: Dict[str, Template] t: Template uncompress: Template diff --git a/stdlib/2/types.pyi b/stdlib/2/types.pyi index e4be0ef2f716..f884fcf2c299 100644 --- a/stdlib/2/types.pyi +++ b/stdlib/2/types.pyi @@ -3,7 +3,7 @@ from typing import ( Any, Callable, Dict, Iterable, Iterator, List, Optional, - Tuple, Type, TypeVar, Union, overload, + Text, Tuple, Type, TypeVar, Union, overload, ) _T = TypeVar('_T') @@ -33,9 +33,9 @@ class FunctionType: func_closure = ... # type: Optional[Tuple[_Cell, ...]] func_code = ... # type: CodeType func_defaults = ... # type: Optional[Tuple[Any, ...]] - func_dict = ... # type: Dict[str, Any] - func_doc = ... # type: Optional[str] - func_globals = ... # type: Dict[str, Any] + func_dict = ... # type: Dict[Text, Any] + func_doc = ... # type: Optional[Text] + func_globals = ... # type: Dict[Text, Any] func_name = ... # type: str __closure__ = func_closure __code__ = func_code @@ -98,13 +98,13 @@ class BuiltinFunctionType: BuiltinMethodType = BuiltinFunctionType class ModuleType: - __doc__ = ... # type: Optional[str] - __file__ = ... # type: Optional[str] - __name__ = ... # type: str - __package__ = ... # type: Optional[str] - __path__ = ... # type: Optional[Iterable[str]] - __dict__ = ... # type: Dict[str, Any] - def __init__(self, name: str, doc: Optional[str] = ...) -> None: ... + __doc__ = ... # type: Optional[Text] + __file__ = ... # type: Optional[Text] + __name__ = ... # type: Text + __package__ = ... # type: Optional[Text] + __path__ = ... # type: Optional[Iterable[Text]] + __dict__ = ... # type: Dict[Text, Any] + def __init__(self, name: Text, doc: Optional[Text] = ...) -> None: ... FileType = file XRangeType = xrange @@ -116,15 +116,15 @@ class TracebackType: class FrameType: f_back = ... # type: FrameType - f_builtins = ... # type: Dict[str, Any] + f_builtins = ... # type: Dict[Text, Any] f_code = ... # type: CodeType f_exc_type = ... # type: None f_exc_value = ... # type: None f_exc_traceback = ... # type: None - f_globals = ... # type: Dict[str, Any] + f_globals = ... # type: Dict[Text, Any] f_lasti = ... # type: int f_lineno = ... # type: int - f_locals = ... # type: Dict[str, Any] + f_locals = ... # type: Dict[Text, Any] f_restricted = ... # type: bool f_trace = ... # type: Callable[[], None] diff --git a/stdlib/2/typing.pyi b/stdlib/2/typing.pyi index ba621d72d71e..8fbb447e3af2 100644 --- a/stdlib/2/typing.pyi +++ b/stdlib/2/typing.pyi @@ -277,7 +277,7 @@ class MutableMapping(Mapping[_KT, _VT], Generic[_KT, _VT]): @overload def update(self, **kwargs: _VT) -> None: ... -Text = unicode +Text = Union[bytes, unicode] TYPE_CHECKING = True @@ -397,7 +397,7 @@ class Match(Generic[AnyStr]): # Pattern is generic over AnyStr (determining the type of its .pattern # attribute), but at the same time its methods take either bytes or # Text and return the same type, regardless of the type of the pattern. -_AnyStr2 = TypeVar('_AnyStr2', bytes, Text) +_AnyStr2 = TypeVar('_AnyStr2', bytes, unicode, Text) class Pattern(Generic[AnyStr]): flags: int diff --git a/stdlib/2/unittest.pyi b/stdlib/2/unittest.pyi index b0b39810d170..fc3b12a6639a 100644 --- a/stdlib/2/unittest.pyi +++ b/stdlib/2/unittest.pyi @@ -12,7 +12,7 @@ _T = TypeVar('_T') _FT = TypeVar('_FT') _ExceptionType = Union[Type[BaseException], Tuple[Type[BaseException], ...]] -_Regexp = Union[Text, Pattern[Text]] +_Regexp = Union[Text, Pattern[unicode], Pattern[str]] class Testable(metaclass=ABCMeta): @abstractmethod diff --git a/stdlib/2and3/codecs.pyi b/stdlib/2and3/codecs.pyi index 35be5a947820..8c8aeac40585 100644 --- a/stdlib/2and3/codecs.pyi +++ b/stdlib/2and3/codecs.pyi @@ -1,3 +1,4 @@ +from six import text_type as unicode import sys from typing import Any, BinaryIO, Callable, Generator, IO, Iterable, Iterator, List, Optional, Protocol, Text, TextIO, Tuple, Type, TypeVar, Union @@ -10,7 +11,7 @@ import types # There *are* bytes->bytes and str->str encodings in the standard library. # They are much more common in Python 2 than in Python 3. -_Decoded = Text +_Decoded = unicode _Encoded = bytes class _Encoder(Protocol): @@ -171,7 +172,7 @@ class StreamReaderWriter(TextIO): if sys.version_info >= (3,): def __next__(self) -> Text: ... else: - def next(self) -> Text: ... + def next(self) -> unicode: ... def __iter__(self: _T) -> _T: ... # This actually returns None, but that's incompatible with the supertype def write(self, data: _Decoded) -> int: ... diff --git a/stdlib/2and3/ctypes/__init__.pyi b/stdlib/2and3/ctypes/__init__.pyi index 87707b771366..eafadec01258 100644 --- a/stdlib/2and3/ctypes/__init__.pyi +++ b/stdlib/2and3/ctypes/__init__.pyi @@ -234,11 +234,11 @@ class _StructUnionMeta(_CDataMeta): _fields_: Sequence[_UnionT[Tuple[str, Type[_CData]], Tuple[str, Type[_CData], int]]] = ... _pack_: int = ... _anonymous_: Sequence[str] = ... - def __getattr__(self, name: str) -> _CField: ... + def __getattr__(self, name: Text) -> _CField: ... class _StructUnionBase(_CData, metaclass=_StructUnionMeta): def __init__(self, *args: Any, **kw: Any) -> None: ... - def __getattr__(self, name: str) -> Any: ... - def __setattr__(self, name: str, value: Any) -> None: ... + def __getattr__(self, name: Text) -> Any: ... + def __setattr__(self, name: Text, value: Any) -> None: ... class Union(_StructUnionBase): ... class Structure(_StructUnionBase): ... diff --git a/stdlib/2and3/decimal.pyi b/stdlib/2and3/decimal.pyi index 0eebc2e6f117..837e7a79bd35 100644 --- a/stdlib/2and3/decimal.pyi +++ b/stdlib/2and3/decimal.pyi @@ -2,7 +2,7 @@ import numbers import sys from types import TracebackType from typing import ( - Any, Container, Dict, List, NamedTuple, Optional, Sequence, Text, Tuple, Type, TypeVar, Union, + Any, AnyStr, Container, Dict, List, NamedTuple, Optional, Sequence, Text, Tuple, Type, TypeVar, Union, ) _Decimal = Union[Decimal, int] @@ -193,7 +193,7 @@ class Decimal(object): def __reduce__(self) -> Tuple[Type[Decimal], Tuple[str]]: ... def __copy__(self) -> Decimal: ... def __deepcopy__(self, memo: Any) -> Decimal: ... - def __format__(self, specifier: str, context: Optional[Context] = ...) -> str: ... + def __format__(self, specifier: AnyStr, context: Optional[Context] = ...) -> AnyStr: ... class _ContextManager(object): new_context: Context diff --git a/stdlib/2and3/imaplib.pyi b/stdlib/2and3/imaplib.pyi index ab32e7bac31f..f651e0335660 100644 --- a/stdlib/2and3/imaplib.pyi +++ b/stdlib/2and3/imaplib.pyi @@ -1,6 +1,7 @@ # Stubs for imaplib (Python 2) import imaplib +from six import text_type as unicode import subprocess import sys import time @@ -15,7 +16,7 @@ class IMAP4: error: Type[Exception] = ... abort: Type[Exception] = ... readonly: Type[Exception] = ... - mustquote: Pattern[Text] = ... + mustquote: Union[Pattern[str],Pattern[unicode]] = ... debug: int = ... state: str = ... literal: Optional[Text] = ... @@ -25,7 +26,7 @@ class IMAP4: is_readonly: bool = ... tagnum: int = ... tagpre: str = ... - tagre: Pattern[Text] = ... + tagre: Union[Pattern[str],Pattern[unicode]] = ... welcome: bytes = ... capabilities: Tuple[str] = ... PROTOCOL_VERSION: str = ... @@ -34,7 +35,7 @@ class IMAP4: host: str = ... port: int = ... sock: _socket = ... - file: Union[IO[Text], IO[bytes]] = ... + file: Union[IO[unicode], IO[bytes]] = ... def open(self, host: str = ..., port: int = ...) -> None: ... def read(self, size: int) -> bytes: ... def readline(self) -> bytes: ... diff --git a/stdlib/2and3/lib2to3/pgen2/driver.pyi b/stdlib/2and3/lib2to3/pgen2/driver.pyi index 56785f087313..f0a490ca2ac2 100644 --- a/stdlib/2and3/lib2to3/pgen2/driver.pyi +++ b/stdlib/2and3/lib2to3/pgen2/driver.pyi @@ -1,6 +1,7 @@ # Stubs for lib2to3.pgen2.driver (Python 3.6) import os +from six import text_type as unicode import sys from typing import Any, Callable, IO, Iterable, List, Optional, Text, Tuple, Union @@ -16,8 +17,8 @@ class Driver: convert: _Convert def __init__(self, grammar: Grammar, convert: Optional[_Convert] = ..., logger: Optional[Logger] = ...) -> None: ... def parse_tokens(self, tokens: Iterable[Any], debug: bool = ...) -> _NL: ... - def parse_stream_raw(self, stream: IO[Text], debug: bool = ...) -> _NL: ... - def parse_stream(self, stream: IO[Text], debug: bool = ...) -> _NL: ... + def parse_stream_raw(self, stream: Union[IO[str],IO[unicode]], debug: bool = ...) -> _NL: ... + def parse_stream(self, stream: Union[IO[str],IO[unicode]], debug: bool = ...) -> _NL: ... def parse_file(self, filename: _Path, encoding: Optional[Text] = ..., debug: bool = ...) -> _NL: ... def parse_string(self, text: Text, debug: bool = ...) -> _NL: ... diff --git a/stdlib/2and3/lib2to3/pgen2/pgen.pyi b/stdlib/2and3/lib2to3/pgen2/pgen.pyi index 42d503b4d3ea..aea1544d4bc6 100644 --- a/stdlib/2and3/lib2to3/pgen2/pgen.pyi +++ b/stdlib/2and3/lib2to3/pgen2/pgen.pyi @@ -1,7 +1,8 @@ # Stubs for lib2to3.pgen2.pgen (Python 3.6) +from six import text_type as unicode from typing import ( - Any, Dict, IO, Iterable, Iterator, List, NoReturn, Optional, Text, Tuple + Any, Dict, IO, Iterable, Iterator, List, NoReturn, Optional, Text, Tuple, Union ) from lib2to3.pgen2 import _Path, grammar @@ -11,10 +12,10 @@ class PgenGrammar(grammar.Grammar): ... class ParserGenerator: filename: _Path - stream: IO[Text] + stream: Union[IO[str],IO[unicode]] generator: Iterator[_TokenInfo] first: Dict[Text, Dict[Text, int]] - def __init__(self, filename: _Path, stream: Optional[IO[Text]] = ...) -> None: ... + def __init__(self, filename: _Path, stream: Optional[Union[IO[str],IO[unicode]]] = ...) -> None: ... def make_grammar(self) -> PgenGrammar: ... def make_first(self, c: PgenGrammar, name: Text) -> Dict[int, int]: ... def make_label(self, c: PgenGrammar, label: Text) -> int: ... diff --git a/stdlib/2and3/logging/__init__.pyi b/stdlib/2and3/logging/__init__.pyi index c84635d35b12..728b7bf36f9f 100644 --- a/stdlib/2and3/logging/__init__.pyi +++ b/stdlib/2and3/logging/__init__.pyi @@ -51,7 +51,7 @@ class Logger(Filterer): def setLevel(self, lvl: Union[int, str]) -> None: ... def isEnabledFor(self, lvl: int) -> bool: ... def getEffectiveLevel(self) -> int: ... - def getChild(self, suffix: str) -> Logger: ... + def getChild(self, suffix: Text) -> Logger: ... if sys.version_info >= (3,): def debug(self, msg: Any, *args: Any, exc_info: _ExcInfoType = ..., stack_info: bool = ..., extra: Optional[Dict[str, Any]] = ..., diff --git a/stdlib/2and3/plistlib.pyi b/stdlib/2and3/plistlib.pyi index d325930bd221..a4e7902a97c1 100644 --- a/stdlib/2and3/plistlib.pyi +++ b/stdlib/2and3/plistlib.pyi @@ -2,7 +2,7 @@ from typing import ( Any, IO, Mapping, MutableMapping, Optional, Union, - Type, TypeVar, + Text, Type, TypeVar, ) from typing import Dict as DictT import sys @@ -48,9 +48,9 @@ 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: ... - def __delattr__(self, attr: str) -> None: ... + def __getattr__(self, attr: Text) -> Any: ... + def __setattr__(self, attr: Text, value: Any) -> None: ... + def __delattr__(self, attr: Text) -> None: ... class Data: data = ... # type: bytes diff --git a/stdlib/2and3/poplib.pyi b/stdlib/2and3/poplib.pyi index d2b7dab6cf5c..a2d9ff7f64f6 100644 --- a/stdlib/2and3/poplib.pyi +++ b/stdlib/2and3/poplib.pyi @@ -1,11 +1,12 @@ # Stubs for poplib (Python 2 and 3) import socket +from six import text_type as unicode import ssl import sys from typing import ( Any, BinaryIO, Dict, List, NoReturn, Optional, overload, Pattern, Text, - Tuple, + Tuple, Union, ) _LongResp = Tuple[bytes, List[bytes], int] @@ -44,7 +45,7 @@ class POP3: def close(self) -> None: ... def rpop(self, user: Text) -> bytes: ... - timestamp: Pattern[Text] + timestamp: Union[Pattern[str],Pattern[unicode]] if sys.version_info < (3, 0): def apop(self, user: Text, secret: Text) -> bytes: ... diff --git a/stdlib/2and3/threading.pyi b/stdlib/2and3/threading.pyi index a76cd9c6d97d..c2e3bca98b6b 100644 --- a/stdlib/2and3/threading.pyi +++ b/stdlib/2and3/threading.pyi @@ -1,7 +1,7 @@ # Stubs for threading from typing import ( - Any, Callable, Iterable, List, Mapping, Optional, Tuple, Type, Union, + Any, Callable, Iterable, List, Mapping, Optional, Tuple, Text, Type, Union, TypeVar, ) from types import FrameType, TracebackType @@ -41,9 +41,9 @@ class ThreadError(Exception): ... class local(object): - def __getattribute__(self, name: str) -> Any: ... - def __setattr__(self, name: str, value: Any) -> None: ... - def __delattr__(self, name: str) -> None: ... + def __getattribute__(self, name: Text) -> Any: ... + def __setattr__(self, name: Text, value: Any) -> None: ... + def __delattr__(self, name: Text) -> None: ... class Thread: diff --git a/stdlib/2and3/unicodedata.pyi b/stdlib/2and3/unicodedata.pyi index c8e64610a83a..759d3fc9ca68 100644 --- a/stdlib/2and3/unicodedata.pyi +++ b/stdlib/2and3/unicodedata.pyi @@ -1,4 +1,5 @@ # Stubs for unicodedata (Python 2.7 and 3.4) +from six import text_type as unicode from typing import Any, Text, TypeVar, Union ucd_3_2_0 = ... # type: UCD @@ -17,7 +18,7 @@ def east_asian_width(__chr: Text) -> Text: ... def lookup(__name: Union[Text, bytes]) -> Text: ... def mirrored(__chr: Text) -> int: ... def name(__chr: Text, __default: _default = ...) -> Union[Text, _default]: ... -def normalize(__form: Text, __unistr: Text) -> Text: ... +def normalize(__form: Text, __unistr: unicode) -> unicode: ... def numeric(__chr: Text, __default: _default = ...) -> Union[float, _default]: ... class UCD(object): @@ -34,5 +35,5 @@ class UCD(object): def lookup(self, __name: Union[Text, bytes]) -> Text: ... def mirrored(self, __chr: Text) -> int: ... def name(self, __chr: Text, __default: _default = ...) -> Union[Text, _default]: ... - def normalize(self, __form: Text, __unistr: Text) -> Text: ... + def normalize(self, __form: Text, __unistr: unicode) -> unicode: ... def numeric(self, __chr: Text, __default: _default = ...) -> Union[float, _default]: ... diff --git a/third_party/2/enum.pyi b/third_party/2/enum.pyi index febc0dd5aaf7..3d6bd0763092 100644 --- a/third_party/2/enum.pyi +++ b/third_party/2/enum.pyi @@ -1,6 +1,6 @@ # NB: third_party/2/enum.pyi and stdlib/3.4/enum.pyi must remain consistent! import sys -from typing import Any, Iterator, List, Mapping, Type, TypeVar, Union +from typing import Any, AnyStr, Iterator, List, Mapping, Type, TypeVar, Union from abc import ABCMeta _T = TypeVar('_T') @@ -25,7 +25,7 @@ class Enum(metaclass=EnumMeta): def __repr__(self) -> str: ... def __str__(self) -> str: ... def __dir__(self) -> List[str]: ... - def __format__(self, format_spec: str) -> str: ... + def __format__(self, format_spec: AnyStr) -> AnyStr: ... def __hash__(self) -> Any: ... def __reduce_ex__(self, proto: object) -> Any: ... diff --git a/third_party/2/gflags.pyi b/third_party/2/gflags.pyi index a3daaa9827ad..a426197d1ace 100644 --- a/third_party/2/gflags.pyi +++ b/third_party/2/gflags.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, Iterable, IO, List, Optional, Union +from typing import Any, Callable, Dict, Iterable, IO, List, Optional, Text, Union from types import ModuleType class Error(Exception): ... @@ -53,8 +53,8 @@ class FlagValues: def __setitem__(self, name: str, flag: Flag) -> None: ... def __getitem__(self, name: str) -> Flag: ... def __getattr__(self, name: str) -> Any: ... - def __setattr__(self, name: str, value: Any): ... - def __delattr__(self, flag_name: str) -> None: ... + def __setattr__(self, name: Text, value: Any): ... + def __delattr__(self, flag_name: Text) -> None: ... def set_default(self, name: str, value: Any) -> None: ... SetDefault = set_default def __contains__(self, name: str) -> bool: ... @@ -121,11 +121,11 @@ class ArgumentParser(object): def WriteCustomInfoInXMLFormat(self, outfile: IO[str], indent: str) -> None: ... class ArgumentSerializer: - def Serialize(self, value: Any) -> unicode: ... + def Serialize(self, value: Any) -> Text: ... class ListSerializer(ArgumentSerializer): def __init__(self, list_sep: str) -> None: ... - def Serialize(self, value: List[Any]) -> str: ... + def Serialize(self, value: List[Any]) -> Text: ... def register_validator(flag_name: str, checker: Callable[[Any], bool], diff --git a/third_party/2and3/dateutil/tz/tz.pyi b/third_party/2and3/dateutil/tz/tz.pyi index 5fbc932bb737..5b4da973528e 100644 --- a/third_party/2and3/dateutil/tz/tz.pyi +++ b/third_party/2and3/dateutil/tz/tz.pyi @@ -1,10 +1,11 @@ +from six import text_type as unicode from typing import Any, Optional, Union, IO, Text, Tuple, List import datetime from ._common import tzname_in_python2 as tzname_in_python2, _tzinfo as _tzinfo from ._common import tzrangebase as tzrangebase, enfold as enfold from ..relativedelta import relativedelta -_FileObj = Union[str, Text, IO[str], IO[Text]] +_FileObj = Union[str, Text, IO[str], IO[unicode]] ZERO = ... # type: datetime.timedelta EPOCH = ... # type: datetime.datetime diff --git a/third_party/2and3/markupsafe/__init__.pyi b/third_party/2and3/markupsafe/__init__.pyi index 53d67a166f39..79e90de17881 100644 --- a/third_party/2and3/markupsafe/__init__.pyi +++ b/third_party/2and3/markupsafe/__init__.pyi @@ -10,21 +10,21 @@ from markupsafe._native import escape as escape, escape_silent as escape_silent, class Markup(text_type): def __new__(cls, base: Text = ..., encoding: Optional[Text] = ..., errors: Text = ...) -> Markup: ... def __html__(self) -> Markup: ... - def __add__(self, other: text_type) -> Markup: ... + def __add__(self, other: Text) -> Markup: ... def __radd__(self, other: text_type) -> Markup: ... def __mul__(self, num: int) -> Markup: ... def __rmul__(self, num: int) -> Markup: ... def __mod__(self, *args: Any) -> Markup: ... - def join(self, seq: Iterable[text_type]): ... - def split(self, sep: Optional[text_type] = ..., maxsplit: int = ...) -> List[text_type]: ... - def rsplit(self, sep: Optional[text_type] = ..., maxsplit: int = ...) -> List[text_type]: ... + def join(self, seq: Iterable[Text]): ... + def split(self, sep: Optional[Text] = ..., maxsplit: int = ...) -> List[text_type]: ... + def rsplit(self, sep: Optional[Text] = ..., maxsplit: int = ...) -> List[text_type]: ... def splitlines(self, keepends: bool = ...) -> List[text_type]: ... def unescape(self) -> Text: ... def striptags(self) -> Text: ... @classmethod def escape(cls, s: text_type) -> Markup: ... - def partition(self, sep: text_type) -> Tuple[Markup, Markup, Markup]: ... - def rpartition(self, sep: text_type) -> Tuple[Markup, Markup, Markup]: ... + def partition(self, sep: Text) -> Tuple[Markup, Markup, Markup]: ... + def rpartition(self, sep: Text) -> Tuple[Markup, Markup, Markup]: ... def format(self, *args, **kwargs) -> Markup: ... def __html_format__(self, format_spec) -> Markup: ... def __getslice__(self, start: int, stop: int) -> Markup: ... @@ -34,21 +34,21 @@ class Markup(text_type): def lower(self) -> Markup: ... def upper(self) -> Markup: ... def swapcase(self) -> Markup: ... - def replace(self, old: text_type, new: text_type, count: int = ...) -> Markup: ... - def ljust(self, width: int, fillchar: text_type = ...) -> Markup: ... - def rjust(self, width: int, fillchar: text_type = ...) -> Markup: ... - def lstrip(self, chars: Optional[text_type] = ...) -> Markup: ... - def rstrip(self, chars: Optional[text_type] = ...) -> Markup: ... - def strip(self, chars: Optional[text_type] = ...) -> Markup: ... - def center(self, width: int, fillchar: text_type = ...) -> Markup: ... + def replace(self, old: Text, new: Text, count: int = ...) -> Markup: ... + def ljust(self, width: int, fillchar: Text = ...) -> Markup: ... + def rjust(self, width: int, fillchar: Text = ...) -> Markup: ... + def lstrip(self, chars: Optional[Text] = ...) -> Markup: ... + def rstrip(self, chars: Optional[Text] = ...) -> Markup: ... + def strip(self, chars: Optional[Text] = ...) -> Markup: ... + def center(self, width: int, fillchar: Text = ...) -> Markup: ... def zfill(self, width: int) -> Markup: ... - def translate(self, table: Union[Mapping[int, Union[int, text_type, None]], Sequence[Union[int, text_type, None]]]) -> Markup: ... + def translate(self, table: Union[Mapping[int, Union[int, Text, None]], Sequence[Union[int, Text, None]]]) -> Markup: ... def expandtabs(self, tabsize: int = ...) -> Markup: ... class EscapeFormatter(string.Formatter): escape = ... # type: Callable[[text_type], Markup] def __init__(self, escape: Callable[[text_type], Markup]) -> None: ... - def format_field(self, value: text_type, format_spec: text_type) -> Markup: ... + def format_field(self, value: text_type, format_spec: Text) -> Markup: ... if sys.version_info[0] >= 3: soft_str = soft_unicode diff --git a/third_party/2and3/requests/structures.pyi b/third_party/2and3/requests/structures.pyi index 92cf27aa1cd5..07e2c29215ec 100644 --- a/third_party/2and3/requests/structures.pyi +++ b/third_party/2and3/requests/structures.pyi @@ -1,4 +1,4 @@ -from typing import Any, Dict, Iterable, Iterator, Mapping, MutableMapping, Optional, Tuple, TypeVar, Union, Generic +from typing import Any, Dict, Iterable, Iterator, Mapping, MutableMapping, Optional, Text, Tuple, TypeVar, Union, Generic _VT = TypeVar('_VT') @@ -15,5 +15,5 @@ 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: ... + def __getattr__(self, attr: Text) -> _VT: ... + def __setattr__(self, attr: Text, value: _VT) -> None: ...