Skip to content

Commit ef966a1

Browse files
authored
[paramiko] Add missing stubs (#14363)
1 parent 3370aa6 commit ef966a1

18 files changed

+250
-123
lines changed
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
paramiko.SFTPServer.__init__
2-
paramiko.sftp_server.SFTPServer.__init__
31
paramiko.util.SupportsClose
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
paramiko._winapi
2+
paramiko.win_openssh.*
23
paramiko.win_pageant
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
paramiko._winapi
2+
paramiko.win_openssh.*
23
paramiko.win_pageant

stubs/paramiko/METADATA.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ version = "3.5.*"
22
upstream_repository = "https://github.com/paramiko/paramiko"
33
# Requires a version of cryptography where cryptography.hazmat.primitives.ciphers.Cipher is generic
44
requires = ["cryptography>=37.0.0"]
5-
partial_stub = true
65

76
[tool.stubtest]
8-
ignore_missing_stub = true
97
# linux and darwin are equivalent
108
platforms = ["linux", "win32"]

stubs/paramiko/paramiko/__init__.pyi

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from paramiko import util as util
12
from paramiko.agent import Agent as Agent, AgentKey as AgentKey
23
from paramiko.channel import Channel as Channel, ChannelFile as ChannelFile
34
from paramiko.client import (
@@ -41,6 +42,47 @@ from paramiko.transport import SecurityOptions as SecurityOptions, Transport as
4142

4243
__author__: str
4344
__license__: str
44-
45-
# Names in __all__ with no definition:
46-
# util
45+
__all__ = [
46+
"Agent",
47+
"AgentKey",
48+
"AuthenticationException",
49+
"AutoAddPolicy",
50+
"BadAuthenticationType",
51+
"BadHostKeyException",
52+
"BufferedFile",
53+
"Channel",
54+
"ChannelException",
55+
"ConfigParseError",
56+
"CouldNotCanonicalize",
57+
"DSSKey",
58+
"ECDSAKey",
59+
"Ed25519Key",
60+
"HostKeys",
61+
"Message",
62+
"MissingHostKeyPolicy",
63+
"PKey",
64+
"PasswordRequiredException",
65+
"ProxyCommand",
66+
"ProxyCommandFailure",
67+
"RSAKey",
68+
"RejectPolicy",
69+
"SFTP",
70+
"SFTPAttributes",
71+
"SFTPClient",
72+
"SFTPError",
73+
"SFTPFile",
74+
"SFTPHandle",
75+
"SFTPServer",
76+
"SFTPServerInterface",
77+
"SSHClient",
78+
"SSHConfig",
79+
"SSHConfigDict",
80+
"SSHException",
81+
"SecurityOptions",
82+
"ServerInterface",
83+
"SubsystemHandler",
84+
"Transport",
85+
"WarningPolicy",
86+
"io_sleep",
87+
"util",
88+
]

stubs/paramiko/paramiko/_winapi.pyi

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import ctypes
33
import sys
44
from _typeshed import Incomplete
55
from types import TracebackType
6-
from typing import Any
76
from typing_extensions import Self
87

98
if sys.platform == "win32":
@@ -18,14 +17,14 @@ if sys.platform == "win32":
1817

1918
def handle_nonzero_success(result: int) -> None: ...
2019
GMEM_MOVEABLE: int
21-
GlobalAlloc: Any
22-
GlobalLock: Any
23-
GlobalUnlock: Any
24-
GlobalSize: Any
25-
CreateFileMapping: Any
26-
MapViewOfFile: Any
27-
UnmapViewOfFile: Any
28-
RtlMoveMemory: Any
20+
GlobalAlloc: Incomplete
21+
GlobalLock: Incomplete
22+
GlobalUnlock: Incomplete
23+
GlobalSize: Incomplete
24+
CreateFileMapping: Incomplete
25+
MapViewOfFile: Incomplete
26+
UnmapViewOfFile: Incomplete
27+
RtlMoveMemory: Incomplete
2928

3029
class MemoryMap:
3130
name: str
@@ -75,21 +74,31 @@ if sys.platform == "win32":
7574

7675
class TOKEN_USER(ctypes.Structure):
7776
num: int
77+
SID: Incomplete
78+
ATTRIBUTES: Incomplete
7879

7980
class SECURITY_DESCRIPTOR(ctypes.Structure):
80-
SECURITY_DESCRIPTOR_CONTROL: Any
81+
SECURITY_DESCRIPTOR_CONTROL: Incomplete
8182
REVISION: int
83+
Revision: int
84+
Sbz1: Incomplete
85+
Control: Incomplete
86+
Owner: Incomplete
87+
Group: Incomplete
88+
Sacl: Incomplete
89+
Dacl: Incomplete
8290

8391
class SECURITY_ATTRIBUTES(ctypes.Structure):
8492
nLength: int
85-
lpSecurityDescriptor: Any
86-
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
93+
lpSecurityDescriptor: int
94+
bInheritHandle: bool
95+
def __init__(self, *args, **kwargs) -> None: ...
8796
@property
88-
def descriptor(self) -> Any: ...
97+
def descriptor(self): ...
8998
@descriptor.setter
90-
def descriptor(self, value: Any) -> None: ...
99+
def descriptor(self, value) -> None: ...
91100

92-
def GetTokenInformation(token: Any, information_class: Any) -> Any: ...
93-
def OpenProcessToken(proc_handle: Any, access: Any) -> Any: ...
101+
def GetTokenInformation(token, information_class): ...
102+
def OpenProcessToken(proc_handle, access): ...
94103
def get_current_user() -> TOKEN_USER: ...
95104
def get_security_attributes_for_user(user: TOKEN_USER | None = None) -> SECURITY_ATTRIBUTES: ...

stubs/paramiko/paramiko/agent.pyi

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import sys
12
from _typeshed import ReadableBuffer
3+
from collections.abc import Mapping
4+
from logging import _ExcInfoType
25
from socket import _RetAddress, socket
36
from threading import Thread
4-
from typing import Protocol
7+
from typing import Final, Protocol
58

69
from paramiko.channel import Channel
710
from paramiko.message import Message, _LikeBytes
@@ -12,10 +15,16 @@ class _AgentProxy(Protocol):
1215
def connect(self) -> None: ...
1316
def close(self) -> None: ...
1417

15-
cSSH2_AGENTC_REQUEST_IDENTITIES: bytes
16-
SSH2_AGENT_IDENTITIES_ANSWER: int
17-
cSSH2_AGENTC_SIGN_REQUEST: bytes
18-
SSH2_AGENT_SIGN_RESPONSE: int
18+
cSSH2_AGENTC_REQUEST_IDENTITIES: Final[bytes]
19+
SSH2_AGENT_IDENTITIES_ANSWER: Final = 12
20+
cSSH2_AGENTC_SIGN_REQUEST: Final[bytes]
21+
SSH2_AGENT_SIGN_RESPONSE: Final = 14
22+
23+
SSH_AGENT_RSA_SHA2_256: Final = 2
24+
SSH_AGENT_RSA_SHA2_512: Final = 4
25+
ALGORITHM_FLAG_MAP: Final[dict[str, int]]
26+
key: str
27+
value: int
1928

2029
class AgentSSH:
2130
def __init__(self) -> None: ...
@@ -33,6 +42,15 @@ class AgentRemoteProxy(AgentProxyThread):
3342
def __init__(self, agent: AgentClientProxy, chan: Channel) -> None: ...
3443
def get_connection(self) -> tuple[socket, _RetAddress]: ...
3544

45+
if sys.platform == "win32":
46+
from .win_openssh import OpenSSHAgentConnection
47+
from .win_pageant import PageantConnection
48+
49+
def get_agent_connection() -> PageantConnection | OpenSSHAgentConnection | None: ...
50+
51+
else:
52+
def get_agent_connection() -> socket | None: ...
53+
3654
class AgentClientProxy:
3755
thread: Thread
3856
def __init__(self, chanRemote: Channel) -> None: ...
@@ -64,6 +82,16 @@ class AgentKey(PKey):
6482
name: str
6583
comment: str
6684
def __init__(self, agent: AgentSSH, blob: ReadableBuffer, comment: str = "") -> None: ...
85+
def log(
86+
self,
87+
level: int,
88+
msg: object,
89+
*args: object,
90+
exc_info: _ExcInfoType = None,
91+
stack_info: bool = False,
92+
stacklevel: int = 1,
93+
extra: Mapping[str, object] | None = None,
94+
) -> None: ...
6795
def asbytes(self) -> bytes: ...
6896
def get_name(self) -> str: ...
6997
def sign_ssh_data(self, data: _LikeBytes, algorithm: str | None = None) -> Message: ...

stubs/paramiko/paramiko/auth_handler.pyi

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ from collections.abc import Callable
22
from threading import Event
33
from typing_extensions import TypeAlias
44

5+
from paramiko.message import Message
56
from paramiko.pkey import PKey
67
from paramiko.ssh_gss import _SSH_GSSAuth
78
from paramiko.transport import Transport
@@ -46,3 +47,12 @@ class GssapiWithMicAuthHandler:
4647
def auth_username(self) -> str: ...
4748
@property
4849
def gss_host(self) -> str: ...
50+
51+
class AuthOnlyHandler(AuthHandler):
52+
def send_auth_request(
53+
self, username: str, method: str, finish_message: Callable[[Message], None] | None = None
54+
) -> list[str]: ...
55+
def auth_none(self, username: str) -> list[str]: ... # type: ignore[override]
56+
def auth_publickey(self, username: str, key: PKey) -> list[str]: ... # type: ignore[override]
57+
def auth_password(self, username: str, password: str) -> list[str]: ... # type: ignore[override]
58+
def auth_interactive(self, username: str, handler: _InteractiveCallback, submethods: str = "") -> list[str]: ... # type: ignore[override]

0 commit comments

Comments
 (0)