Use TypeAlias where possible for type aliases (#7630)

This commit is contained in:
Alex Waygood
2022-04-16 02:01:00 +01:00
committed by GitHub
parent c0e6dd3f3f
commit 740193a8fc
218 changed files with 760 additions and 625 deletions

View File

@@ -1,11 +1,12 @@
from threading import Event
from typing import Callable
from typing_extensions import TypeAlias
from paramiko.pkey import PKey
from paramiko.ssh_gss import _SSH_GSSAuth
from paramiko.transport import Transport
_InteractiveCallback = Callable[[str, str, list[tuple[str, bool]]], list[str]]
_InteractiveCallback: TypeAlias = Callable[[str, str, list[tuple[str, bool]]], list[str]]
class AuthHandler:
transport: Transport

View File

@@ -1,5 +1,6 @@
import sys
from typing import Protocol
from typing_extensions import TypeAlias
MSG_DISCONNECT: int
MSG_IGNORE: int
@@ -109,7 +110,7 @@ else:
class _SupportsAsBytes(Protocol):
def asbytes(self) -> bytes: ...
_LikeBytes = bytes | str | _SupportsAsBytes
_LikeBytes: TypeAlias = bytes | str | _SupportsAsBytes
def asbytes(s: _LikeBytes) -> bytes: ...

View File

@@ -1,5 +1,6 @@
import sys
from typing import Any, Iterable
from typing_extensions import TypeAlias
from .common import _LikeBytes
@@ -8,7 +9,7 @@ if sys.version_info >= (3, 0):
else:
from StringIO import StringIO
BytesIO = StringIO[bytes]
BytesIO: TypeAlias = StringIO[bytes]
class Message:
big_int: int

View File

@@ -1,6 +1,7 @@
from _typeshed import Self
from logging import Logger
from typing import IO, Any, Callable, Iterator
from typing_extensions import TypeAlias
from paramiko.channel import Channel
from paramiko.sftp import BaseSFTP
@@ -9,7 +10,7 @@ from paramiko.sftp_file import SFTPFile
from paramiko.transport import Transport
from paramiko.util import ClosingContextManager
_Callback = Callable[[int, int], Any]
_Callback: TypeAlias = Callable[[int, int], Any]
b_slash: bytes

View File

@@ -3,6 +3,7 @@ from socket import socket
from threading import Condition, Event, Lock, Thread
from types import ModuleType
from typing import Any, Callable, Iterable, Protocol, Sequence
from typing_extensions import TypeAlias
from paramiko.auth_handler import AuthHandler, _InteractiveCallback
from paramiko.channel import Channel
@@ -14,8 +15,8 @@ from paramiko.sftp_client import SFTPClient
from paramiko.ssh_gss import _SSH_GSSAuth
from paramiko.util import ClosingContextManager
_Addr = tuple[str, int]
_SocketLike = str | _Addr | socket | Channel
_Addr: TypeAlias = tuple[str, int]
_SocketLike: TypeAlias = str | _Addr | socket | Channel
class _KexEngine(Protocol):
def start_kex(self) -> None: ...