mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 20:24:30 +08:00
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:
@@ -1,5 +1,3 @@
|
||||
import sys
|
||||
|
||||
from .connections import Connection as Connection
|
||||
from .constants import FIELD_TYPE as FIELD_TYPE
|
||||
from .converters import escape_dict as escape_dict, escape_sequence as escape_sequence, escape_string as escape_string
|
||||
@@ -43,12 +41,7 @@ TIMESTAMP: DBAPISet
|
||||
DATETIME: DBAPISet
|
||||
ROWID: DBAPISet
|
||||
|
||||
if sys.version_info >= (3, 0):
|
||||
def Binary(x) -> bytes: ...
|
||||
|
||||
else:
|
||||
def Binary(x) -> bytearray: ...
|
||||
|
||||
def Binary(x) -> bytes: ...
|
||||
def get_client_info() -> str: ...
|
||||
|
||||
__version__: str
|
||||
|
||||
@@ -1,20 +1,8 @@
|
||||
import sys
|
||||
from base64 import encodebytes as encodebytes
|
||||
from typing import Any
|
||||
|
||||
if sys.version_info >= (3,):
|
||||
from base64 import encodebytes as encodebytes
|
||||
else:
|
||||
from base64 import encodestring
|
||||
|
||||
encodebytes = encodestring
|
||||
|
||||
expanduser: Any
|
||||
|
||||
if sys.version_info >= (3, 0):
|
||||
StandardError = Exception
|
||||
else:
|
||||
from __builtin__ import StandardError as StandardError
|
||||
|
||||
StandardError = Exception
|
||||
long_type: Any
|
||||
unquote_str: Any
|
||||
parse_qs_safe: Any
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import datetime
|
||||
import io
|
||||
import logging.handlers
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
from collections.abc import Callable, Iterable, Mapping, Sequence
|
||||
from contextlib import AbstractContextManager
|
||||
from email.message import Message
|
||||
from hashlib import _Hash
|
||||
from typing import IO, Any, TypeVar
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
@@ -13,30 +15,6 @@ import boto.connection
|
||||
_KT = TypeVar("_KT")
|
||||
_VT = TypeVar("_VT")
|
||||
|
||||
if sys.version_info >= (3,):
|
||||
# TODO move _StringIO definition into boto.compat once stubs exist and rename to StringIO
|
||||
import io
|
||||
|
||||
_StringIO: TypeAlias = io.StringIO
|
||||
|
||||
from hashlib import _Hash
|
||||
|
||||
_HashType: TypeAlias = _Hash
|
||||
|
||||
from email.message import Message as _Message
|
||||
else:
|
||||
# TODO move _StringIO definition into boto.compat once stubs exist and rename to StringIO
|
||||
import StringIO
|
||||
|
||||
_StringIO: TypeAlias = StringIO.StringIO[Any]
|
||||
|
||||
from hashlib import _hash
|
||||
|
||||
_HashType: TypeAlias = _hash
|
||||
|
||||
# TODO use email.message.Message once stubs exist
|
||||
_Message: TypeAlias = Any
|
||||
|
||||
_Provider: TypeAlias = Any # TODO replace this with boto.provider.Provider once stubs exist
|
||||
_LockType: TypeAlias = Any # TODO replace this with _thread.LockType once stubs exist
|
||||
|
||||
@@ -83,7 +61,7 @@ def fetch_file(
|
||||
class ShellCommand:
|
||||
exit_code: int
|
||||
command: subprocess._CMD
|
||||
log_fp: _StringIO
|
||||
log_fp: io.StringIO
|
||||
wait: bool
|
||||
fail_fast: bool
|
||||
def __init__(
|
||||
@@ -121,9 +99,9 @@ class LRUCache(dict[_KT, _VT]):
|
||||
_str: TypeAlias = str
|
||||
|
||||
class Password:
|
||||
hashfunc: Callable[[bytes], _HashType]
|
||||
hashfunc: Callable[[bytes], _Hash]
|
||||
str: _str | None
|
||||
def __init__(self, str: _str | None = ..., hashfunc: Callable[[bytes], _HashType] | None = ...) -> None: ...
|
||||
def __init__(self, str: _str | None = ..., hashfunc: Callable[[bytes], _Hash] | None = ...) -> None: ...
|
||||
def set(self, value: bytes | _str) -> None: ...
|
||||
def __eq__(self, other: _str | bytes | None) -> bool: ... # type: ignore[override]
|
||||
def __len__(self) -> int: ...
|
||||
@@ -133,7 +111,7 @@ def notify(
|
||||
body: str | None = ...,
|
||||
html_body: Sequence[str] | str | None = ...,
|
||||
to_string: str | None = ...,
|
||||
attachments: Iterable[_Message] | None = ...,
|
||||
attachments: Iterable[Message] | None = ...,
|
||||
append_instance_id: bool = ...,
|
||||
) -> None: ...
|
||||
def get_utf8_value(value: str) -> bytes: ...
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import sys
|
||||
from builtins import dict as _dict # alias to avoid conflicts with attribute name
|
||||
from collections.abc import Callable, Iterator
|
||||
from typing import Any, NamedTuple, Pattern, TypeVar
|
||||
from contextlib import _GeneratorContextManager
|
||||
from inspect import getfullargspec as getfullargspec, iscoroutinefunction as iscoroutinefunction
|
||||
from typing import Any, Pattern, TypeVar
|
||||
from typing_extensions import ParamSpec
|
||||
|
||||
_C = TypeVar("_C", bound=Callable[..., Any])
|
||||
@@ -11,25 +12,6 @@ _P = ParamSpec("_P")
|
||||
|
||||
def get_init(cls: type) -> None: ...
|
||||
|
||||
if sys.version_info >= (3,):
|
||||
from inspect import getfullargspec as getfullargspec, iscoroutinefunction as iscoroutinefunction
|
||||
else:
|
||||
class FullArgSpec(NamedTuple):
|
||||
args: list[str]
|
||||
varargs: str | None
|
||||
varkw: str | None
|
||||
defaults: tuple[Any, ...]
|
||||
kwonlyargs: list[str]
|
||||
kwonlydefaults: dict[str, Any]
|
||||
annotations: dict[str, Any]
|
||||
def iscoroutinefunction(f: Callable[..., Any]) -> bool: ...
|
||||
def getfullargspec(func: Any) -> FullArgSpec: ...
|
||||
|
||||
if sys.version_info >= (3, 2):
|
||||
from contextlib import _GeneratorContextManager
|
||||
else:
|
||||
from contextlib import GeneratorContextManager as _GeneratorContextManager
|
||||
|
||||
DEF: Pattern[str]
|
||||
|
||||
class FunctionMaker:
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
import sys
|
||||
from _typeshed import Self
|
||||
from collections.abc import Iterator, Sequence
|
||||
from configparser import ConfigParser
|
||||
from typing import Any
|
||||
|
||||
if sys.version_info >= (3, 0):
|
||||
from configparser import ConfigParser
|
||||
else:
|
||||
from ConfigParser import ConfigParser
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from re import Pattern
|
||||
else:
|
||||
|
||||
@@ -1,20 +1,10 @@
|
||||
import sys
|
||||
from html.parser import HTMLParser as HTMLParser
|
||||
from io import StringIO as StringIO
|
||||
|
||||
if sys.version_info >= (3, 0):
|
||||
unicode = str
|
||||
unichr = chr
|
||||
basestring = str
|
||||
interactive_prompt = input
|
||||
from html.parser import HTMLParser as HTMLParser
|
||||
from io import StringIO as StringIO
|
||||
else:
|
||||
unicode = unicode
|
||||
unichr = unichr
|
||||
basestring = basestring
|
||||
interactive_prompt = raw_input # noqa: F821 # exists as a builtin in Python 2, but not in Python 3
|
||||
from StringIO import StringIO as StringIO
|
||||
|
||||
from HTMLParser import HTMLParser as HTMLParser
|
||||
unicode = str
|
||||
unichr = chr
|
||||
basestring = str
|
||||
interactive_prompt = input
|
||||
|
||||
def coerce_string(value): ...
|
||||
def is_string(value): ...
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import abc
|
||||
import sys
|
||||
from _typeshed import Self
|
||||
from typing import Any, Callable, Generic, ItemsView, KeysView, Mapping, TypeVar, ValuesView
|
||||
|
||||
@@ -15,16 +14,9 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta):
|
||||
# Mypy plugin hook for 'pop' expects that 'default' has a type variable type.
|
||||
def pop(self, k: NoReturn, default: _T = ...) -> object: ... # type: ignore
|
||||
def update(self: Self, __m: Self) -> None: ...
|
||||
if sys.version_info >= (3, 0):
|
||||
def items(self) -> ItemsView[str, object]: ...
|
||||
def keys(self) -> KeysView[str]: ...
|
||||
def values(self) -> ValuesView[object]: ...
|
||||
else:
|
||||
def has_key(self, k: str) -> bool: ...
|
||||
def viewitems(self) -> ItemsView[str, object]: ...
|
||||
def viewkeys(self) -> KeysView[str]: ...
|
||||
def viewvalues(self) -> ValuesView[object]: ...
|
||||
|
||||
def items(self) -> ItemsView[str, object]: ...
|
||||
def keys(self) -> KeysView[str]: ...
|
||||
def values(self) -> ValuesView[object]: ...
|
||||
def __delitem__(self, k: NoReturn) -> None: ...
|
||||
|
||||
def TypedDict(typename: str, fields: dict[str, type[Any]], total: bool = ...) -> type[dict[str, Any]]: ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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): ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
import sys
|
||||
from collections.abc import MutableMapping
|
||||
from http.cookiejar import CookieJar
|
||||
from typing import Any
|
||||
|
||||
if sys.version_info >= (3, 0):
|
||||
from http.cookiejar import CookieJar
|
||||
else:
|
||||
from cookielib import CookieJar
|
||||
|
||||
class MockRequest:
|
||||
type: Any
|
||||
def __init__(self, request) -> None: ...
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import ssl
|
||||
import sys
|
||||
from builtins import ConnectionError as ConnectionError
|
||||
from collections.abc import Iterable
|
||||
from http.client import HTTPConnection as _HTTPConnection, HTTPException as HTTPException
|
||||
from typing import IO, Any
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
@@ -8,14 +9,6 @@ from . import exceptions, util
|
||||
from .packages import ssl_match_hostname
|
||||
from .util import ssl_
|
||||
|
||||
if sys.version_info >= (3, 0):
|
||||
from builtins import ConnectionError as ConnectionError
|
||||
from http.client import HTTPConnection as _HTTPConnection, HTTPException as HTTPException
|
||||
else:
|
||||
from httplib import HTTPConnection as _HTTPConnection, HTTPException as HTTPException
|
||||
|
||||
class ConnectionError(Exception): ...
|
||||
|
||||
_TYPE_BODY: TypeAlias = bytes | IO[Any] | Iterable[bytes] | str
|
||||
|
||||
class DummyConnection: ...
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
import sys
|
||||
from _typeshed import ReadableBuffer
|
||||
from hashlib import _Hash
|
||||
from typing_extensions import SupportsIndex, final
|
||||
|
||||
if sys.version_info >= (3, 0):
|
||||
from hashlib import _Hash
|
||||
else:
|
||||
from hashlib import _hash as _Hash
|
||||
|
||||
VERSION: str
|
||||
XXHASH_VERSION: str
|
||||
|
||||
|
||||
Reference in New Issue
Block a user