diff --git a/stdlib/_csv.pyi b/stdlib/_csv.pyi index 9e9739149..45d05f478 100644 --- a/stdlib/_csv.pyi +++ b/stdlib/_csv.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, Iterator, List, Optional, Protocol, Text, Type, Union +from typing import Any, Iterable, Iterator, List, Optional, Protocol, Type, Union QUOTE_ALL: int QUOTE_MINIMAL: int @@ -34,7 +34,7 @@ class _Writer(Protocol): def write(self, s: str) -> Any: ... def writer(csvfile: _Writer, dialect: _DialectLike = ..., **fmtparams: Any) -> _writer: ... -def reader(csvfile: Iterable[Text], dialect: _DialectLike = ..., **fmtparams: Any) -> _reader: ... +def reader(csvfile: Iterable[str], dialect: _DialectLike = ..., **fmtparams: Any) -> _reader: ... def register_dialect(name: str, dialect: Any = ..., **fmtparams: Any) -> None: ... def unregister_dialect(name: str) -> None: ... def get_dialect(name: str) -> Dialect: ... diff --git a/stdlib/_dummy_threading.pyi b/stdlib/_dummy_threading.pyi index 3c680312b..de7537505 100644 --- a/stdlib/_dummy_threading.pyi +++ b/stdlib/_dummy_threading.pyi @@ -1,6 +1,6 @@ import sys from types import FrameType, TracebackType -from typing import Any, Callable, Iterable, List, Mapping, Optional, Text, Type, TypeVar, Union +from typing import Any, Callable, Iterable, List, Mapping, Optional, Type, TypeVar, Union # TODO recursive type _TF = Callable[[FrameType, str, Any], Optional[Callable[..., Any]]] @@ -51,7 +51,7 @@ class Thread: def run(self) -> None: ... def join(self, timeout: Optional[float] = ...) -> None: ... def getName(self) -> str: ... - def setName(self, name: Text) -> None: ... + def setName(self, name: str) -> None: ... if sys.version_info >= (3, 8): @property def native_id(self) -> Optional[int]: ... # only available on some platforms diff --git a/stdlib/_typeshed/wsgi.pyi b/stdlib/_typeshed/wsgi.pyi index bafaf7bc5..8fb053177 100644 --- a/stdlib/_typeshed/wsgi.pyi +++ b/stdlib/_typeshed/wsgi.pyi @@ -4,14 +4,14 @@ # file. They are provided for type checking purposes. from sys import _OptExcInfo -from typing import Any, Callable, Dict, Iterable, List, Optional, Protocol, Text, Tuple +from typing import Any, Callable, Dict, Iterable, List, Optional, Protocol, Tuple class StartResponse(Protocol): def __call__( self, status: str, headers: List[Tuple[str, str]], exc_info: Optional[_OptExcInfo] = ... ) -> Callable[[bytes], Any]: ... -WSGIEnvironment = Dict[Text, Any] +WSGIEnvironment = Dict[str, Any] WSGIApplication = Callable[[WSGIEnvironment, StartResponse], Iterable[bytes]] # WSGI input streams per PEP 3333 diff --git a/stdlib/aifc.pyi b/stdlib/aifc.pyi index 860cbd5cb..b43af47ff 100644 --- a/stdlib/aifc.pyi +++ b/stdlib/aifc.pyi @@ -1,6 +1,6 @@ import sys from types import TracebackType -from typing import IO, Any, List, NamedTuple, Optional, Text, Tuple, Type, Union, overload +from typing import IO, Any, List, NamedTuple, Optional, Tuple, Type, Union, overload from typing_extensions import Literal class Error(Exception): ... @@ -13,7 +13,7 @@ class _aifc_params(NamedTuple): comptype: bytes compname: bytes -_File = Union[Text, IO[bytes]] +_File = Union[str, IO[bytes]] _Marker = Tuple[int, int, bytes] class Aifc_read: diff --git a/stdlib/array.pyi b/stdlib/array.pyi index 20a3ff920..a215494d2 100644 --- a/stdlib/array.pyi +++ b/stdlib/array.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, BinaryIO, Generic, Iterable, List, MutableSequence, Text, Tuple, TypeVar, Union, overload +from typing import Any, BinaryIO, Generic, Iterable, List, MutableSequence, Tuple, TypeVar, Union, overload from typing_extensions import Literal _IntTypeCode = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"] @@ -7,7 +7,7 @@ _FloatTypeCode = Literal["f", "d"] _UnicodeTypeCode = Literal["u"] _TypeCode = Union[_IntTypeCode, _FloatTypeCode, _UnicodeTypeCode] -_T = TypeVar("_T", int, float, Text) +_T = TypeVar("_T", int, float, str) typecodes: str @@ -19,7 +19,7 @@ class array(MutableSequence[_T], Generic[_T]): @overload def __init__(self: array[float], typecode: _FloatTypeCode, __initializer: Union[bytes, Iterable[_T]] = ...) -> None: ... @overload - def __init__(self: array[Text], typecode: _UnicodeTypeCode, __initializer: Union[bytes, Iterable[_T]] = ...) -> None: ... + def __init__(self: array[str], typecode: _UnicodeTypeCode, __initializer: Union[bytes, Iterable[_T]] = ...) -> None: ... @overload def __init__(self, typecode: str, __initializer: Union[bytes, Iterable[_T]] = ...) -> None: ... def append(self, __v: _T) -> None: ... diff --git a/stdlib/codecs.pyi b/stdlib/codecs.pyi index 2e763c509..7172d0074 100644 --- a/stdlib/codecs.pyi +++ b/stdlib/codecs.pyi @@ -11,7 +11,6 @@ from typing import ( List, Optional, Protocol, - Text, TextIO, Tuple, Type, @@ -22,25 +21,22 @@ from typing import ( from typing_extensions import Literal # TODO: this only satisfies the most common interface, where -# bytes (py2 str) is the raw form and str (py2 unicode) is the cooked form. +# bytes is the raw form and str is the cooked form. # In the long run, both should become template parameters maybe? # 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 -_Encoded = bytes - class _Encoder(Protocol): - def __call__(self, input: _Decoded, errors: str = ...) -> Tuple[_Encoded, int]: ... # signature of Codec().encode + def __call__(self, input: str, errors: str = ...) -> Tuple[bytes, int]: ... # signature of Codec().encode class _Decoder(Protocol): - def __call__(self, input: _Encoded, errors: str = ...) -> Tuple[_Decoded, int]: ... # signature of Codec().decode + def __call__(self, input: bytes, errors: str = ...) -> Tuple[str, int]: ... # signature of Codec().decode class _StreamReader(Protocol): - def __call__(self, stream: IO[_Encoded], errors: str = ...) -> StreamReader: ... + def __call__(self, stream: IO[bytes], errors: str = ...) -> StreamReader: ... class _StreamWriter(Protocol): - def __call__(self, stream: IO[_Encoded], errors: str = ...) -> StreamWriter: ... + def __call__(self, stream: IO[bytes], errors: str = ...) -> StreamWriter: ... class _IncrementalEncoder(Protocol): def __call__(self, errors: str = ...) -> IncrementalEncoder: ... @@ -74,18 +70,16 @@ def encode(obj: bytes, encoding: _BytesToBytesEncodingT, errors: str = ...) -> b @overload def encode(obj: str, encoding: Literal["rot13", "rot_13"] = ..., errors: str = ...) -> str: ... # type: ignore @overload -def encode(obj: _Decoded, encoding: str = ..., errors: str = ...) -> _Encoded: ... +def encode(obj: str, encoding: str = ..., errors: str = ...) -> bytes: ... @overload def decode(obj: bytes, encoding: _BytesToBytesEncodingT, errors: str = ...) -> bytes: ... # type: ignore @overload -def decode(obj: str, encoding: Literal["rot13", "rot_13"] = ..., errors: str = ...) -> Text: ... +def decode(obj: str, encoding: Literal["rot13", "rot_13"] = ..., errors: str = ...) -> str: ... @overload -def decode(obj: _Encoded, encoding: str = ..., errors: str = ...) -> _Decoded: ... +def decode(obj: bytes, encoding: str = ..., errors: str = ...) -> str: ... def lookup(__encoding: str) -> CodecInfo: ... -def utf_16_be_decode( - __data: _Encoded, __errors: Optional[str] = ..., __final: bool = ... -) -> Tuple[_Decoded, int]: ... # undocumented -def utf_16_be_encode(__str: _Decoded, __errors: Optional[str] = ...) -> Tuple[_Encoded, int]: ... # undocumented +def utf_16_be_decode(__data: bytes, __errors: Optional[str] = ..., __final: bool = ...) -> Tuple[str, int]: ... # undocumented +def utf_16_be_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ... # undocumented class CodecInfo(Tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]): @property @@ -124,11 +118,9 @@ def register(__search_function: Callable[[str], Optional[CodecInfo]]) -> None: . def open( filename: str, mode: str = ..., encoding: Optional[str] = ..., errors: str = ..., buffering: int = ... ) -> StreamReaderWriter: ... -def EncodedFile( - file: IO[_Encoded], data_encoding: str, file_encoding: Optional[str] = ..., errors: str = ... -) -> StreamRecoder: ... -def iterencode(iterator: Iterable[_Decoded], encoding: str, errors: str = ...) -> Generator[_Encoded, None, None]: ... -def iterdecode(iterator: Iterable[_Encoded], encoding: str, errors: str = ...) -> Generator[_Decoded, None, None]: ... +def EncodedFile(file: IO[bytes], data_encoding: str, file_encoding: Optional[str] = ..., errors: str = ...) -> StreamRecoder: ... +def iterencode(iterator: Iterable[str], encoding: str, errors: str = ...) -> Generator[bytes, None, None]: ... +def iterdecode(iterator: Iterable[bytes], encoding: str, errors: str = ...) -> Generator[str, None, None]: ... BOM: bytes BOM_BE: bytes @@ -155,42 +147,42 @@ def backslashreplace_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], class Codec: # These are sort of @abstractmethod but sort of not. # The StreamReader and StreamWriter subclasses only implement one. - def encode(self, input: _Decoded, errors: str = ...) -> Tuple[_Encoded, int]: ... - def decode(self, input: _Encoded, errors: str = ...) -> Tuple[_Decoded, int]: ... + def encode(self, input: str, errors: str = ...) -> Tuple[bytes, int]: ... + def decode(self, input: bytes, errors: str = ...) -> Tuple[str, int]: ... class IncrementalEncoder: errors: str def __init__(self, errors: str = ...) -> None: ... @abstractmethod - def encode(self, input: _Decoded, final: bool = ...) -> _Encoded: ... + def encode(self, input: str, final: bool = ...) -> bytes: ... def reset(self) -> None: ... # documentation says int but str is needed for the subclass. - def getstate(self) -> Union[int, _Decoded]: ... - def setstate(self, state: Union[int, _Decoded]) -> None: ... + def getstate(self) -> Union[int, str]: ... + def setstate(self, state: Union[int, str]) -> None: ... class IncrementalDecoder: errors: str def __init__(self, errors: str = ...) -> None: ... @abstractmethod - def decode(self, input: _Encoded, final: bool = ...) -> _Decoded: ... + def decode(self, input: bytes, final: bool = ...) -> str: ... def reset(self) -> None: ... - def getstate(self) -> Tuple[_Encoded, int]: ... - def setstate(self, state: Tuple[_Encoded, int]) -> None: ... + def getstate(self) -> Tuple[bytes, int]: ... + def setstate(self, state: Tuple[bytes, int]) -> None: ... # These are not documented but used in encodings/*.py implementations. class BufferedIncrementalEncoder(IncrementalEncoder): buffer: str def __init__(self, errors: str = ...) -> None: ... @abstractmethod - def _buffer_encode(self, input: _Decoded, errors: str, final: bool) -> _Encoded: ... - def encode(self, input: _Decoded, final: bool = ...) -> _Encoded: ... + def _buffer_encode(self, input: str, errors: str, final: bool) -> bytes: ... + def encode(self, input: str, final: bool = ...) -> bytes: ... class BufferedIncrementalDecoder(IncrementalDecoder): buffer: bytes def __init__(self, errors: str = ...) -> None: ... @abstractmethod - def _buffer_decode(self, input: _Encoded, errors: str, final: bool) -> Tuple[_Decoded, int]: ... - def decode(self, input: _Encoded, final: bool = ...) -> _Decoded: ... + def _buffer_decode(self, input: bytes, errors: str, final: bool) -> Tuple[str, int]: ... + def decode(self, input: bytes, final: bool = ...) -> str: ... _SW = TypeVar("_SW", bound=StreamWriter) @@ -198,9 +190,9 @@ _SW = TypeVar("_SW", bound=StreamWriter) # attributes and methods are passed-through from the stream. class StreamWriter(Codec): errors: str - def __init__(self, stream: IO[_Encoded], errors: str = ...) -> None: ... - def write(self, object: _Decoded) -> None: ... - def writelines(self, list: Iterable[_Decoded]) -> None: ... + def __init__(self, stream: IO[bytes], errors: str = ...) -> None: ... + def write(self, object: str) -> None: ... + def writelines(self, list: Iterable[str]) -> None: ... def reset(self) -> None: ... def __enter__(self: _SW) -> _SW: ... def __exit__( @@ -212,16 +204,16 @@ _SR = TypeVar("_SR", bound=StreamReader) class StreamReader(Codec): errors: str - def __init__(self, stream: IO[_Encoded], errors: str = ...) -> None: ... - def read(self, size: int = ..., chars: int = ..., firstline: bool = ...) -> _Decoded: ... - def readline(self, size: Optional[int] = ..., keepends: bool = ...) -> _Decoded: ... - def readlines(self, sizehint: Optional[int] = ..., keepends: bool = ...) -> List[_Decoded]: ... + def __init__(self, stream: IO[bytes], errors: str = ...) -> None: ... + def read(self, size: int = ..., chars: int = ..., firstline: bool = ...) -> str: ... + def readline(self, size: Optional[int] = ..., keepends: bool = ...) -> str: ... + def readlines(self, sizehint: Optional[int] = ..., keepends: bool = ...) -> List[str]: ... def reset(self) -> None: ... def __enter__(self: _SR) -> _SR: ... def __exit__( self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType] ) -> None: ... - def __iter__(self) -> Iterator[_Decoded]: ... + def __iter__(self) -> Iterator[str]: ... def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ... _T = TypeVar("_T", bound=StreamReaderWriter) @@ -229,15 +221,15 @@ _T = TypeVar("_T", bound=StreamReaderWriter) # Doesn't actually inherit from TextIO, but wraps a BinaryIO to provide text reading and writing # and delegates attributes to the underlying binary stream with __getattr__. class StreamReaderWriter(TextIO): - def __init__(self, stream: IO[_Encoded], Reader: _StreamReader, Writer: _StreamWriter, errors: str = ...) -> None: ... - def read(self, size: int = ...) -> _Decoded: ... - def readline(self, size: Optional[int] = ...) -> _Decoded: ... - def readlines(self, sizehint: Optional[int] = ...) -> List[_Decoded]: ... - def __next__(self) -> Text: ... + def __init__(self, stream: IO[bytes], Reader: _StreamReader, Writer: _StreamWriter, errors: str = ...) -> None: ... + def read(self, size: int = ...) -> str: ... + def readline(self, size: Optional[int] = ...) -> str: ... + def readlines(self, sizehint: Optional[int] = ...) -> List[str]: ... + def __next__(self) -> str: ... def __iter__(self: _T) -> _T: ... # This actually returns None, but that's incompatible with the supertype - def write(self, data: _Decoded) -> int: ... - def writelines(self, list: Iterable[_Decoded]) -> None: ... + def write(self, data: str) -> int: ... + def writelines(self, list: Iterable[str]) -> None: ... def reset(self) -> None: ... # Same as write() def seek(self, offset: int, whence: int = ...) -> int: ... @@ -263,7 +255,7 @@ _SRT = TypeVar("_SRT", bound=StreamRecoder) class StreamRecoder(BinaryIO): def __init__( self, - stream: IO[_Encoded], + stream: IO[bytes], encode: _Encoder, decode: _Decoder, Reader: _StreamReader, diff --git a/stdlib/csv.pyi b/stdlib/csv.pyi index 259b78f21..25a9e4aeb 100644 --- a/stdlib/csv.pyi +++ b/stdlib/csv.pyi @@ -17,7 +17,7 @@ from _csv import ( unregister_dialect as unregister_dialect, writer as writer, ) -from typing import Any, Generic, Iterable, Iterator, List, Mapping, Optional, Sequence, Text, Type, TypeVar, overload +from typing import Any, Generic, Iterable, Iterator, List, Mapping, Optional, Sequence, Type, TypeVar, overload if sys.version_info >= (3, 8): from typing import Dict as _DictReadMapping @@ -55,7 +55,7 @@ class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]): @overload def __init__( self, - f: Iterable[Text], + f: Iterable[str], fieldnames: Sequence[_T], restkey: Optional[str] = ..., restval: Optional[str] = ..., @@ -66,7 +66,7 @@ class DictReader(Generic[_T], Iterator[_DictReadMapping[_T, str]]): @overload def __init__( self: DictReader[str], - f: Iterable[Text], + f: Iterable[str], fieldnames: Optional[Sequence[str]] = ..., restkey: Optional[str] = ..., restval: Optional[str] = ..., diff --git a/stdlib/ctypes/__init__.pyi b/stdlib/ctypes/__init__.pyi index c55d9413d..131bb4d7e 100644 --- a/stdlib/ctypes/__init__.pyi +++ b/stdlib/ctypes/__init__.pyi @@ -11,7 +11,6 @@ from typing import ( Mapping, Optional, Sequence, - Text, Tuple, Type, TypeVar, @@ -166,7 +165,7 @@ def create_string_buffer(init: _UnionT[int, bytes], size: Optional[int] = ...) - c_buffer = create_string_buffer -def create_unicode_buffer(init: _UnionT[int, Text], size: Optional[int] = ...) -> Array[c_wchar]: ... +def create_unicode_buffer(init: _UnionT[int, str], size: Optional[int] = ...) -> Array[c_wchar]: ... if sys.platform == "win32": def DllCanUnloadNow() -> int: ... @@ -248,10 +247,10 @@ class c_ulong(_SimpleCData[int]): ... class c_ulonglong(_SimpleCData[int]): ... class c_ushort(_SimpleCData[int]): ... class c_void_p(_PointerLike, _SimpleCData[Optional[int]]): ... -class c_wchar(_SimpleCData[Text]): ... +class c_wchar(_SimpleCData[str]): ... -class c_wchar_p(_PointerLike, _SimpleCData[Optional[Text]]): - def __init__(self, value: Optional[_UnionT[int, Text]] = ...) -> None: ... +class c_wchar_p(_PointerLike, _SimpleCData[Optional[str]]): + def __init__(self, value: Optional[_UnionT[int, str]] = ...) -> None: ... class c_bool(_SimpleCData[bool]): def __init__(self, value: bool = ...) -> None: ... @@ -285,7 +284,7 @@ class Array(Generic[_CT], _CData): _length_: ClassVar[int] = ... _type_: ClassVar[Type[_CT]] = ... raw: bytes = ... # Note: only available if _CT == c_char - value: Any = ... # Note: bytes if _CT == c_char, Text if _CT == c_wchar, unavailable otherwise + value: Any = ... # Note: bytes if _CT == c_char, str if _CT == c_wchar, unavailable otherwise # TODO These methods cannot be annotated correctly at the moment. # All of these "Any"s stand for the array's element type, but it's not possible to use _CT # here, because of a special feature of ctypes. diff --git a/stdlib/decimal.pyi b/stdlib/decimal.pyi index caf37df0f..f63243853 100644 --- a/stdlib/decimal.pyi +++ b/stdlib/decimal.pyi @@ -1,9 +1,9 @@ import numbers from types import TracebackType -from typing import Any, Container, Dict, List, NamedTuple, Optional, Sequence, Text, Tuple, Type, TypeVar, Union, overload +from typing import Any, Container, Dict, List, NamedTuple, Optional, Sequence, Tuple, Type, TypeVar, Union, overload _Decimal = Union[Decimal, int] -_DecimalNew = Union[Decimal, float, Text, Tuple[int, Sequence[int], int]] +_DecimalNew = Union[Decimal, float, str, Tuple[int, Sequence[int], int]] _ComparableNum = Union[Decimal, float, numbers.Rational] _DecimalT = TypeVar("_DecimalT", bound=Decimal) diff --git a/stdlib/ftplib.pyi b/stdlib/ftplib.pyi index f2611ffda..c474da2e3 100644 --- a/stdlib/ftplib.pyi +++ b/stdlib/ftplib.pyi @@ -2,11 +2,10 @@ from _typeshed import SupportsRead, SupportsReadline from socket import socket from ssl import SSLContext from types import TracebackType -from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Text, TextIO, Tuple, Type, TypeVar, Union +from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, TextIO, Tuple, Type, TypeVar, Union from typing_extensions import Literal _T = TypeVar("_T") -_IntOrStr = Union[int, Text] MSG_OOB: int FTP_PORT: int @@ -24,11 +23,7 @@ all_errors: Tuple[Type[Exception], ...] class FTP: debugging: int - - # Note: This is technically the type that's passed in as the host argument. But to make it easier in Python 2 we - # accept Text but return str. host: str - port: int maxline: int sock: Optional[socket] @@ -46,62 +41,62 @@ class FTP: source_address: Optional[Tuple[str, int]] def __init__( self, - host: Text = ..., - user: Text = ..., - passwd: Text = ..., - acct: Text = ..., + host: str = ..., + user: str = ..., + passwd: str = ..., + acct: str = ..., timeout: float = ..., source_address: Optional[Tuple[str, int]] = ..., ) -> None: ... def connect( - self, host: Text = ..., port: int = ..., timeout: float = ..., source_address: Optional[Tuple[str, int]] = ... + self, host: str = ..., port: int = ..., timeout: float = ..., source_address: Optional[Tuple[str, int]] = ... ) -> str: ... def getwelcome(self) -> str: ... def set_debuglevel(self, level: int) -> None: ... def debug(self, level: int) -> None: ... def set_pasv(self, val: Union[bool, int]) -> None: ... - def sanitize(self, s: Text) -> str: ... - def putline(self, line: Text) -> None: ... - def putcmd(self, line: Text) -> None: ... + def sanitize(self, s: str) -> str: ... + def putline(self, line: str) -> None: ... + def putcmd(self, line: str) -> None: ... def getline(self) -> str: ... def getmultiline(self) -> str: ... def getresp(self) -> str: ... def voidresp(self) -> str: ... def abort(self) -> str: ... - def sendcmd(self, cmd: Text) -> str: ... - def voidcmd(self, cmd: Text) -> str: ... - def sendport(self, host: Text, port: int) -> str: ... - def sendeprt(self, host: Text, port: int) -> str: ... + def sendcmd(self, cmd: str) -> str: ... + def voidcmd(self, cmd: str) -> str: ... + def sendport(self, host: str, port: int) -> str: ... + def sendeprt(self, host: str, port: int) -> str: ... def makeport(self) -> socket: ... def makepasv(self) -> Tuple[str, int]: ... - def login(self, user: Text = ..., passwd: Text = ..., acct: Text = ...) -> str: ... + def login(self, user: str = ..., passwd: str = ..., acct: str = ...) -> str: ... # In practice, `rest` rest can actually be anything whose str() is an integer sequence, so to make it simple we allow integers. - def ntransfercmd(self, cmd: Text, rest: Optional[_IntOrStr] = ...) -> Tuple[socket, int]: ... - def transfercmd(self, cmd: Text, rest: Optional[_IntOrStr] = ...) -> socket: ... + def ntransfercmd(self, cmd: str, rest: Optional[Union[int, str]] = ...) -> Tuple[socket, int]: ... + def transfercmd(self, cmd: str, rest: Optional[Union[int, str]] = ...) -> socket: ... def retrbinary( - self, cmd: Text, callback: Callable[[bytes], Any], blocksize: int = ..., rest: Optional[_IntOrStr] = ... + self, cmd: str, callback: Callable[[bytes], Any], blocksize: int = ..., rest: Optional[Union[int, str]] = ... ) -> str: ... def storbinary( self, - cmd: Text, + cmd: str, fp: SupportsRead[bytes], blocksize: int = ..., callback: Optional[Callable[[bytes], Any]] = ..., - rest: Optional[_IntOrStr] = ..., + rest: Optional[Union[int, str]] = ..., ) -> str: ... - def retrlines(self, cmd: Text, callback: Optional[Callable[[str], Any]] = ...) -> str: ... - def storlines(self, cmd: Text, fp: SupportsReadline[bytes], callback: Optional[Callable[[bytes], Any]] = ...) -> str: ... - def acct(self, password: Text) -> str: ... - def nlst(self, *args: Text) -> List[str]: ... + def retrlines(self, cmd: str, callback: Optional[Callable[[str], Any]] = ...) -> str: ... + def storlines(self, cmd: str, fp: SupportsReadline[bytes], callback: Optional[Callable[[bytes], Any]] = ...) -> str: ... + def acct(self, password: str) -> str: ... + def nlst(self, *args: str) -> List[str]: ... # Technically only the last arg can be a Callable but ... def dir(self, *args: Union[str, Callable[[str], None]]) -> None: ... - def mlsd(self, path: Text = ..., facts: Iterable[str] = ...) -> Iterator[Tuple[str, Dict[str, str]]]: ... - def rename(self, fromname: Text, toname: Text) -> str: ... - def delete(self, filename: Text) -> str: ... - def cwd(self, dirname: Text) -> str: ... - def size(self, filename: Text) -> Optional[int]: ... - def mkd(self, dirname: Text) -> str: ... - def rmd(self, dirname: Text) -> str: ... + def mlsd(self, path: str = ..., facts: Iterable[str] = ...) -> Iterator[Tuple[str, Dict[str, str]]]: ... + def rename(self, fromname: str, toname: str) -> str: ... + def delete(self, filename: str) -> str: ... + def cwd(self, dirname: str) -> str: ... + def size(self, filename: str) -> Optional[int]: ... + def mkd(self, dirname: str) -> str: ... + def rmd(self, dirname: str) -> str: ... def pwd(self) -> str: ... def quit(self) -> str: ... def close(self) -> None: ... @@ -109,10 +104,10 @@ class FTP: class FTP_TLS(FTP): def __init__( self, - host: Text = ..., - user: Text = ..., - passwd: Text = ..., - acct: Text = ..., + host: str = ..., + user: str = ..., + passwd: str = ..., + acct: str = ..., keyfile: Optional[str] = ..., certfile: Optional[str] = ..., context: Optional[SSLContext] = ..., @@ -123,7 +118,7 @@ class FTP_TLS(FTP): keyfile: Optional[str] certfile: Optional[str] context: SSLContext - def login(self, user: Text = ..., passwd: Text = ..., acct: Text = ..., secure: bool = ...) -> str: ... + def login(self, user: str = ..., passwd: str = ..., acct: str = ..., secure: bool = ...) -> str: ... def auth(self) -> str: ... def prot_p(self) -> str: ... def prot_c(self) -> str: ... diff --git a/stdlib/imaplib.pyi b/stdlib/imaplib.pyi index ced7dc196..9fc3a740c 100644 --- a/stdlib/imaplib.pyi +++ b/stdlib/imaplib.pyi @@ -4,7 +4,7 @@ import time from socket import socket as _socket from ssl import SSLContext, SSLSocket from types import TracebackType -from typing import IO, Any, Callable, Dict, List, Optional, Pattern, Text, Tuple, Type, Union +from typing import IO, Any, Callable, Dict, List, Optional, Pattern, Tuple, Type, Union from typing_extensions import Literal # TODO: Commands should use their actual return types, not this type alias. @@ -17,17 +17,17 @@ class IMAP4: error: Type[Exception] = ... abort: Type[Exception] = ... readonly: Type[Exception] = ... - mustquote: Pattern[Text] = ... + mustquote: Pattern[str] = ... debug: int = ... state: str = ... - literal: Optional[Text] = ... + literal: Optional[str] = ... tagged_commands: Dict[bytes, Optional[List[bytes]]] untagged_responses: Dict[str, List[Union[bytes, Tuple[bytes, bytes]]]] continuation_response: str = ... is_readonly: bool = ... tagnum: int = ... tagpre: str = ... - tagre: Pattern[Text] = ... + tagre: Pattern[str] = ... welcome: bytes = ... capabilities: Tuple[str] = ... PROTOCOL_VERSION: str = ... @@ -41,7 +41,7 @@ class IMAP4: host: str = ... port: int = ... sock: _socket = ... - file: Union[IO[Text], IO[bytes]] = ... + file: Union[IO[str], IO[bytes]] = ... def read(self, size: int) -> bytes: ... def readline(self) -> bytes: ... def send(self, data: bytes) -> None: ... diff --git a/stdlib/keyword.pyi b/stdlib/keyword.pyi index 3e095ed5f..ac052feeb 100644 --- a/stdlib/keyword.pyi +++ b/stdlib/keyword.pyi @@ -1,7 +1,7 @@ import sys -from typing import Sequence, Text +from typing import Sequence -def iskeyword(s: Text) -> bool: ... +def iskeyword(s: str) -> bool: ... kwlist: Sequence[str] diff --git a/stdlib/lib2to3/pgen2/driver.pyi b/stdlib/lib2to3/pgen2/driver.pyi index 841b0e4b1..f50cbd78b 100644 --- a/stdlib/lib2to3/pgen2/driver.pyi +++ b/stdlib/lib2to3/pgen2/driver.pyi @@ -2,7 +2,7 @@ from _typeshed import StrPath from lib2to3.pgen2.grammar import Grammar from lib2to3.pytree import _NL, _Convert from logging import Logger -from typing import IO, Any, Iterable, Optional, Text +from typing import IO, Any, Iterable, Optional class Driver: grammar: Grammar @@ -10,11 +10,11 @@ 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_file(self, filename: StrPath, encoding: Optional[Text] = ..., debug: bool = ...) -> _NL: ... - def parse_string(self, text: Text, debug: bool = ...) -> _NL: ... + def parse_stream_raw(self, stream: IO[str], debug: bool = ...) -> _NL: ... + def parse_stream(self, stream: IO[str], debug: bool = ...) -> _NL: ... + def parse_file(self, filename: StrPath, encoding: Optional[str] = ..., debug: bool = ...) -> _NL: ... + def parse_string(self, text: str, debug: bool = ...) -> _NL: ... def load_grammar( - gt: Text = ..., gp: Optional[Text] = ..., save: bool = ..., force: bool = ..., logger: Optional[Logger] = ... + gt: str = ..., gp: Optional[str] = ..., save: bool = ..., force: bool = ..., logger: Optional[Logger] = ... ) -> Grammar: ... diff --git a/stdlib/lib2to3/pgen2/grammar.pyi b/stdlib/lib2to3/pgen2/grammar.pyi index 6ec97ce84..fe250cfe7 100644 --- a/stdlib/lib2to3/pgen2/grammar.pyi +++ b/stdlib/lib2to3/pgen2/grammar.pyi @@ -1,20 +1,20 @@ from _typeshed import StrPath -from typing import Dict, List, Optional, Text, Tuple, TypeVar +from typing import Dict, List, Optional, Tuple, TypeVar _P = TypeVar("_P") -_Label = Tuple[int, Optional[Text]] +_Label = Tuple[int, Optional[str]] _DFA = List[List[Tuple[int, int]]] _DFAS = Tuple[_DFA, Dict[int, int]] class Grammar: - symbol2number: Dict[Text, int] - number2symbol: Dict[int, Text] + symbol2number: Dict[str, int] + number2symbol: Dict[int, str] states: List[_DFA] dfas: Dict[int, _DFAS] labels: List[_Label] - keywords: Dict[Text, int] + keywords: Dict[str, int] tokens: Dict[int, int] - symbol2label: Dict[Text, int] + symbol2label: Dict[str, int] start: int def __init__(self) -> None: ... def dump(self, filename: StrPath) -> None: ... @@ -22,5 +22,5 @@ class Grammar: def copy(self: _P) -> _P: ... def report(self) -> None: ... -opmap_raw: Text -opmap: Dict[Text, Text] +opmap_raw: str +opmap: Dict[str, str] diff --git a/stdlib/lib2to3/pgen2/literals.pyi b/stdlib/lib2to3/pgen2/literals.pyi index 160d6fd76..4c162ecf2 100644 --- a/stdlib/lib2to3/pgen2/literals.pyi +++ b/stdlib/lib2to3/pgen2/literals.pyi @@ -1,7 +1,7 @@ -from typing import Dict, Match, Text +from typing import Dict, Match -simple_escapes: Dict[Text, Text] +simple_escapes: Dict[str, str] -def escape(m: Match[str]) -> Text: ... -def evalString(s: Text) -> Text: ... +def escape(m: Match[str]) -> str: ... +def evalString(s: str) -> str: ... def test() -> None: ... diff --git a/stdlib/lib2to3/pgen2/parse.pyi b/stdlib/lib2to3/pgen2/parse.pyi index b7018cba9..c84d2cdf7 100644 --- a/stdlib/lib2to3/pgen2/parse.pyi +++ b/stdlib/lib2to3/pgen2/parse.pyi @@ -1,26 +1,26 @@ from lib2to3.pgen2.grammar import _DFAS, Grammar from lib2to3.pytree import _NL, _Convert, _RawNode -from typing import Any, List, Optional, Sequence, Set, Text, Tuple +from typing import Any, List, Optional, Sequence, Set, Tuple _Context = Sequence[Any] class ParseError(Exception): - msg: Text + msg: str type: int - value: Optional[Text] + value: Optional[str] context: _Context - def __init__(self, msg: Text, type: int, value: Optional[Text], context: _Context) -> None: ... + def __init__(self, msg: str, type: int, value: Optional[str], context: _Context) -> None: ... class Parser: grammar: Grammar convert: _Convert stack: List[Tuple[_DFAS, int, _RawNode]] rootnode: Optional[_NL] - used_names: Set[Text] + used_names: Set[str] def __init__(self, grammar: Grammar, convert: Optional[_Convert] = ...) -> None: ... def setup(self, start: Optional[int] = ...) -> None: ... - def addtoken(self, type: int, value: Optional[Text], context: _Context) -> bool: ... - def classify(self, type: int, value: Optional[Text], context: _Context) -> int: ... - def shift(self, type: int, value: Optional[Text], newstate: int, context: _Context) -> None: ... + def addtoken(self, type: int, value: Optional[str], context: _Context) -> bool: ... + def classify(self, type: int, value: Optional[str], context: _Context) -> int: ... + def shift(self, type: int, value: Optional[str], newstate: int, context: _Context) -> None: ... def push(self, type: int, newdfa: _DFAS, newstate: int, context: _Context) -> None: ... def pop(self) -> None: ... diff --git a/stdlib/lib2to3/pgen2/pgen.pyi b/stdlib/lib2to3/pgen2/pgen.pyi index 7920262f4..6909eed9b 100644 --- a/stdlib/lib2to3/pgen2/pgen.pyi +++ b/stdlib/lib2to3/pgen2/pgen.pyi @@ -1,45 +1,45 @@ from _typeshed import StrPath from lib2to3.pgen2 import grammar from lib2to3.pgen2.tokenize import _TokenInfo -from typing import IO, Any, Dict, Iterable, Iterator, List, NoReturn, Optional, Text, Tuple +from typing import IO, Any, Dict, Iterable, Iterator, List, NoReturn, Optional, Tuple class PgenGrammar(grammar.Grammar): ... class ParserGenerator: filename: StrPath - stream: IO[Text] + stream: IO[str] generator: Iterator[_TokenInfo] - first: Dict[Text, Dict[Text, int]] - def __init__(self, filename: StrPath, stream: Optional[IO[Text]] = ...) -> None: ... + first: Dict[str, Dict[str, int]] + def __init__(self, filename: StrPath, stream: Optional[IO[str]] = ...) -> 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: ... + def make_first(self, c: PgenGrammar, name: str) -> Dict[int, int]: ... + def make_label(self, c: PgenGrammar, label: str) -> int: ... def addfirstsets(self) -> None: ... - def calcfirst(self, name: Text) -> None: ... - def parse(self) -> Tuple[Dict[Text, List[DFAState]], Text]: ... + def calcfirst(self, name: str) -> None: ... + def parse(self) -> Tuple[Dict[str, List[DFAState]], str]: ... def make_dfa(self, start: NFAState, finish: NFAState) -> List[DFAState]: ... - def dump_nfa(self, name: Text, start: NFAState, finish: NFAState) -> List[DFAState]: ... - def dump_dfa(self, name: Text, dfa: Iterable[DFAState]) -> None: ... + def dump_nfa(self, name: str, start: NFAState, finish: NFAState) -> List[DFAState]: ... + def dump_dfa(self, name: str, dfa: Iterable[DFAState]) -> None: ... def simplify_dfa(self, dfa: List[DFAState]) -> None: ... def parse_rhs(self) -> Tuple[NFAState, NFAState]: ... def parse_alt(self) -> Tuple[NFAState, NFAState]: ... def parse_item(self) -> Tuple[NFAState, NFAState]: ... def parse_atom(self) -> Tuple[NFAState, NFAState]: ... - def expect(self, type: int, value: Optional[Any] = ...) -> Text: ... + def expect(self, type: int, value: Optional[Any] = ...) -> str: ... def gettoken(self) -> None: ... def raise_error(self, msg: str, *args: Any) -> NoReturn: ... class NFAState: - arcs: List[Tuple[Optional[Text], NFAState]] + arcs: List[Tuple[Optional[str], NFAState]] def __init__(self) -> None: ... - def addarc(self, next: NFAState, label: Optional[Text] = ...) -> None: ... + def addarc(self, next: NFAState, label: Optional[str] = ...) -> None: ... class DFAState: nfaset: Dict[NFAState, Any] isfinal: bool - arcs: Dict[Text, DFAState] + arcs: Dict[str, DFAState] def __init__(self, nfaset: Dict[NFAState, Any], final: NFAState) -> None: ... - def addarc(self, next: DFAState, label: Text) -> None: ... + def addarc(self, next: DFAState, label: str) -> None: ... def unifystate(self, old: DFAState, new: DFAState) -> None: ... def __eq__(self, other: Any) -> bool: ... diff --git a/stdlib/lib2to3/pgen2/token.pyi b/stdlib/lib2to3/pgen2/token.pyi index 98583df33..86cafdcbb 100644 --- a/stdlib/lib2to3/pgen2/token.pyi +++ b/stdlib/lib2to3/pgen2/token.pyi @@ -1,4 +1,4 @@ -from typing import Dict, Text +from typing import Dict ENDMARKER: int NAME: int @@ -61,7 +61,7 @@ ASYNC: int ERRORTOKEN: int N_TOKENS: int NT_OFFSET: int -tok_name: Dict[int, Text] +tok_name: Dict[int, str] def ISTERMINAL(x: int) -> bool: ... def ISNONTERMINAL(x: int) -> bool: ... diff --git a/stdlib/lib2to3/pgen2/tokenize.pyi b/stdlib/lib2to3/pgen2/tokenize.pyi index 477341c1a..116f77a69 100644 --- a/stdlib/lib2to3/pgen2/tokenize.pyi +++ b/stdlib/lib2to3/pgen2/tokenize.pyi @@ -1,23 +1,23 @@ from lib2to3.pgen2.token import * # noqa -from typing import Callable, Iterable, Iterator, List, Text, Tuple +from typing import Callable, Iterable, Iterator, List, Tuple _Coord = Tuple[int, int] -_TokenEater = Callable[[int, Text, _Coord, _Coord, Text], None] -_TokenInfo = Tuple[int, Text, _Coord, _Coord, Text] +_TokenEater = Callable[[int, str, _Coord, _Coord, str], None] +_TokenInfo = Tuple[int, str, _Coord, _Coord, str] class TokenError(Exception): ... class StopTokenizing(Exception): ... -def tokenize(readline: Callable[[], Text], tokeneater: _TokenEater = ...) -> None: ... +def tokenize(readline: Callable[[], str], tokeneater: _TokenEater = ...) -> None: ... class Untokenizer: - tokens: List[Text] + tokens: List[str] prev_row: int prev_col: int def __init__(self) -> None: ... def add_whitespace(self, start: _Coord) -> None: ... - def untokenize(self, iterable: Iterable[_TokenInfo]) -> Text: ... - def compat(self, token: Tuple[int, Text], iterable: Iterable[_TokenInfo]) -> None: ... + def untokenize(self, iterable: Iterable[_TokenInfo]) -> str: ... + def compat(self, token: Tuple[int, str], iterable: Iterable[_TokenInfo]) -> None: ... -def untokenize(iterable: Iterable[_TokenInfo]) -> Text: ... -def generate_tokens(readline: Callable[[], Text]) -> Iterator[_TokenInfo]: ... +def untokenize(iterable: Iterable[_TokenInfo]) -> str: ... +def generate_tokens(readline: Callable[[], str]) -> Iterator[_TokenInfo]: ... diff --git a/stdlib/lib2to3/pytree.pyi b/stdlib/lib2to3/pytree.pyi index d05315ea9..8d90ee39b 100644 --- a/stdlib/lib2to3/pytree.pyi +++ b/stdlib/lib2to3/pytree.pyi @@ -1,21 +1,21 @@ from lib2to3.pgen2.grammar import Grammar -from typing import Any, Callable, Dict, Iterator, List, Optional, Text, Tuple, TypeVar, Union +from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, TypeVar, Union _P = TypeVar("_P") _NL = Union[Node, Leaf] -_Context = Tuple[Text, int, int] -_Results = Dict[Text, _NL] -_RawNode = Tuple[int, Text, _Context, Optional[List[_NL]]] +_Context = Tuple[str, int, int] +_Results = Dict[str, _NL] +_RawNode = Tuple[int, str, _Context, Optional[List[_NL]]] _Convert = Callable[[Grammar, _RawNode], Any] HUGE: int -def type_repr(type_num: int) -> Text: ... +def type_repr(type_num: int) -> str: ... class Base: type: int parent: Optional[Node] - prefix: Text + prefix: str children: List[_NL] was_changed: bool was_checked: bool @@ -34,7 +34,7 @@ class Base: def prev_sibling(self) -> Optional[_NL]: ... def leaves(self) -> Iterator[Leaf]: ... def depth(self) -> int: ... - def get_suffix(self) -> Text: ... + def get_suffix(self) -> str: ... class Node(Base): fixers_applied: List[Any] @@ -43,7 +43,7 @@ class Node(Base): type: int, children: List[_NL], context: Optional[Any] = ..., - prefix: Optional[Text] = ..., + prefix: Optional[str] = ..., fixers_applied: Optional[List[Any]] = ..., ) -> None: ... def set_child(self, i: int, child: _NL) -> None: ... @@ -53,14 +53,14 @@ class Node(Base): class Leaf(Base): lineno: int column: int - value: Text + value: str fixers_applied: List[Any] def __init__( self, type: int, - value: Text, + value: str, context: Optional[_Context] = ..., - prefix: Optional[Text] = ..., + prefix: Optional[str] = ..., fixers_applied: List[Any] = ..., ) -> None: ... @@ -68,26 +68,26 @@ def convert(gr: Grammar, raw_node: _RawNode) -> _NL: ... class BasePattern: type: int - content: Optional[Text] - name: Optional[Text] + content: Optional[str] + name: Optional[str] def optimize(self) -> BasePattern: ... # sic, subclasses are free to optimize themselves into different patterns def match(self, node: _NL, results: Optional[_Results] = ...) -> bool: ... def match_seq(self, nodes: List[_NL], results: Optional[_Results] = ...) -> bool: ... def generate_matches(self, nodes: List[_NL]) -> Iterator[Tuple[int, _Results]]: ... class LeafPattern(BasePattern): - def __init__(self, type: Optional[int] = ..., content: Optional[Text] = ..., name: Optional[Text] = ...) -> None: ... + def __init__(self, type: Optional[int] = ..., content: Optional[str] = ..., name: Optional[str] = ...) -> None: ... class NodePattern(BasePattern): wildcards: bool - def __init__(self, type: Optional[int] = ..., content: Optional[Text] = ..., name: Optional[Text] = ...) -> None: ... + def __init__(self, type: Optional[int] = ..., content: Optional[str] = ..., name: Optional[str] = ...) -> None: ... class WildcardPattern(BasePattern): min: int max: int - def __init__(self, content: Optional[Text] = ..., min: int = ..., max: int = ..., name: Optional[Text] = ...) -> None: ... + def __init__(self, content: Optional[str] = ..., min: int = ..., max: int = ..., name: Optional[str] = ...) -> None: ... class NegatedPattern(BasePattern): - def __init__(self, content: Optional[Text] = ...) -> None: ... + def __init__(self, content: Optional[str] = ...) -> None: ... def generate_matches(patterns: List[BasePattern], nodes: List[_NL]) -> Iterator[Tuple[int, _Results]]: ... diff --git a/stdlib/linecache.pyi b/stdlib/linecache.pyi index 9be8dcc6b..73c773876 100644 --- a/stdlib/linecache.pyi +++ b/stdlib/linecache.pyi @@ -1,10 +1,10 @@ -from typing import Any, Dict, List, Optional, Text +from typing import Any, Dict, List, Optional _ModuleGlobals = Dict[str, Any] -def getline(filename: Text, lineno: int, module_globals: Optional[_ModuleGlobals] = ...) -> str: ... +def getline(filename: str, lineno: int, module_globals: Optional[_ModuleGlobals] = ...) -> str: ... def clearcache() -> None: ... -def getlines(filename: Text, module_globals: Optional[_ModuleGlobals] = ...) -> List[str]: ... -def checkcache(filename: Optional[Text] = ...) -> None: ... -def updatecache(filename: Text, module_globals: Optional[_ModuleGlobals] = ...) -> List[str]: ... -def lazycache(filename: Text, module_globals: _ModuleGlobals) -> bool: ... +def getlines(filename: str, module_globals: Optional[_ModuleGlobals] = ...) -> List[str]: ... +def checkcache(filename: Optional[str] = ...) -> None: ... +def updatecache(filename: str, module_globals: Optional[_ModuleGlobals] = ...) -> List[str]: ... +def lazycache(filename: str, module_globals: _ModuleGlobals) -> bool: ... diff --git a/stdlib/macpath.pyi b/stdlib/macpath.pyi index 609fb4ee8..64685d6af 100644 --- a/stdlib/macpath.pyi +++ b/stdlib/macpath.pyi @@ -32,7 +32,7 @@ from posixpath import ( splitext as splitext, supports_unicode_filenames as supports_unicode_filenames, ) -from typing import AnyStr, Optional, Text, Tuple, overload +from typing import AnyStr, Optional, Tuple, overload altsep: Optional[str] @@ -60,7 +60,7 @@ def islink(s: AnyPath) -> bool: ... # Mypy complains that the signatures overlap, but things seem to behave correctly anyway. @overload -def join(s: StrPath, *paths: StrPath) -> Text: ... +def join(s: StrPath, *paths: StrPath) -> str: ... @overload def join(s: BytesPath, *paths: BytesPath) -> bytes: ... @overload diff --git a/stdlib/mailbox.pyi b/stdlib/mailbox.pyi index d968e7d77..7f3f02314 100644 --- a/stdlib/mailbox.pyi +++ b/stdlib/mailbox.pyi @@ -16,7 +16,6 @@ from typing import ( Optional, Protocol, Sequence, - Text, Tuple, Type, TypeVar, @@ -91,9 +90,9 @@ class Maildir(Mailbox[MaildirMessage]): ) -> None: ... def get_file(self, key: str) -> _ProxyFile[bytes]: ... def list_folders(self) -> List[str]: ... - def get_folder(self, folder: Text) -> Maildir: ... - def add_folder(self, folder: Text) -> Maildir: ... - def remove_folder(self, folder: Text) -> None: ... + def get_folder(self, folder: str) -> Maildir: ... + def add_folder(self, folder: str) -> Maildir: ... + def remove_folder(self, folder: str) -> None: ... def clean(self) -> None: ... def next(self) -> Optional[str]: ... diff --git a/stdlib/mimetypes.pyi b/stdlib/mimetypes.pyi index f0cfac32c..1f874022b 100644 --- a/stdlib/mimetypes.pyi +++ b/stdlib/mimetypes.pyi @@ -1,12 +1,12 @@ import sys -from typing import IO, Dict, List, Optional, Sequence, Text, Tuple, Union +from typing import IO, Dict, List, Optional, Sequence, Tuple, Union if sys.version_info >= (3, 8): from os import PathLike - def guess_type(url: Union[Text, PathLike[str]], strict: bool = ...) -> Tuple[Optional[str], Optional[str]]: ... + def guess_type(url: Union[str, PathLike[str]], strict: bool = ...) -> Tuple[Optional[str], Optional[str]]: ... else: - def guess_type(url: Text, strict: bool = ...) -> Tuple[Optional[str], Optional[str]]: ... + def guess_type(url: str, strict: bool = ...) -> Tuple[Optional[str], Optional[str]]: ... def guess_all_extensions(type: str, strict: bool = ...) -> List[str]: ... def guess_extension(type: str, strict: bool = ...) -> Optional[str]: ... diff --git a/stdlib/msvcrt.pyi b/stdlib/msvcrt.pyi index ede80c9fb..0441ed8ac 100644 --- a/stdlib/msvcrt.pyi +++ b/stdlib/msvcrt.pyi @@ -1,5 +1,4 @@ import sys -from typing import Text # This module is only available on Windows if sys.platform == "win32": @@ -14,11 +13,11 @@ if sys.platform == "win32": def get_osfhandle(__fd: int) -> int: ... def kbhit() -> bool: ... def getch() -> bytes: ... - def getwch() -> Text: ... + def getwch() -> str: ... def getche() -> bytes: ... - def getwche() -> Text: ... + def getwche() -> str: ... def putch(__char: bytes) -> None: ... - def putwch(__unicode_char: Text) -> None: ... + def putwch(__unicode_char: str) -> None: ... def ungetch(__char: bytes) -> None: ... - def ungetwch(__unicode_char: Text) -> None: ... + def ungetwch(__unicode_char: str) -> None: ... def heapmin() -> None: ... diff --git a/stdlib/parser.pyi b/stdlib/parser.pyi index 799f25cf6..9fb26f9e3 100644 --- a/stdlib/parser.pyi +++ b/stdlib/parser.pyi @@ -1,9 +1,9 @@ from _typeshed import AnyPath from types import CodeType -from typing import Any, List, Sequence, Text, Tuple +from typing import Any, List, Sequence, Tuple -def expr(source: Text) -> STType: ... -def suite(source: Text) -> STType: ... +def expr(source: str) -> STType: ... +def suite(source: str) -> STType: ... def sequence2st(sequence: Sequence[Any]) -> STType: ... def tuple2st(sequence: Sequence[Any]) -> STType: ... def st2list(st: STType, line_info: bool = ..., col_info: bool = ...) -> List[Any]: ... diff --git a/stdlib/pickletools.pyi b/stdlib/pickletools.pyi index b1f7803d8..59c06624a 100644 --- a/stdlib/pickletools.pyi +++ b/stdlib/pickletools.pyi @@ -1,4 +1,4 @@ -from typing import IO, Any, Callable, Iterator, List, MutableMapping, Optional, Text, Tuple, Type, Union +from typing import IO, Any, Callable, Iterator, List, MutableMapping, Optional, Tuple, Type, Union _Reader = Callable[[IO[bytes]], Any] bytes_types: Tuple[Type[Any], ...] @@ -36,7 +36,7 @@ def read_uint8(f: IO[bytes]) -> int: ... uint8: ArgumentDescriptor -def read_stringnl(f: IO[bytes], decode: bool = ..., stripquotes: bool = ...) -> Union[bytes, Text]: ... +def read_stringnl(f: IO[bytes], decode: bool = ..., stripquotes: bool = ...) -> Union[bytes, str]: ... stringnl: ArgumentDescriptor @@ -44,7 +44,7 @@ def read_stringnl_noescape(f: IO[bytes]) -> str: ... stringnl_noescape: ArgumentDescriptor -def read_stringnl_noescape_pair(f: IO[bytes]) -> Text: ... +def read_stringnl_noescape_pair(f: IO[bytes]) -> str: ... stringnl_noescape_pair: ArgumentDescriptor @@ -68,19 +68,19 @@ def read_bytes8(f: IO[bytes]) -> bytes: ... bytes8: ArgumentDescriptor -def read_unicodestringnl(f: IO[bytes]) -> Text: ... +def read_unicodestringnl(f: IO[bytes]) -> str: ... unicodestringnl: ArgumentDescriptor -def read_unicodestring1(f: IO[bytes]) -> Text: ... +def read_unicodestring1(f: IO[bytes]) -> str: ... unicodestring1: ArgumentDescriptor -def read_unicodestring4(f: IO[bytes]) -> Text: ... +def read_unicodestring4(f: IO[bytes]) -> str: ... unicodestring4: ArgumentDescriptor -def read_unicodestring8(f: IO[bytes]) -> Text: ... +def read_unicodestring8(f: IO[bytes]) -> str: ... unicodestring8: ArgumentDescriptor diff --git a/stdlib/pstats.pyi b/stdlib/pstats.pyi index 9c74aeb9c..b8d581960 100644 --- a/stdlib/pstats.pyi +++ b/stdlib/pstats.pyi @@ -2,7 +2,7 @@ import sys from _typeshed import AnyPath from cProfile import Profile as _cProfile from profile import Profile -from typing import IO, Any, Dict, Iterable, List, Optional, Text, Tuple, TypeVar, Union, overload +from typing import IO, Any, Dict, Iterable, List, Optional, Tuple, TypeVar, Union, overload _Selector = Union[str, float, int] _T = TypeVar("_T", bound=Stats) @@ -24,14 +24,14 @@ class Stats: sort_arg_dict_default: Dict[str, Tuple[Any, str]] def __init__( self: _T, - __arg: Union[None, str, Text, Profile, _cProfile] = ..., - *args: Union[None, str, Text, Profile, _cProfile, _T], + __arg: Union[None, str, Profile, _cProfile] = ..., + *args: Union[None, str, Profile, _cProfile, _T], stream: Optional[IO[Any]] = ..., ) -> None: ... - def init(self, arg: Union[None, str, Text, Profile, _cProfile]) -> None: ... - def load_stats(self, arg: Union[None, str, Text, Profile, _cProfile]) -> None: ... + def init(self, arg: Union[None, str, Profile, _cProfile]) -> None: ... + def load_stats(self, arg: Union[None, str, Profile, _cProfile]) -> None: ... def get_top_level_stats(self) -> None: ... - def add(self: _T, *arg_list: Union[None, str, Text, Profile, _cProfile, _T]) -> _T: ... + def add(self: _T, *arg_list: Union[None, str, Profile, _cProfile, _T]) -> _T: ... def dump_stats(self, filename: AnyPath) -> None: ... def get_sort_arg_defs(self) -> Dict[str, Tuple[Tuple[Tuple[int, int], ...], str]]: ... @overload diff --git a/stdlib/py_compile.pyi b/stdlib/py_compile.pyi index 51f7ee6f5..6a563a858 100644 --- a/stdlib/py_compile.pyi +++ b/stdlib/py_compile.pyi @@ -1,7 +1,5 @@ import sys -from typing import AnyStr, List, Optional, Text, Type, Union - -_EitherStr = Union[bytes, Text] +from typing import AnyStr, List, Optional, Type class PyCompileError(Exception): exc_type_name: str @@ -44,4 +42,4 @@ else: file: AnyStr, cfile: Optional[AnyStr] = ..., dfile: Optional[AnyStr] = ..., doraise: bool = ..., optimize: int = ... ) -> Optional[AnyStr]: ... -def main(args: Optional[List[Text]] = ...) -> int: ... +def main(args: Optional[List[str]] = ...) -> int: ... diff --git a/stdlib/pydoc.pyi b/stdlib/pydoc.pyi index 19b9b28cb..b41bef543 100644 --- a/stdlib/pydoc.pyi +++ b/stdlib/pydoc.pyi @@ -13,7 +13,6 @@ from typing import ( MutableMapping, NoReturn, Optional, - Text, Tuple, Type, Union, @@ -28,7 +27,7 @@ __version__: str __credits__: str def pathdirs() -> List[str]: ... -def getdoc(object: object) -> Text: ... +def getdoc(object: object) -> str: ... def splitdoc(doc: AnyStr) -> Tuple[AnyStr, AnyStr]: ... def classname(object: object, modname: str) -> str: ... def isdata(object: object) -> bool: ... @@ -74,8 +73,8 @@ class HTMLRepr(Repr): def escape(self, text: str) -> str: ... def repr(self, object: object) -> str: ... def repr1(self, x: object, level: complex) -> str: ... - def repr_string(self, x: Text, level: complex) -> str: ... - def repr_str(self, x: Text, level: complex) -> str: ... + def repr_string(self, x: str, level: complex) -> str: ... + def repr_str(self, x: str, level: complex) -> str: ... def repr_instance(self, x: object, level: complex) -> str: ... def repr_unicode(self, x: AnyStr, level: complex) -> str: ... diff --git a/stdlib/pyexpat/__init__.pyi b/stdlib/pyexpat/__init__.pyi index 65f6b0e9f..c58958d15 100644 --- a/stdlib/pyexpat/__init__.pyi +++ b/stdlib/pyexpat/__init__.pyi @@ -1,7 +1,7 @@ import pyexpat.errors as errors import pyexpat.model as model from _typeshed import SupportsRead -from typing import Any, Callable, Dict, List, Optional, Text, Tuple, Union +from typing import Any, Callable, Dict, List, Optional, Tuple, Union EXPAT_VERSION: str # undocumented version_info: Tuple[int, int, int] # undocumented @@ -22,12 +22,12 @@ XML_PARAM_ENTITY_PARSING_ALWAYS: int _Model = Tuple[int, int, Optional[str], Tuple[Any, ...]] class XMLParserType(object): - def Parse(self, __data: Union[Text, bytes], __isfinal: bool = ...) -> int: ... + def Parse(self, __data: Union[str, bytes], __isfinal: bool = ...) -> int: ... def ParseFile(self, __file: SupportsRead[bytes]) -> int: ... - def SetBase(self, __base: Text) -> None: ... + def SetBase(self, __base: str) -> None: ... def GetBase(self) -> Optional[str]: ... def GetInputContext(self) -> Optional[bytes]: ... - def ExternalEntityParserCreate(self, __context: Optional[Text], __encoding: Text = ...) -> XMLParserType: ... + def ExternalEntityParserCreate(self, __context: Optional[str], __encoding: str = ...) -> XMLParserType: ... def SetParamEntityParsing(self, __flag: int) -> int: ... def UseForeignDTD(self, __flag: bool = ...) -> None: ... buffer_size: int @@ -75,5 +75,5 @@ def ErrorString(__code: int) -> str: ... # intern is undocumented def ParserCreate( - encoding: Optional[Text] = ..., namespace_separator: Optional[Text] = ..., intern: Optional[Dict[str, Any]] = ... + encoding: Optional[str] = ..., namespace_separator: Optional[str] = ..., intern: Optional[Dict[str, Any]] = ... ) -> XMLParserType: ... diff --git a/stdlib/sched.pyi b/stdlib/sched.pyi index 1d6eb98f8..379d5a518 100644 --- a/stdlib/sched.pyi +++ b/stdlib/sched.pyi @@ -1,11 +1,11 @@ -from typing import Any, Callable, Dict, List, NamedTuple, Optional, Text, Tuple +from typing import Any, Callable, Dict, List, NamedTuple, Optional, Tuple class Event(NamedTuple): time: float priority: Any action: Callable[..., Any] argument: Tuple[Any, ...] - kwargs: Dict[Text, Any] + kwargs: Dict[str, Any] class scheduler: def __init__(self, timefunc: Callable[[], float] = ..., delayfunc: Callable[[float], None] = ...) -> None: ... diff --git a/stdlib/smtpd.pyi b/stdlib/smtpd.pyi index a81b0911f..313e72216 100644 --- a/stdlib/smtpd.pyi +++ b/stdlib/smtpd.pyi @@ -1,7 +1,7 @@ import asynchat import asyncore import socket -from typing import Any, DefaultDict, List, Optional, Text, Tuple, Type, Union +from typing import Any, DefaultDict, List, Optional, Tuple, Type, Union _Address = Tuple[str, int] # (host, port) @@ -13,7 +13,7 @@ class SMTPChannel(asynchat.async_chat): smtp_server: SMTPServer conn: socket.socket addr: Any - received_lines: List[Text] + received_lines: List[str] smtp_state: int seen_greeting: str mailfrom: str @@ -39,7 +39,7 @@ class SMTPChannel(asynchat.async_chat): decode_data: bool = ..., ) -> None: ... # base asynchat.async_chat.push() accepts bytes - def push(self, msg: Text) -> None: ... # type: ignore + def push(self, msg: str) -> None: ... # type: ignore def collect_incoming_data(self, data: bytes) -> None: ... def found_terminator(self) -> None: ... def smtp_HELO(self, arg: str) -> None: ... @@ -70,17 +70,17 @@ class SMTPServer(asyncore.dispatcher): ) -> None: ... def handle_accepted(self, conn: socket.socket, addr: Any) -> None: ... def process_message( - self, peer: _Address, mailfrom: str, rcpttos: List[Text], data: Union[bytes, str], **kwargs: Any + self, peer: _Address, mailfrom: str, rcpttos: List[str], data: Union[bytes, str], **kwargs: Any ) -> Optional[str]: ... class DebuggingServer(SMTPServer): ... class PureProxy(SMTPServer): def process_message( # type: ignore - self, peer: _Address, mailfrom: str, rcpttos: List[Text], data: Union[bytes, str] + self, peer: _Address, mailfrom: str, rcpttos: List[str], data: Union[bytes, str] ) -> Optional[str]: ... class MailmanProxy(PureProxy): def process_message( # type: ignore - self, peer: _Address, mailfrom: str, rcpttos: List[Text], data: Union[bytes, str] + self, peer: _Address, mailfrom: str, rcpttos: List[str], data: Union[bytes, str] ) -> Optional[str]: ... diff --git a/stdlib/socket.pyi b/stdlib/socket.pyi index b2ef06893..06adfe49e 100644 --- a/stdlib/socket.pyi +++ b/stdlib/socket.pyi @@ -1,6 +1,6 @@ import sys from enum import IntEnum, IntFlag -from typing import Any, BinaryIO, Iterable, List, Optional, Text, TextIO, Tuple, TypeVar, Union, overload +from typing import Any, BinaryIO, Iterable, List, Optional, TextIO, Tuple, TypeVar, Union, overload from typing_extensions import Literal # ----- Constants ----- @@ -691,7 +691,7 @@ if sys.version_info >= (3, 7): def create_connection( address: Tuple[Optional[str], int], timeout: Optional[float] = ..., - source_address: Optional[Tuple[Union[bytearray, bytes, Text], int]] = ..., + source_address: Optional[Tuple[Union[bytearray, bytes, str], int]] = ..., ) -> socket: ... if sys.version_info >= (3, 8): @@ -707,7 +707,7 @@ if sys.platform == "win32": # the 5th tuple item is an address def getaddrinfo( - host: Optional[Union[bytearray, bytes, Text]], + host: Optional[Union[bytearray, bytes, str]], port: Union[str, int, None], family: int = ..., type: int = ..., diff --git a/stdlib/sqlite3/dbapi2.pyi b/stdlib/sqlite3/dbapi2.pyi index 4e247855f..3681f99f4 100644 --- a/stdlib/sqlite3/dbapi2.pyi +++ b/stdlib/sqlite3/dbapi2.pyi @@ -1,7 +1,7 @@ import os import sys from datetime import date, datetime, time -from typing import Any, Callable, Generator, Iterable, Iterator, List, Optional, Protocol, Text, Tuple, Type, TypeVar, Union +from typing import Any, Callable, Generator, Iterable, Iterator, List, Optional, Protocol, Tuple, Type, TypeVar, Union _T = TypeVar("_T") @@ -66,7 +66,7 @@ def complete_statement(sql: str) -> bool: ... if sys.version_info >= (3, 7): def connect( - database: Union[bytes, Text, os.PathLike[Text]], + database: Union[bytes, str, os.PathLike[str]], timeout: float = ..., detect_types: int = ..., isolation_level: Optional[str] = ..., @@ -78,7 +78,7 @@ if sys.version_info >= (3, 7): else: def connect( - database: Union[bytes, Text], + database: Union[bytes, str], timeout: float = ..., detect_types: int = ..., isolation_level: Optional[str] = ..., @@ -132,7 +132,7 @@ class Connection(object): def execute(self, sql: str, parameters: Iterable[Any] = ...) -> Cursor: ... # TODO: please check in executemany() if seq_of_parameters type is possible like this def executemany(self, __sql: str, __parameters: Iterable[Iterable[Any]]) -> Cursor: ... - def executescript(self, __sql_script: Union[bytes, Text]) -> Cursor: ... + def executescript(self, __sql_script: Union[bytes, str]) -> Cursor: ... def interrupt(self, *args: Any, **kwargs: Any) -> None: ... def iterdump(self, *args: Any, **kwargs: Any) -> Generator[str, None, None]: ... def rollback(self, *args: Any, **kwargs: Any) -> None: ... @@ -175,7 +175,7 @@ class Cursor(Iterator[Any]): def close(self, *args: Any, **kwargs: Any) -> None: ... def execute(self, __sql: str, __parameters: Iterable[Any] = ...) -> Cursor: ... def executemany(self, __sql: str, __seq_of_parameters: Iterable[Iterable[Any]]) -> Cursor: ... - def executescript(self, __sql_script: Union[bytes, Text]) -> Cursor: ... + def executescript(self, __sql_script: Union[bytes, str]) -> Cursor: ... def fetchall(self) -> List[Any]: ... def fetchmany(self, size: Optional[int] = ...) -> List[Any]: ... def fetchone(self) -> Any: ... diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index 4164903e2..ccae3e3b3 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -2,7 +2,7 @@ import enum import socket import sys from _typeshed import StrPath -from typing import Any, Callable, Dict, Iterable, List, NamedTuple, Optional, Set, Text, Tuple, Type, Union, overload +from typing import Any, Callable, Dict, Iterable, List, NamedTuple, Optional, Set, Tuple, Type, Union, overload from typing_extensions import Literal _PCTRTT = Tuple[Tuple[str, str], ...] @@ -45,7 +45,7 @@ def wrap_socket( ciphers: Optional[str] = ..., ) -> SSLSocket: ... def create_default_context( - purpose: Any = ..., *, cafile: Optional[str] = ..., capath: Optional[str] = ..., cadata: Union[Text, bytes, None] = ... + purpose: Any = ..., *, cafile: Optional[str] = ..., capath: Optional[str] = ..., cadata: Union[str, bytes, None] = ... ) -> SSLContext: ... if sys.version_info >= (3, 7): @@ -59,7 +59,7 @@ if sys.version_info >= (3, 7): keyfile: Optional[str] = ..., cafile: Optional[str] = ..., capath: Optional[str] = ..., - cadata: Union[Text, bytes, None] = ..., + cadata: Union[str, bytes, None] = ..., ) -> SSLContext: ... else: @@ -73,7 +73,7 @@ else: keyfile: Optional[str] = ..., cafile: Optional[str] = ..., capath: Optional[str] = ..., - cadata: Union[Text, bytes, None] = ..., + cadata: Union[str, bytes, None] = ..., ) -> SSLContext: ... _create_default_https_context: Callable[..., SSLContext] @@ -305,7 +305,7 @@ class SSLContext: ) -> None: ... def load_default_certs(self, purpose: Purpose = ...) -> None: ... def load_verify_locations( - self, cafile: Optional[StrPath] = ..., capath: Optional[StrPath] = ..., cadata: Union[Text, bytes, None] = ... + self, cafile: Optional[StrPath] = ..., capath: Optional[StrPath] = ..., cadata: Union[str, bytes, None] = ... ) -> None: ... def get_ca_certs(self, binary_form: bool = ...) -> Union[List[_PeerCertRetDictType], List[bytes]]: ... def set_default_verify_paths(self) -> None: ... diff --git a/stdlib/stringprep.pyi b/stdlib/stringprep.pyi index 604fd2f2c..cbc562d46 100644 --- a/stdlib/stringprep.pyi +++ b/stdlib/stringprep.pyi @@ -1,21 +1,19 @@ -from typing import Text - -def in_table_a1(code: Text) -> bool: ... -def in_table_b1(code: Text) -> bool: ... -def map_table_b3(code: Text) -> Text: ... -def map_table_b2(a: Text) -> Text: ... -def in_table_c11(code: Text) -> bool: ... -def in_table_c12(code: Text) -> bool: ... -def in_table_c11_c12(code: Text) -> bool: ... -def in_table_c21(code: Text) -> bool: ... -def in_table_c22(code: Text) -> bool: ... -def in_table_c21_c22(code: Text) -> bool: ... -def in_table_c3(code: Text) -> bool: ... -def in_table_c4(code: Text) -> bool: ... -def in_table_c5(code: Text) -> bool: ... -def in_table_c6(code: Text) -> bool: ... -def in_table_c7(code: Text) -> bool: ... -def in_table_c8(code: Text) -> bool: ... -def in_table_c9(code: Text) -> bool: ... -def in_table_d1(code: Text) -> bool: ... -def in_table_d2(code: Text) -> bool: ... +def in_table_a1(code: str) -> bool: ... +def in_table_b1(code: str) -> bool: ... +def map_table_b3(code: str) -> str: ... +def map_table_b2(a: str) -> str: ... +def in_table_c11(code: str) -> bool: ... +def in_table_c12(code: str) -> bool: ... +def in_table_c11_c12(code: str) -> bool: ... +def in_table_c21(code: str) -> bool: ... +def in_table_c22(code: str) -> bool: ... +def in_table_c21_c22(code: str) -> bool: ... +def in_table_c3(code: str) -> bool: ... +def in_table_c4(code: str) -> bool: ... +def in_table_c5(code: str) -> bool: ... +def in_table_c6(code: str) -> bool: ... +def in_table_c7(code: str) -> bool: ... +def in_table_c8(code: str) -> bool: ... +def in_table_c9(code: str) -> bool: ... +def in_table_d1(code: str) -> bool: ... +def in_table_d2(code: str) -> bool: ... diff --git a/stdlib/sunau.pyi b/stdlib/sunau.pyi index a301b2f00..79d0881c9 100644 --- a/stdlib/sunau.pyi +++ b/stdlib/sunau.pyi @@ -1,7 +1,7 @@ import sys -from typing import IO, Any, NamedTuple, NoReturn, Optional, Text, Union +from typing import IO, Any, NamedTuple, NoReturn, Optional, Union -_File = Union[Text, IO[bytes]] +_File = Union[str, IO[bytes]] class Error(Exception): ... diff --git a/stdlib/symtable.pyi b/stdlib/symtable.pyi index 82944d055..ea6ed5571 100644 --- a/stdlib/symtable.pyi +++ b/stdlib/symtable.pyi @@ -1,7 +1,7 @@ import sys -from typing import Any, List, Optional, Sequence, Text, Tuple +from typing import Any, List, Optional, Sequence, Tuple -def symtable(code: Text, filename: Text, compile_type: Text) -> SymbolTable: ... +def symtable(code: str, filename: str, compile_type: str) -> SymbolTable: ... class SymbolTable(object): def __init__(self, raw_table: Any, filename: str) -> None: ... diff --git a/stdlib/threading.pyi b/stdlib/threading.pyi index 3c680312b..de7537505 100644 --- a/stdlib/threading.pyi +++ b/stdlib/threading.pyi @@ -1,6 +1,6 @@ import sys from types import FrameType, TracebackType -from typing import Any, Callable, Iterable, List, Mapping, Optional, Text, Type, TypeVar, Union +from typing import Any, Callable, Iterable, List, Mapping, Optional, Type, TypeVar, Union # TODO recursive type _TF = Callable[[FrameType, str, Any], Optional[Callable[..., Any]]] @@ -51,7 +51,7 @@ class Thread: def run(self) -> None: ... def join(self, timeout: Optional[float] = ...) -> None: ... def getName(self) -> str: ... - def setName(self, name: Text) -> None: ... + def setName(self, name: str) -> None: ... if sys.version_info >= (3, 8): @property def native_id(self) -> Optional[int]: ... # only available on some platforms diff --git a/stdlib/turtle.pyi b/stdlib/turtle.pyi index 48467dc6b..e04a96257 100644 --- a/stdlib/turtle.pyi +++ b/stdlib/turtle.pyi @@ -1,11 +1,11 @@ from tkinter import Canvas, PhotoImage -from typing import Any, Callable, Dict, List, Optional, Sequence, Text, Tuple, TypeVar, Union, overload +from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, TypeVar, Union, overload # Note: '_Color' is the alias we use for arguments and _AnyColor is the # alias we use for return types. Really, these two aliases should be the # same, but as per the "no union returns" typeshed policy, we'll return # Any instead. -_Color = Union[Text, Tuple[float, float, float]] +_Color = Union[str, Tuple[float, float, float]] _AnyColor = Any # TODO: Replace this with a TypedDict once it becomes standardized. diff --git a/stdlib/unicodedata.pyi b/stdlib/unicodedata.pyi index a83d79ff2..3bc4f6f33 100644 --- a/stdlib/unicodedata.pyi +++ b/stdlib/unicodedata.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Text, TypeVar, Union +from typing import Any, TypeVar, Union ucd_3_2_0: UCD ucnhash_CAPI: Any @@ -7,36 +7,36 @@ unidata_version: str _T = TypeVar("_T") -def bidirectional(__chr: Text) -> Text: ... -def category(__chr: Text) -> Text: ... -def combining(__chr: Text) -> int: ... -def decimal(__chr: Text, __default: _T = ...) -> Union[int, _T]: ... -def decomposition(__chr: Text) -> Text: ... -def digit(__chr: Text, __default: _T = ...) -> Union[int, _T]: ... -def east_asian_width(__chr: Text) -> Text: ... +def bidirectional(__chr: str) -> str: ... +def category(__chr: str) -> str: ... +def combining(__chr: str) -> int: ... +def decimal(__chr: str, __default: _T = ...) -> Union[int, _T]: ... +def decomposition(__chr: str) -> str: ... +def digit(__chr: str, __default: _T = ...) -> Union[int, _T]: ... +def east_asian_width(__chr: str) -> str: ... if sys.version_info >= (3, 8): def is_normalized(__form: str, __unistr: str) -> bool: ... -def lookup(__name: Union[Text, bytes]) -> Text: ... -def mirrored(__chr: Text) -> int: ... -def name(__chr: Text, __default: _T = ...) -> Union[Text, _T]: ... -def normalize(__form: Text, __unistr: Text) -> Text: ... -def numeric(__chr: Text, __default: _T = ...) -> Union[float, _T]: ... +def lookup(__name: Union[str, bytes]) -> str: ... +def mirrored(__chr: str) -> int: ... +def name(__chr: str, __default: _T = ...) -> Union[str, _T]: ... +def normalize(__form: str, __unistr: str) -> str: ... +def numeric(__chr: str, __default: _T = ...) -> Union[float, _T]: ... class UCD(object): # The methods below are constructed from the same array in C # (unicodedata_functions) and hence identical to the methods above. unidata_version: str - def bidirectional(self, __chr: Text) -> str: ... - def category(self, __chr: Text) -> str: ... - def combining(self, __chr: Text) -> int: ... - def decimal(self, __chr: Text, __default: _T = ...) -> Union[int, _T]: ... - def decomposition(self, __chr: Text) -> str: ... - def digit(self, __chr: Text, __default: _T = ...) -> Union[int, _T]: ... - def east_asian_width(self, __chr: Text) -> str: ... - def lookup(self, __name: Union[Text, bytes]) -> Text: ... - def mirrored(self, __chr: Text) -> int: ... - def name(self, __chr: Text, __default: _T = ...) -> Union[Text, _T]: ... - def normalize(self, __form: Text, __unistr: Text) -> Text: ... - def numeric(self, __chr: Text, __default: _T = ...) -> Union[float, _T]: ... + def bidirectional(self, __chr: str) -> str: ... + def category(self, __chr: str) -> str: ... + def combining(self, __chr: str) -> int: ... + def decimal(self, __chr: str, __default: _T = ...) -> Union[int, _T]: ... + def decomposition(self, __chr: str) -> str: ... + def digit(self, __chr: str, __default: _T = ...) -> Union[int, _T]: ... + def east_asian_width(self, __chr: str) -> str: ... + def lookup(self, __name: Union[str, bytes]) -> str: ... + def mirrored(self, __chr: str) -> int: ... + def name(self, __chr: str, __default: _T = ...) -> Union[str, _T]: ... + def normalize(self, __form: str, __unistr: str) -> str: ... + def numeric(self, __chr: str, __default: _T = ...) -> Union[float, _T]: ... diff --git a/stdlib/uu.pyi b/stdlib/uu.pyi index 2bb2c2a1c..91ce210ae 100644 --- a/stdlib/uu.pyi +++ b/stdlib/uu.pyi @@ -1,7 +1,7 @@ import sys -from typing import BinaryIO, Optional, Text, Union +from typing import BinaryIO, Optional, Union -_File = Union[Text, BinaryIO] +_File = Union[str, BinaryIO] class Error(Exception): ... diff --git a/stdlib/uuid.pyi b/stdlib/uuid.pyi index 2bd2f22c6..b66b169c5 100644 --- a/stdlib/uuid.pyi +++ b/stdlib/uuid.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Optional, Text, Tuple +from typing import Any, Optional, Tuple # Because UUID has properties called int and bytes we need to rename these temporarily. _Int = int @@ -17,7 +17,7 @@ class UUID: if sys.version_info >= (3, 7): def __init__( self, - hex: Optional[Text] = ..., + hex: Optional[str] = ..., bytes: Optional[_Bytes] = ..., bytes_le: Optional[_Bytes] = ..., fields: Optional[_FieldsType] = ..., @@ -31,7 +31,7 @@ class UUID: else: def __init__( self, - hex: Optional[Text] = ..., + hex: Optional[str] = ..., bytes: Optional[_Bytes] = ..., bytes_le: Optional[_Bytes] = ..., fields: Optional[_FieldsType] = ..., diff --git a/stdlib/wave.pyi b/stdlib/wave.pyi index d1c2075a6..61f9136ea 100644 --- a/stdlib/wave.pyi +++ b/stdlib/wave.pyi @@ -1,7 +1,7 @@ import sys -from typing import IO, Any, BinaryIO, NamedTuple, NoReturn, Optional, Text, Union +from typing import IO, Any, BinaryIO, NamedTuple, NoReturn, Optional, Union -_File = Union[Text, IO[bytes]] +_File = Union[str, IO[bytes]] class Error(Exception): ... diff --git a/stdlib/webbrowser.pyi b/stdlib/webbrowser.pyi index 322ec2764..bb543e2f2 100644 --- a/stdlib/webbrowser.pyi +++ b/stdlib/webbrowser.pyi @@ -1,41 +1,41 @@ import sys -from typing import Callable, List, Optional, Sequence, Text, Union +from typing import Callable, List, Optional, Sequence, Union class Error(Exception): ... if sys.version_info >= (3, 7): def register( - name: Text, klass: Optional[Callable[[], BaseBrowser]], instance: Optional[BaseBrowser] = ..., *, preferred: bool = ... + name: str, klass: Optional[Callable[[], BaseBrowser]], instance: Optional[BaseBrowser] = ..., *, preferred: bool = ... ) -> None: ... else: def register( - name: Text, klass: Optional[Callable[[], BaseBrowser]], instance: Optional[BaseBrowser] = ..., update_tryorder: int = ... + name: str, klass: Optional[Callable[[], BaseBrowser]], instance: Optional[BaseBrowser] = ..., update_tryorder: int = ... ) -> None: ... -def get(using: Optional[Text] = ...) -> BaseBrowser: ... -def open(url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... -def open_new(url: Text) -> bool: ... -def open_new_tab(url: Text) -> bool: ... +def get(using: Optional[str] = ...) -> BaseBrowser: ... +def open(url: str, new: int = ..., autoraise: bool = ...) -> bool: ... +def open_new(url: str) -> bool: ... +def open_new_tab(url: str) -> bool: ... class BaseBrowser: args: List[str] name: str basename: str - def __init__(self, name: Text = ...) -> None: ... - def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... - def open_new(self, url: Text) -> bool: ... - def open_new_tab(self, url: Text) -> bool: ... + def __init__(self, name: str = ...) -> None: ... + def open(self, url: str, new: int = ..., autoraise: bool = ...) -> bool: ... + def open_new(self, url: str) -> bool: ... + def open_new_tab(self, url: str) -> bool: ... class GenericBrowser(BaseBrowser): args: List[str] name: str basename: str - def __init__(self, name: Union[Text, Sequence[Text]]) -> None: ... - def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... + def __init__(self, name: Union[str, Sequence[str]]) -> None: ... + def open(self, url: str, new: int = ..., autoraise: bool = ...) -> bool: ... class BackgroundBrowser(GenericBrowser): - def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... + def open(self, url: str, new: int = ..., autoraise: bool = ...) -> bool: ... class UnixBrowser(BaseBrowser): raise_opts: Optional[List[str]] @@ -45,7 +45,7 @@ class UnixBrowser(BaseBrowser): remote_action: str remote_action_newwin: str remote_action_newtab: str - def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... + def open(self, url: str, new: int = ..., autoraise: bool = ...) -> bool: ... class Mozilla(UnixBrowser): remote_args: List[str] @@ -84,20 +84,20 @@ class Elinks(UnixBrowser): redirect_stdout: bool class Konqueror(BaseBrowser): - def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... + def open(self, url: str, new: int = ..., autoraise: bool = ...) -> bool: ... class Grail(BaseBrowser): - def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... + def open(self, url: str, new: int = ..., autoraise: bool = ...) -> bool: ... if sys.platform == "win32": class WindowsDefault(BaseBrowser): - def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... + def open(self, url: str, new: int = ..., autoraise: bool = ...) -> bool: ... if sys.platform == "darwin": class MacOSX(BaseBrowser): name: str - def __init__(self, name: Text) -> None: ... - def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... + def __init__(self, name: str) -> None: ... + def open(self, url: str, new: int = ..., autoraise: bool = ...) -> bool: ... class MacOSXOSAScript(BaseBrowser): - def __init__(self, name: Text) -> None: ... - def open(self, url: Text, new: int = ..., autoraise: bool = ...) -> bool: ... + def __init__(self, name: str) -> None: ... + def open(self, url: str, new: int = ..., autoraise: bool = ...) -> bool: ... diff --git a/stdlib/wsgiref/handlers.pyi b/stdlib/wsgiref/handlers.pyi index b428ba441..ba85292b8 100644 --- a/stdlib/wsgiref/handlers.pyi +++ b/stdlib/wsgiref/handlers.pyi @@ -1,6 +1,6 @@ from abc import abstractmethod from types import TracebackType -from typing import IO, Callable, Dict, List, MutableMapping, Optional, Text, Tuple, Type +from typing import IO, Callable, Dict, List, MutableMapping, Optional, Tuple, Type from .headers import Headers from .types import ErrorStream, InputStream, StartResponse, WSGIApplication, WSGIEnvironment @@ -28,7 +28,7 @@ class BaseHandler: traceback_limit: Optional[int] error_status: str - error_headers: List[Tuple[Text, Text]] + error_headers: List[Tuple[str, str]] error_body: bytes def run(self, application: WSGIApplication) -> None: ... def setup_environ(self) -> None: ... @@ -37,7 +37,7 @@ class BaseHandler: def set_content_length(self) -> None: ... def cleanup_headers(self) -> None: ... def start_response( - self, status: Text, headers: List[Tuple[Text, Text]], exc_info: Optional[_exc_info] = ... + self, status: str, headers: List[Tuple[str, str]], exc_info: Optional[_exc_info] = ... ) -> Callable[[bytes], None]: ... def send_preamble(self) -> None: ... def write(self, data: bytes) -> None: ... diff --git a/stdlib/xml/sax/__init__.pyi b/stdlib/xml/sax/__init__.pyi index a95fde106..854a552d3 100644 --- a/stdlib/xml/sax/__init__.pyi +++ b/stdlib/xml/sax/__init__.pyi @@ -1,5 +1,5 @@ import sys -from typing import IO, Any, Iterable, List, NoReturn, Optional, Text, Union +from typing import IO, Any, Iterable, List, NoReturn, Optional, Union from xml.sax.handler import ContentHandler, ErrorHandler from xml.sax.xmlreader import Locator, XMLReader @@ -29,5 +29,5 @@ else: def make_parser(parser_list: List[str] = ...) -> XMLReader: ... def parse(source: Union[str, IO[str], IO[bytes]], handler: ContentHandler, errorHandler: ErrorHandler = ...) -> None: ... -def parseString(string: Union[bytes, Text], handler: ContentHandler, errorHandler: Optional[ErrorHandler] = ...) -> None: ... +def parseString(string: Union[bytes, str], handler: ContentHandler, errorHandler: Optional[ErrorHandler] = ...) -> None: ... def _create_parser(parser_name: str) -> XMLReader: ... diff --git a/stdlib/xml/sax/saxutils.pyi b/stdlib/xml/sax/saxutils.pyi index 66bb9976a..066097fb5 100644 --- a/stdlib/xml/sax/saxutils.pyi +++ b/stdlib/xml/sax/saxutils.pyi @@ -1,12 +1,12 @@ from _typeshed import SupportsWrite from codecs import StreamReaderWriter, StreamWriter from io import RawIOBase, TextIOBase -from typing import Mapping, Optional, Text, Union +from typing import Mapping, Optional, Union from xml.sax import handler, xmlreader -def escape(data: Text, entities: Mapping[Text, Text] = ...) -> Text: ... -def unescape(data: Text, entities: Mapping[Text, Text] = ...) -> Text: ... -def quoteattr(data: Text, entities: Mapping[Text, Text] = ...) -> Text: ... +def escape(data: str, entities: Mapping[str, str] = ...) -> str: ... +def unescape(data: str, entities: Mapping[str, str] = ...) -> str: ... +def quoteattr(data: str, entities: Mapping[str, str] = ...) -> str: ... class XMLGenerator(handler.ContentHandler): def __init__(