Replace 'Text' with 'str' in py3 stdlib (#5466)

This commit is contained in:
Sebastian Rittau
2021-05-16 16:10:48 +02:00
committed by GitHub
parent dbe77b6ae9
commit 6a9c89e928
49 changed files with 328 additions and 349 deletions

View File

@@ -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: ...