mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 04:54:47 +08:00
Fixed missing methods, wrong names and types (#3560)
Changes: * Added the missing methods `selected_alpn_protocol()` and `version()` to `SSLObject` * Fixed the naming of the `shared_ciphers()` method in `SSLSocket` and `SSLObject` (was missing the last "s") * Fixed return type of `cipher()` (it's documented to return `None` if no connection has been established) * Fixed second argument in cipher and shared_ciphers The TLS version is a string, like "TLSv1.2". * Added explicit overloads for getpeercert() Its return type can be determined statically based on the `binary_form` argument.
This commit is contained in:
committed by
Sebastian Rittau
parent
21a9e69612
commit
83f9d833fb
@@ -2,12 +2,18 @@
|
||||
|
||||
from typing import (
|
||||
Any, Callable, ClassVar, Dict, List, NamedTuple, Optional, Set, Text, Type, Tuple, Union,
|
||||
overload
|
||||
)
|
||||
import enum
|
||||
import socket
|
||||
import sys
|
||||
import os
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from typing import Literal
|
||||
else:
|
||||
from typing_extensions import Literal
|
||||
|
||||
_PCTRTT = Tuple[Tuple[str, str], ...]
|
||||
_PCTRTTT = Tuple[_PCTRTT, ...]
|
||||
_PeerCertRetDictType = Dict[str, Union[str, _PCTRTTT, _PCTRTT]]
|
||||
@@ -200,10 +206,15 @@ class SSLSocket(socket.socket):
|
||||
buffer: Optional[bytearray] = ...) -> bytes: ...
|
||||
def write(self, buf: bytes) -> int: ...
|
||||
def do_handshake(self) -> None: ...
|
||||
def getpeercert(self, binary_form: bool = ...) -> _PeerCertRetType: ...
|
||||
def cipher(self) -> Tuple[str, int, int]: ...
|
||||
@overload
|
||||
def getpeercert(self, binary_form: Literal[False] = ...) -> Optional[_PeerCertRetDictType]: ...
|
||||
@overload
|
||||
def getpeercert(self, binary_form: Literal[True]) -> Optional[bytes]: ...
|
||||
@overload
|
||||
def getpeercert(self, binary_form: bool) -> _PeerCertRetType: ...
|
||||
def cipher(self) -> Optional[Tuple[str, str, int]]: ...
|
||||
if sys.version_info >= (3, 5):
|
||||
def shared_cipher(self) -> Optional[List[Tuple[str, int, int]]]: ...
|
||||
def shared_ciphers(self) -> Optional[List[Tuple[str, str, int]]]: ...
|
||||
def compression(self) -> Optional[str]: ...
|
||||
def get_channel_binding(self, cb_type: str = ...) -> Optional[bytes]: ...
|
||||
def selected_alpn_protocol(self) -> Optional[str]: ...
|
||||
@@ -284,14 +295,21 @@ if sys.version_info >= (3, 5):
|
||||
def read(self, len: int = ...,
|
||||
buffer: Optional[bytearray] = ...) -> bytes: ...
|
||||
def write(self, buf: bytes) -> int: ...
|
||||
def getpeercert(self, binary_form: bool = ...) -> _PeerCertRetType: ...
|
||||
@overload
|
||||
def getpeercert(self, binary_form: Literal[False] = ...) -> Optional[_PeerCertRetDictType]: ...
|
||||
@overload
|
||||
def getpeercert(self, binary_form: Literal[True]) -> Optional[bytes]: ...
|
||||
@overload
|
||||
def getpeercert(self, binary_form: bool) -> _PeerCertRetType: ...
|
||||
def selected_alpn_protocol(self) -> Optional[str]: ...
|
||||
def selected_npn_protocol(self) -> Optional[str]: ...
|
||||
def cipher(self) -> Tuple[str, int, int]: ...
|
||||
def shared_cipher(self) -> Optional[List[Tuple[str, int, int]]]: ...
|
||||
def cipher(self) -> Optional[Tuple[str, str, int]]: ...
|
||||
def shared_ciphers(self) -> Optional[List[Tuple[str, str, int]]]: ...
|
||||
def compression(self) -> Optional[str]: ...
|
||||
def pending(self) -> int: ...
|
||||
def do_handshake(self) -> None: ...
|
||||
def unwrap(self) -> None: ...
|
||||
def version(self) -> Optional[str]: ...
|
||||
def get_channel_binding(self, cb_type: str = ...) -> Optional[bytes]: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def verify_client_post_handshake(self) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user