2 from _typeshed import Self, SupportsRead, SupportsReadline
3 from socket import socket
4 from ssl import SSLContext
5 from types import TracebackType
6 from typing import Any, Callable, Iterable, Iterator, TextIO, Tuple, Type
7 from typing_extensions import Literal
15 class Error(Exception): ...
16 class error_reply(Error): ...
17 class error_temp(Error): ...
18 class error_perm(Error): ...
19 class error_proto(Error): ...
21 all_errors: Tuple[Type[Exception], ...]
37 # The following variable is intentionally left undocumented.
38 # See https://bugs.python.org/issue43285 for relevant discussion
39 # trust_server_pasv_ipv4_address: bool
40 def __enter__(self: Self) -> Self: ...
42 self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
44 source_address: tuple[str, int] | None
45 if sys.version_info >= (3, 9):
53 source_address: tuple[str, int] | None = ...,
65 source_address: tuple[str, int] | None = ...,
68 self, host: str = ..., port: int = ..., timeout: float = ..., source_address: tuple[str, int] | None = ...
70 def getwelcome(self) -> str: ...
71 def set_debuglevel(self, level: int) -> None: ...
72 def debug(self, level: int) -> None: ...
73 def set_pasv(self, val: bool | int) -> None: ...
74 def sanitize(self, s: str) -> str: ...
75 def putline(self, line: str) -> None: ...
76 def putcmd(self, line: str) -> None: ...
77 def getline(self) -> str: ...
78 def getmultiline(self) -> str: ...
79 def getresp(self) -> str: ...
80 def voidresp(self) -> str: ...
81 def abort(self) -> str: ...
82 def sendcmd(self, cmd: str) -> str: ...
83 def voidcmd(self, cmd: str) -> str: ...
84 def sendport(self, host: str, port: int) -> str: ...
85 def sendeprt(self, host: str, port: int) -> str: ...
86 def makeport(self) -> socket: ...
87 def makepasv(self) -> tuple[str, int]: ...
88 def login(self, user: str = ..., passwd: str = ..., acct: str = ...) -> str: ...
89 # In practice, `rest` rest can actually be anything whose str() is an integer sequence, so to make it simple we allow integers.
90 def ntransfercmd(self, cmd: str, rest: int | str | None = ...) -> tuple[socket, int]: ...
91 def transfercmd(self, cmd: str, rest: int | str | None = ...) -> socket: ...
93 self, cmd: str, callback: Callable[[bytes], Any], blocksize: int = ..., rest: int | str | None = ...
98 fp: SupportsRead[bytes],
100 callback: Callable[[bytes], Any] | None = ...,
101 rest: int | str | None = ...,
103 def retrlines(self, cmd: str, callback: Callable[[str], Any] | None = ...) -> str: ...
104 def storlines(self, cmd: str, fp: SupportsReadline[bytes], callback: Callable[[bytes], Any] | None = ...) -> str: ...
105 def acct(self, password: str) -> str: ...
106 def nlst(self, *args: str) -> list[str]: ...
107 # Technically only the last arg can be a Callable but ...
108 def dir(self, *args: str | Callable[[str], None]) -> None: ...
109 def mlsd(self, path: str = ..., facts: Iterable[str] = ...) -> Iterator[tuple[str, dict[str, str]]]: ...
110 def rename(self, fromname: str, toname: str) -> str: ...
111 def delete(self, filename: str) -> str: ...
112 def cwd(self, dirname: str) -> str: ...
113 def size(self, filename: str) -> int | None: ...
114 def mkd(self, dirname: str) -> str: ...
115 def rmd(self, dirname: str) -> str: ...
116 def pwd(self) -> str: ...
117 def quit(self) -> str: ...
118 def close(self) -> None: ...
121 if sys.version_info >= (3, 9):
128 keyfile: str | None = ...,
129 certfile: str | None = ...,
130 context: SSLContext | None = ...,
131 timeout: float = ...,
132 source_address: tuple[str, int] | None = ...,
143 keyfile: str | None = ...,
144 certfile: str | None = ...,
145 context: SSLContext | None = ...,
146 timeout: float = ...,
147 source_address: tuple[str, int] | None = ...,
153 def login(self, user: str = ..., passwd: str = ..., acct: str = ..., secure: bool = ...) -> str: ...
154 def auth(self) -> str: ...
155 def prot_p(self) -> str: ...
156 def prot_c(self) -> str: ...
157 def ccc(self) -> str: ...
159 def parse150(resp: str) -> int | None: ... # undocumented
160 def parse227(resp: str) -> tuple[str, int]: ... # undocumented
161 def parse229(resp: str, peer: Any) -> tuple[str, int]: ... # undocumented
162 def parse257(resp: str) -> str: ... # undocumented
164 source: FTP, sourcename: str, target: FTP, targetname: str = ..., type: Literal["A", "I"] = ...
165 ) -> None: ... # undocumented