Enable pyright for all Python 3 stubs (#5597)

* pyright: disable reportUnknownParameterType

Unknown parameter types are preferred over Any annotations for
incomplete stubs. Especially larger stubs are expected to be
incomplete for some time and it would be a shame to lose the
other pyright warnings for those stubs.

* Also disable reportUnknownVariableType

Fix problems with tkinter

* Disable reportUnknownMemberType

Fix pyright problems
This commit is contained in:
Sebastian Rittau
2021-06-09 16:14:22 +02:00
committed by GitHub
parent c601d5cf3d
commit 711580722b
78 changed files with 633 additions and 687 deletions

View File

@@ -1,97 +1,85 @@
import builtins
import ctypes.wintypes
import ctypes
import sys
from types import TracebackType
from typing import Any, Optional, Type, TypeVar
assert sys.platform == "win32"
if sys.platform == "win32":
_T = TypeVar("_T")
def format_system_message(errno: int) -> Optional[str]: ...
class WindowsError(builtins.WindowsError):
def __init__(self, value: Optional[int] = ...) -> None: ...
@property
def message(self) -> str: ...
@property
def code(self) -> int: ...
def handle_nonzero_success(result: int) -> None: ...
GMEM_MOVEABLE: int
GlobalAlloc: Any
GlobalLock: Any
GlobalUnlock: Any
GlobalSize: Any
CreateFileMapping: Any
MapViewOfFile: Any
UnmapViewOfFile: Any
RtlMoveMemory: Any
class MemoryMap:
name: str
length: int
security_attributes: Any = ...
pos: int
filemap: Any = ...
view: Any = ...
def __init__(self, name: str, length: int, security_attributes: Optional[Any] = ...) -> None: ...
def __enter__(self: _T) -> _T: ...
def seek(self, pos: int) -> None: ...
def write(self, msg: bytes) -> None: ...
def read(self, n: int) -> bytes: ...
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], tb: Optional[TracebackType]
) -> None: ...
READ_CONTROL: int
STANDARD_RIGHTS_REQUIRED: int
STANDARD_RIGHTS_READ: int
STANDARD_RIGHTS_WRITE: int
STANDARD_RIGHTS_EXECUTE: int
STANDARD_RIGHTS_ALL: int
POLICY_VIEW_LOCAL_INFORMATION: int
POLICY_VIEW_AUDIT_INFORMATION: int
POLICY_GET_PRIVATE_INFORMATION: int
POLICY_TRUST_ADMIN: int
POLICY_CREATE_ACCOUNT: int
POLICY_CREATE_SECRET: int
POLICY_CREATE_PRIVILEGE: int
POLICY_SET_DEFAULT_QUOTA_LIMITS: int
POLICY_SET_AUDIT_REQUIREMENTS: int
POLICY_AUDIT_LOG_ADMIN: int
POLICY_SERVER_ADMIN: int
POLICY_LOOKUP_NAMES: int
POLICY_NOTIFICATION: int
POLICY_ALL_ACCESS: int
POLICY_READ: int
POLICY_WRITE: int
POLICY_EXECUTE: int
class TokenAccess:
TOKEN_QUERY: int
class TokenInformationClass:
TokenUser: int
class TOKEN_USER(ctypes.Structure):
num: int
class SECURITY_DESCRIPTOR(ctypes.Structure):
SECURITY_DESCRIPTOR_CONTROL: Any
REVISION: int
class SECURITY_ATTRIBUTES(ctypes.Structure):
nLength: int
lpSecurityDescriptor: Any
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
@property
def descriptor(self) -> Any: ...
@descriptor.setter
def descriptor(self, value: Any) -> None: ...
def GetTokenInformation(token: Any, information_class: Any) -> Any: ...
def OpenProcessToken(proc_handle: Any, access: Any) -> Any: ...
def get_current_user() -> TOKEN_USER: ...
def get_security_attributes_for_user(user: Optional[TOKEN_USER] = ...) -> SECURITY_ATTRIBUTES: ...
_T = TypeVar("_T")
def format_system_message(errno: int) -> Optional[str]: ...
class WindowsError(builtins.WindowsError):
def __init__(self, value: Optional[int] = ...) -> None: ...
@property
def message(self) -> str: ...
@property
def code(self) -> int: ...
def handle_nonzero_success(result: int) -> None: ...
GMEM_MOVEABLE: int
GlobalAlloc: Any
GlobalLock: Any
GlobalUnlock: Any
GlobalSize: Any
CreateFileMapping: Any
MapViewOfFile: Any
UnmapViewOfFile: Any
RtlMoveMemory: Any
class MemoryMap:
name: str
length: int
security_attributes: Any = ...
pos: int
filemap: Any = ...
view: Any = ...
def __init__(self, name: str, length: int, security_attributes: Optional[Any] = ...) -> None: ...
def __enter__(self: _T) -> _T: ...
def seek(self, pos: int) -> None: ...
def write(self, msg: bytes) -> None: ...
def read(self, n: int) -> bytes: ...
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], tb: Optional[TracebackType]
) -> None: ...
READ_CONTROL: int
STANDARD_RIGHTS_REQUIRED: int
STANDARD_RIGHTS_READ: int
STANDARD_RIGHTS_WRITE: int
STANDARD_RIGHTS_EXECUTE: int
STANDARD_RIGHTS_ALL: int
POLICY_VIEW_LOCAL_INFORMATION: int
POLICY_VIEW_AUDIT_INFORMATION: int
POLICY_GET_PRIVATE_INFORMATION: int
POLICY_TRUST_ADMIN: int
POLICY_CREATE_ACCOUNT: int
POLICY_CREATE_SECRET: int
POLICY_CREATE_PRIVILEGE: int
POLICY_SET_DEFAULT_QUOTA_LIMITS: int
POLICY_SET_AUDIT_REQUIREMENTS: int
POLICY_AUDIT_LOG_ADMIN: int
POLICY_SERVER_ADMIN: int
POLICY_LOOKUP_NAMES: int
POLICY_NOTIFICATION: int
POLICY_ALL_ACCESS: int
POLICY_READ: int
POLICY_WRITE: int
POLICY_EXECUTE: int
class TokenAccess:
TOKEN_QUERY: int
class TokenInformationClass:
TokenUser: int
class TOKEN_USER(ctypes.Structure):
num: int
class SECURITY_DESCRIPTOR(ctypes.Structure):
SECURITY_DESCRIPTOR_CONTROL: Any
REVISION: int
class SECURITY_ATTRIBUTES(ctypes.Structure):
nLength: int
lpSecurityDescriptor: Any
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
@property
def descriptor(self) -> Any: ...
@descriptor.setter
def descriptor(self, value: Any) -> None: ...
def GetTokenInformation(token: Any, information_class: Any) -> Any: ...
def OpenProcessToken(proc_handle: Any, access: Any) -> Any: ...
def get_current_user() -> TOKEN_USER: ...
def get_security_attributes_for_user(user: Optional[TOKEN_USER] = ...) -> SECURITY_ATTRIBUTES: ...

