Delete python 2 branches from third-party stubs (#7741)

Since #7703, we no longer have third-party stubs that support Python 2, so code like `if sys.version_info >= (3, 0)` can be simplified.
This commit is contained in:
Akuli
2022-04-29 22:53:01 +03:00
committed by GitHub
parent 002c8e2586
commit e613fc483b
21 changed files with 40 additions and 203 deletions

View File

@@ -1,4 +1,3 @@
import sys
from typing import Protocol
from typing_extensions import TypeAlias
@@ -100,12 +99,8 @@ max_byte: bytes
cr_byte: bytes
linefeed_byte: bytes
crlf: bytes
if sys.version_info >= (3, 0):
cr_byte_value: int
linefeed_byte_value: int
else:
cr_byte_value: bytes
linefeed_byte_value: bytes
cr_byte_value: int
linefeed_byte_value: int
class _SupportsAsBytes(Protocol):
def asbytes(self) -> bytes: ...

View File

@@ -1,16 +1,11 @@
import sys
from _typeshed import ReadableBuffer as ReadableBuffer
from collections.abc import Callable
from hashlib import _Hash
from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey
from paramiko.message import Message
from paramiko.transport import Transport
if sys.version_info >= (3, 0):
from hashlib import _Hash
else:
from hashlib import _hash as _Hash
c_MSG_KEXECDH_INIT: bytes
c_MSG_KEXECDH_REPLY: bytes

View File

@@ -1,16 +1,11 @@
import sys
from _typeshed import ReadableBuffer
from collections.abc import Callable
from hashlib import _Hash
from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurve, EllipticCurvePrivateKey, EllipticCurvePublicKey
from paramiko.message import Message
from paramiko.transport import Transport
if sys.version_info >= (3, 0):
from hashlib import _Hash
else:
from hashlib import _hash as _Hash
c_MSG_KEXECDH_INIT: bytes
c_MSG_KEXECDH_REPLY: bytes

View File

@@ -1,15 +1,10 @@
import sys
from _typeshed import ReadableBuffer
from collections.abc import Callable
from hashlib import _Hash
from paramiko.message import Message
from paramiko.transport import Transport
if sys.version_info >= (3, 0):
from hashlib import _Hash
else:
from hashlib import _hash as _Hash
c_MSG_KEXDH_GEX_REQUEST_OLD: bytes
c_MSG_KEXDH_GEX_GROUP: bytes
c_MSG_KEXDH_GEX_INIT: bytes

View File

@@ -1,15 +1,10 @@
import sys
from _typeshed import ReadableBuffer
from collections.abc import Callable
from hashlib import _Hash
from paramiko.message import Message
from paramiko.transport import Transport
if sys.version_info >= (3, 0):
from hashlib import _Hash
else:
from hashlib import _hash as _Hash
c_MSG_KEXDH_INIT: bytes
c_MSG_KEXDH_REPLY: bytes
b7fffffffffffffff: bytes

View File

@@ -1,14 +1,9 @@
import sys
from _typeshed import ReadableBuffer
from collections.abc import Callable
from hashlib import _Hash
from paramiko.kex_group1 import KexGroup1 as KexGroup1
if sys.version_info >= (3, 0):
from hashlib import _Hash
else:
from hashlib import _hash as _Hash
class KexGroup14(KexGroup1):
P: int
G: int

View File

@@ -1,14 +1,9 @@
import sys
from _typeshed import ReadableBuffer
from collections.abc import Callable
from hashlib import _Hash
from paramiko.kex_group1 import KexGroup1 as KexGroup1
if sys.version_info >= (3, 0):
from hashlib import _Hash
else:
from hashlib import _hash as _Hash
class KexGroup16SHA512(KexGroup1):
name: str
P: int

View File

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

View File

@@ -1,5 +1,5 @@
import sys
from collections.abc import Callable
from hashlib import _Hash
from logging import Logger
from socket import socket
from typing import Any
@@ -8,11 +8,6 @@ from cryptography.hazmat.primitives.ciphers import Cipher
from paramiko.compress import ZlibCompressor, ZlibDecompressor
from paramiko.message import Message
if sys.version_info >= (3, 0):
from hashlib import _Hash
else:
from hashlib import _hash as _Hash
def compute_hmac(key: bytes, message: bytes, digest_class: _Hash) -> bytes: ...
class NeedRekeyException(Exception): ...

View File

@@ -1,5 +1,6 @@
import sys
import builtins as builtins
from collections.abc import Iterable, Sequence
from io import BytesIO as BytesIO, StringIO as StringIO
from typing import Any, TypeVar
_T = TypeVar("_T")
@@ -16,19 +17,6 @@ def input(prompt: Any) -> str: ...
def decodebytes(s: bytes) -> bytes: ...
def encodebytes(s: bytes) -> bytes: ...
if sys.version_info >= (3, 0):
import builtins as builtins
import io
StringIO = io.StringIO
BytesIO = io.BytesIO
else:
import __builtin__ as builtins
import cStringIO
StringIO = cStringIO.StringIO
BytesIO = StringIO
bytes = builtins.bytes
def byte_ord(c: int | str) -> int: ...

View File

@@ -1,6 +1,6 @@
import sys
from _typeshed import Self
from collections.abc import Callable
from hashlib import _Hash
from logging import Logger, LogRecord
from types import TracebackType
from typing import IO, AnyStr, Protocol, TypeVar
@@ -8,11 +8,6 @@ from typing import IO, AnyStr, Protocol, TypeVar
from paramiko.config import SSHConfig, SSHConfigDict
from paramiko.hostkeys import HostKeys
if sys.version_info >= (3, 0):
from hashlib import _Hash
else:
from hashlib import _hash as _Hash
class SupportsClose(Protocol):
def close(self) -> None: ...