Improve classmethods in paramiko stubs (#7113)

This commit is contained in:
Alex Waygood
2022-02-02 21:15:26 +00:00
committed by GitHub
parent b4e97a1909
commit 15d76b072a
5 changed files with 14 additions and 10 deletions

View File

@@ -1,3 +1,4 @@
from _typeshed import Self
from typing import IO, Any, Iterable, Pattern
from paramiko.ssh_exception import ConfigParseError as ConfigParseError, CouldNotCanonicalize as CouldNotCanonicalize
@@ -9,11 +10,11 @@ class SSHConfig:
TOKENS_BY_CONFIG_KEY: dict[str, list[str]]
def __init__(self) -> None: ...
@classmethod
def from_text(cls, text: str) -> SSHConfig: ...
def from_text(cls: type[Self], text: str) -> Self: ...
@classmethod
def from_path(cls, path: str) -> SSHConfig: ...
def from_path(cls: type[Self], path: str) -> Self: ...
@classmethod
def from_file(cls, flo: IO[str]) -> SSHConfig: ...
def from_file(cls: type[Self], 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,3 +1,4 @@
from _typeshed import Self
from typing import Iterator, Mapping, MutableMapping
from paramiko.pkey import PKey
@@ -41,5 +42,5 @@ class HostKeyEntry:
key: PKey
def __init__(self, hostnames: list[str] | None = ..., key: PKey | None = ...) -> None: ...
@classmethod
def from_line(cls, line: str, lineno: int | None = ...) -> HostKeyEntry | None: ...
def from_line(cls: type[Self], line: str, lineno: int | None = ...) -> Self | None: ...
def to_line(self) -> str | None: ...

View File

@@ -36,10 +36,10 @@ class PublicBlob:
comment: str
def __init__(self, type_: str, blob: bytes, comment: str | None = ...) -> None: ...
@classmethod
def from_file(cls, filename: str) -> PublicBlob: ...
def from_file(cls: type[Self], filename: str) -> Self: ...
@classmethod
def from_string(cls, string: str) -> PublicBlob: ...
def from_string(cls: type[Self], string: str) -> Self: ...
@classmethod
def from_message(cls, message: Message) -> PublicBlob: ...
def from_message(cls: type[Self], message: Message) -> Self: ...
def __eq__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...

View File

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

View File

@@ -1,3 +1,4 @@
from _typeshed import Self
from logging import Logger
from typing import IO, Any, Callable, Iterator, Text
@@ -20,8 +21,8 @@ class SFTPClient(BaseSFTP, ClosingContextManager):
def __init__(self, sock: Channel) -> None: ...
@classmethod
def from_transport(
cls, t: Transport, window_size: int | None = ..., max_packet_size: int | None = ...
) -> SFTPClient | None: ...
cls: type[Self], 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]: ...