View File

@@ -1,9 +1,7 @@
from threading import Event
from typing import Callable, List, Optional, Tuple
from paramiko.message import Message
from paramiko.pkey import PKey
from paramiko.server import InteractiveQuery
from paramiko.ssh_gss import _SSH_GSSAuth
from paramiko.transport import Transport

View File

@@ -2,9 +2,8 @@ from logging import Logger
from threading import Condition, Event, Lock
from typing import Any, Callable, Mapping, Optional, Tuple, TypeVar
from paramiko.buffered_pipe import BufferedPipe, PipeTimeout
from paramiko.buffered_pipe import BufferedPipe
from paramiko.file import BufferedFile
from paramiko.message import Message
from paramiko.transport import Transport
from paramiko.util import ClosingContextManager
@@ -19,8 +18,8 @@ class Channel(ClosingContextManager):
active: bool
eof_received: int
eof_sent: int
in_buffer: BufferedPipe
in_stderr_buffer: BufferedPipe
in_buffer: BufferedPipe[Any]
in_stderr_buffer: BufferedPipe[Any]
timeout: Optional[float]
closed: bool
ultra_debug: bool
@@ -89,7 +88,7 @@ class Channel(ClosingContextManager):
def shutdown_read(self) -> None: ...
def shutdown_write(self) -> None: ...
class ChannelFile(BufferedFile):
class ChannelFile(BufferedFile[Any]):
channel: Channel
def __init__(self, channel: Channel, mode: str = ..., bufsize: int = ...) -> None: ...

View File

