Use typing_extensions.Self instead of _typeshed.Self (#9702)

This commit is contained in:
Alex Waygood
2023-02-15 11:32:43 +01:00
committed by GitHub
parent 8cd6d81f15
commit 7180d0223b
140 changed files with 597 additions and 610 deletions

View File

@@ -1,9 +1,10 @@
import builtins
import ctypes
import sys
from _typeshed import Incomplete, Self
from _typeshed import Incomplete
from types import TracebackType
from typing import Any
from typing_extensions import Self
if sys.platform == "win32":
def format_system_message(errno: int) -> str | None: ...
@@ -34,7 +35,7 @@ if sys.platform == "win32":
filemap: Any = ...
view: Any = ...
def __init__(self, name: str, length: int, security_attributes: Incomplete | None = ...) -> None: ...
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def seek(self, pos: int) -> None: ...
def write(self, msg: bytes) -> None: ...
def read(self, n: int) -> bytes: ...

View File

@@ -1,7 +1,7 @@
from _typeshed import Self
from collections.abc import Iterable
from re import Pattern
from typing import IO
from typing_extensions import Self
from paramiko.ssh_exception import ConfigParseError as ConfigParseError, CouldNotCanonicalize as CouldNotCanonicalize
@@ -12,11 +12,11 @@ class SSHConfig:
TOKENS_BY_CONFIG_KEY: dict[str, list[str]]
def __init__(self) -> None: ...
@classmethod
def from_text(cls: type[Self], text: str) -> Self: ...
def from_text(cls, text: str) -> Self: ...
@classmethod
def from_path(cls: type[Self], path: str) -> Self: ...
def from_path(cls, path: str) -> Self: ...
@classmethod
def from_file(cls: type[Self], flo: IO[str]) -> Self: ...
def from_file(cls, flo: IO[str]) -> Self: ...
def parse(self, file_obj: IO[str]) -> None: ...
def lookup(self, hostname: str) -> SSHConfigDict: ...
def canonicalize(self, hostname: str, options: SSHConfigDict, domains: Iterable[str]) -> str: ...

View File

@@ -1,5 +1,5 @@
from _typeshed import Self
from collections.abc import Iterator, Mapping, MutableMapping
from typing_extensions import Self
from paramiko.pkey import PKey
@@ -42,5 +42,5 @@ class HostKeyEntry:
key: PKey
def __init__(self, hostnames: list[str] | None = ..., key: PKey | None = ...) -> None: ...
@classmethod
def from_line(cls: type[Self], line: str, lineno: int | None = ...) -> Self | None: ...
def from_line(cls, line: str, lineno: int | None = ...) -> Self | None: ...
def to_line(self) -> str | None: ...

View File

@@ -1,6 +1,6 @@
from _typeshed import Self
from re import Pattern
from typing import IO
from typing_extensions import Self
from paramiko.message import Message
@@ -24,9 +24,9 @@ class PKey:
def sign_ssh_data(self, data: bytes, algorithm: str | None = ...) -> Message: ...
def verify_ssh_sig(self, data: bytes, msg: Message) -> bool: ...
@classmethod
def from_private_key_file(cls: type[Self], filename: str, password: str | None = ...) -> Self: ...
def from_private_key_file(cls, filename: str, password: str | None = ...) -> Self: ...
@classmethod
def from_private_key(cls: type[Self], file_obj: IO[str], password: str | None = ...) -> Self: ...
def from_private_key(cls, file_obj: IO[str], password: str | None = ...) -> Self: ...
def write_private_key_file(self, filename: str, password: str | None = ...) -> None: ...
def write_private_key(self, file_obj: IO[str], password: str | None = ...) -> None: ...
def load_certificate(self, value: Message | str) -> None: ...
@@ -37,10 +37,10 @@ class PublicBlob:
comment: str
def __init__(self, type_: str, blob: bytes, comment: str | None = ...) -> None: ...
@classmethod
def from_file(cls: type[Self], filename: str) -> Self: ...
def from_file(cls, filename: str) -> Self: ...
@classmethod
def from_string(cls: type[Self], string: str) -> Self: ...
def from_string(cls, string: str) -> Self: ...
@classmethod
def from_message(cls: type[Self], message: Message) -> Self: ...
def from_message(cls, message: Message) -> Self: ...
def __eq__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...

View File

@@ -1,5 +1,5 @@
from _typeshed import Self
from os import stat_result
from typing_extensions import Self
class SFTPAttributes:
FLAG_SIZE: int
@@ -18,5 +18,5 @@ class SFTPAttributes:
attr: dict[str, str]
def __init__(self) -> None: ...
@classmethod
def from_stat(cls: type[Self], obj: stat_result, filename: str | None = ...) -> Self: ...
def from_stat(cls, obj: stat_result, filename: str | None = ...) -> Self: ...
def asbytes(self) -> bytes: ...

View File

@@ -1,8 +1,7 @@
from _typeshed import Self
from collections.abc import Callable, Iterator
from logging import Logger
from typing import IO
from typing_extensions import TypeAlias
from typing_extensions import Self, TypeAlias
from paramiko.channel import Channel
from paramiko.sftp import BaseSFTP
@@ -22,9 +21,7 @@ class SFTPClient(BaseSFTP, ClosingContextManager):
logger: Logger
def __init__(self, sock: Channel) -> None: ...
@classmethod
def from_transport(
cls: type[Self], t: Transport, window_size: int | None = ..., max_packet_size: int | None = ...
) -> Self | None: ...
def from_transport(cls, t: Transport, window_size: int | None = ..., max_packet_size: int | None = ...) -> Self | None: ...
def close(self) -> None: ...
def get_channel(self) -> Channel | None: ...
def listdir(self, path: str = ...) -> list[str]: ...

View File

@@ -1,8 +1,8 @@
from _typeshed import Self
from hashlib import _Hash
from logging import Logger, LogRecord
from types import TracebackType
from typing import IO, AnyStr, Protocol
from typing_extensions import Self
from paramiko.config import SSHConfig, SSHConfigDict
from paramiko.hostkeys import HostKeys
@@ -32,7 +32,7 @@ def get_logger(name: str) -> Logger: ...
def constant_time_bytes_eq(a: AnyStr, b: AnyStr) -> bool: ...
class ClosingContextManager:
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def __exit__(
self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> None: ...