Use PEP 585 syntax in Python 2, protobuf & _ast stubs, where possible (#6949)

This commit is contained in:
Alex Waygood
2022-01-18 15:14:03 +00:00
committed by GitHub
parent aa885ecd65
commit 8af5e0d340
264 changed files with 2217 additions and 2411 deletions

View File

@@ -1,7 +1,7 @@
from _typeshed import SupportsRead, SupportsReadline
from socket import socket
from ssl import SSLContext
from typing import Any, BinaryIO, Callable, List, Text, Tuple, Type, Union
from typing import Any, BinaryIO, Callable, Text, Union
from typing_extensions import Literal
_IntOrStr = Union[int, Text]
@@ -17,7 +17,7 @@ class error_temp(Error): ...
class error_perm(Error): ...
class error_proto(Error): ...
all_errors: Tuple[Type[Exception], ...]
all_errors: tuple[type[Exception], ...]
class FTP:
debugging: int
@@ -57,10 +57,10 @@ class FTP:
def sendport(self, host: Text, port: int) -> str: ...
def sendeprt(self, host: Text, port: int) -> str: ...
def makeport(self) -> socket: ...
def makepasv(self) -> Tuple[str, int]: ...
def makepasv(self) -> tuple[str, int]: ...
def login(self, user: Text = ..., passwd: Text = ..., acct: Text = ...) -> 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: _IntOrStr | None = ...) -> Tuple[socket, int]: ...
def ntransfercmd(self, cmd: Text, rest: _IntOrStr | None = ...) -> tuple[socket, int]: ...
def transfercmd(self, cmd: Text, rest: _IntOrStr | None = ...) -> socket: ...
def retrbinary(
self, cmd: Text, callback: Callable[[bytes], Any], blocksize: int = ..., rest: _IntOrStr | None = ...
@@ -76,7 +76,7 @@ class FTP:
def retrlines(self, cmd: Text, callback: Callable[[str], Any] | None = ...) -> str: ...
def storlines(self, cmd: Text, fp: SupportsReadline[bytes], callback: Callable[[bytes], Any] | None = ...) -> str: ...
def acct(self, password: Text) -> str: ...
def nlst(self, *args: Text) -> List[str]: ...
def nlst(self, *args: Text) -> list[str]: ...
# Technically only the last arg can be a Callable but ...
def dir(self, *args: str | Callable[[str], None]) -> None: ...
def rename(self, fromname: Text, toname: Text) -> str: ...
@@ -100,7 +100,7 @@ class FTP_TLS(FTP):
certfile: str | None = ...,
context: SSLContext | None = ...,
timeout: float = ...,
source_address: Tuple[str, int] | None = ...,
source_address: tuple[str, int] | None = ...,
) -> None: ...
ssl_version: int
keyfile: str | None
@@ -113,14 +113,14 @@ class FTP_TLS(FTP):
class Netrc:
def __init__(self, filename: Text | None = ...) -> None: ...
def get_hosts(self) -> List[str]: ...
def get_account(self, host: Text) -> Tuple[str | None, str | None, str | None]: ...
def get_macros(self) -> List[str]: ...
def get_macro(self, macro: Text) -> Tuple[str, ...]: ...
def get_hosts(self) -> list[str]: ...
def get_account(self, host: Text) -> tuple[str | None, str | None, str | None]: ...
def get_macros(self) -> list[str]: ...
def get_macro(self, macro: Text) -> tuple[str, ...]: ...
def parse150(resp: str) -> int | None: ... # undocumented
def parse227(resp: str) -> Tuple[str, int]: ... # undocumented
def parse229(resp: str, peer: Any) -> Tuple[str, int]: ... # undocumented
def parse227(resp: str) -> tuple[str, int]: ... # undocumented
def parse229(resp: str, peer: Any) -> tuple[str, int]: ... # undocumented
def parse257(resp: str) -> str: ... # undocumented
def ftpcp(
source: FTP, sourcename: str, target: FTP, targetname: str = ..., type: Literal["A", "I"] = ...