@@ -1,7 +1,6 @@
from socket import socket
from typing import Any, Dict, Iterable, Mapping, NoReturn, Optional, Tuple, Type, Union
from typing import Dict, Iterable, Mapping, NoReturn, Optional, Tuple, Type, Union
from paramiko.agent import Agent
from paramiko.channel import Channel, ChannelFile, ChannelStderrFile, ChannelStdinFile
from paramiko.hostkeys import HostKeys
from paramiko.pkey import PKey

View File

@@ -1,5 +1,5 @@
import sys
from typing import Any, Dict, Protocol, Text, Union
from typing import Dict, Protocol, Text, Union
MSG_DISCONNECT: int
MSG_IGNORE: int

View File

@@ -1,8 +1,7 @@
from typing import IO, Any, Callable, Optional, Tuple
from paramiko.ber import BER
from paramiko.message import Message
from paramiko.pkey import PKey, PublicBlob
from paramiko.pkey import PKey
class DSSKey(PKey):
p: Optional[int]

View File

@@ -1,6 +1,10 @@
from typing import IO, Any, Callable, List, Optional, Sequence, Tuple, Type
from cryptography.hazmat.primitives.asymmetric.ec2 import EllipticCurve, EllipticCurvePrivateKey, EllipticCurvePublicKey
from cryptography.hazmat.primitives.asymmetric.ec2 import ( # type: ignore
EllipticCurve,
EllipticCurvePrivateKey,
EllipticCurvePublicKey,
)
from cryptography.hazmat.primitives.hashes import HashAlgorithm
from paramiko.message import Message
from paramiko.pkey import PKey

View File

@@ -1,4 +1,4 @@
from typing import IO, Any, Optional
from typing import IO, Optional
from paramiko.message import Message
from paramiko.pkey import PKey

View File

@@ -1,4 +1,4 @@
from typing import AnyStr, Generic, Iterable, List, Optional, Tuple, Union
from typing import Any, AnyStr, Generic, Iterable, List, Optional, Tuple, Union
from paramiko.util import ClosingContextManager
@@ -18,7 +18,7 @@ class BufferedFile(ClosingContextManager, Generic[AnyStr]):
newlines: Union[None, AnyStr, Tuple[AnyStr, ...]]
def __init__(self) -> None: ...
def __del__(self) -> None: ...
def __iter__(self) -> BufferedFile: ...
def __iter__(self) -> BufferedFile[Any]: ...
def close(self) -> None: ...
def flush(self) -> None: ...
def __next__(self) -> AnyStr: ...
@@ -33,6 +33,6 @@ class BufferedFile(ClosingContextManager, Generic[AnyStr]):
def tell(self) -> int: ...
def write(self, data: AnyStr) -> None: ...
def writelines(self, sequence: Iterable[AnyStr]) -> None: ...
def xreadlines(self) -> BufferedFile: ...
def xreadlines(self) -> BufferedFile[Any]: ...
@property
def closed(self) -> bool: ...

View File

@@ -1,4 +1,4 @@
from typing import Dict, Iterator, List, Mapping, MutableMapping, Optional
from typing import Iterator, List, Mapping, MutableMapping, Optional
from paramiko.pkey import PKey

View File

@@ -1,6 +1,6 @@
import sys
from _typeshed import ReadableBuffer as ReadableBuffer
from typing import Any, Callable, Optional
from typing import Callable, Optional
from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey
from paramiko.message import Message

View File

@@ -2,7 +2,11 @@ import sys
from _typeshed import ReadableBuffer
from typing import Callable, Optional, Union
from cryptography.hazmat.primitives.asymmetric.ec2 import EllipticCurve, EllipticCurvePrivateKey, EllipticCurvePublicKey
from cryptography.hazmat.primitives.asymmetric.ec2 import ( # type: ignore
EllipticCurve,
EllipticCurvePrivateKey,
EllipticCurvePublicKey,
)
from paramiko.message import Message
from paramiko.transport import Transport

View File

@@ -1,4 +1,4 @@
from typing import IO, Any, Optional, Pattern, Text, Type, TypeVar, Union
from typing import IO, Optional, Pattern, Type, TypeVar, Union
from paramiko.message import Message

View File

@@ -1,11 +1,11 @@
from subprocess import Popen
from typing import List, Optional
from typing import Any, List, Optional
from paramiko.util import ClosingContextManager
class ProxyCommand(ClosingContextManager):
cmd: List[str]
process: Popen
process: Popen[Any]
timeout: Optional[float]
def __init__(self, command_line: str) -> None: ...
def send(self, content: bytes) -> int: ...

View File

@@ -5,11 +5,11 @@ _T = TypeVar("_T")
PY2: bool
string_types: Union[Type, Sequence[Type]]
text_type: Union[Type, Sequence[Type]]
bytes_types: Union[Type, Sequence[Type]]
string_types: Union[Type[Any], Sequence[Type[Any]]]
text_type: Union[Type[Any], Sequence[Type[Any]]]
bytes_types: Union[Type[Any], Sequence[Type[Any]]]
bytes = bytes
integer_types: Union[Type, Sequence[Type]]
integer_types: Union[Type[Any], Sequence[Type[Any]]]
long = int
def input(prompt: Any) -> str: ...

View File

@@ -1,11 +1,11 @@
from typing import Iterator, Optional, Sequence, Tuple
from typing import Any, Iterator, Optional, Sequence, Tuple
from paramiko.file import BufferedFile
from paramiko.sftp_attr import SFTPAttributes
from paramiko.sftp_client import SFTPClient
from paramiko.sftp_handle import SFTPHandle
class SFTPFile(BufferedFile):
class SFTPFile(BufferedFile[Any]):
MAX_REQUEST_SIZE: int
sftp: SFTPClient
handle: SFTPHandle

View File

@@ -1,7 +1,6 @@
from typing import Union
from paramiko.sftp_attr import SFTPAttributes
from paramiko.sftp_server import SFTPServer
from paramiko.util import ClosingContextManager
class SFTPHandle(ClosingContextManager):

View File

@@ -1,7 +1,5 @@
from typing import Any, Optional, Tuple, Type
from paramiko.ssh_exception import SSHException
GSS_AUTH_AVAILABLE: bool
GSS_EXCEPTIONS: Tuple[Type[Exception], ...]

View File

@@ -6,11 +6,9 @@ from typing import Any, Callable, Dict, Iterable, List, Optional, Protocol, Sequ
from paramiko.auth_handler import AuthHandler, _InteractiveCallback
from paramiko.channel import Channel
from paramiko.compress import ZlibCompressor, ZlibDecompressor
from paramiko.message import Message
from paramiko.packet import NeedRekeyException, Packetizer
from paramiko.packet import Packetizer
from paramiko.pkey import PKey
from paramiko.primes import ModulusPack
from paramiko.server import ServerInterface, SubsystemHandler
from paramiko.sftp_client import SFTPClient
from paramiko.ssh_gss import _SSH_GSSAuth

View File

@@ -1,7 +1,7 @@
import sys
from logging import Logger, LogRecord
from types import TracebackType
from typing import IO, AnyStr, Callable, Generic, List, Optional, Protocol, Text, Type, TypeVar, Union
from typing import IO, AnyStr, Callable, List, Optional, Protocol, Type, TypeVar, Union
from paramiko.config import SSHConfig, SSHConfigDict
from paramiko.hostkeys import HostKeys
@@ -46,7 +46,7 @@ def constant_time_bytes_eq(a: AnyStr, b: AnyStr) -> bool: ...
class ClosingContextManager:
def __enter__(self: _TC) -> _TC: ...
def __exit__(
self: _TC, type: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType]
self, type: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType]
) -> None: ...
def clamp_value(minimum: int, val: int, maximum: int) -> int: ...

View File

@@ -1,16 +1,12 @@
import ctypes.wintypes
import ctypes
import sys
assert sys.platform == "win32"
win32con_WM_COPYDATA: int
def can_talk_to_agent(): ...
class COPYDATASTRUCT(ctypes.Structure): ...
class PageantConnection:
def __init__(self) -> None: ...
def send(self, data: bytes) -> None: ...
def recv(self, n: int) -> bytes: ...
def close(self) -> None: ...
if sys.platform == "win32":
win32con_WM_COPYDATA: int
def can_talk_to_agent(): ...
class COPYDATASTRUCT(ctypes.Structure): ...
class PageantConnection:
def __init__(self) -> None: ...
def send(self, data: bytes) -> None: ...
def recv(self, n: int) -> bytes: ...
def close(self) -> None: ...