From 4c9e096a33908d120d6ad8e630a640b35719bfa7 Mon Sep 17 00:00:00 2001 From: layday Date: Fri, 5 Apr 2024 21:08:00 +0300 Subject: [PATCH 1/3] Add `get_verified_chain` and `get_unverified_chain` for Python 3.13 Added in https://github.com/python/cpython/pull/109113. --- stdlib/ssl.pyi | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index b2263df1337d..845138086de0 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -2,7 +2,7 @@ import enum import socket import sys from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer -from collections.abc import Callable, Iterable +from collections.abc import Callable, Iterable, Sequence from typing import Any, Literal, NamedTuple, TypedDict, final, overload from typing_extensions import Never, Self, TypeAlias @@ -366,6 +366,9 @@ class SSLSocket(socket.socket): def recvmsg(self, *args: Never, **kwargs: Never) -> Never: ... # type: ignore[override] def recvmsg_into(self, *args: Never, **kwargs: Never) -> Never: ... # type: ignore[override] def sendmsg(self, *args: Never, **kwargs: Never) -> Never: ... # type: ignore[override] + if sys.version_info >= (3, 13): + def get_verified_chain(self) -> Sequence[bytes]: ... + def get_unverified_chain(self) -> Sequence[bytes]: ... class TLSVersion(enum.IntEnum): MINIMUM_SUPPORTED: int @@ -476,6 +479,9 @@ class SSLObject: def version(self) -> str | None: ... def get_channel_binding(self, cb_type: str = "tls-unique") -> bytes | None: ... def verify_client_post_handshake(self) -> None: ... + if sys.version_info >= (3, 13): + def get_verified_chain(self) -> Sequence[bytes]: ... + def get_unverified_chain(self) -> Sequence[bytes]: ... @final class MemoryBIO: From 0afb79f41a7a2556b48045a05e20a8c9ade3fd9f Mon Sep 17 00:00:00 2001 From: layday Date: Fri, 5 Apr 2024 21:20:13 +0300 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Alex Waygood --- stdlib/ssl.pyi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index 845138086de0..a5f097b9a54d 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -367,8 +367,8 @@ class SSLSocket(socket.socket): def recvmsg_into(self, *args: Never, **kwargs: Never) -> Never: ... # type: ignore[override] def sendmsg(self, *args: Never, **kwargs: Never) -> Never: ... # type: ignore[override] if sys.version_info >= (3, 13): - def get_verified_chain(self) -> Sequence[bytes]: ... - def get_unverified_chain(self) -> Sequence[bytes]: ... + def get_verified_chain(self) -> list[bytes]: ... + def get_unverified_chain(self) -> list[bytes]: ... class TLSVersion(enum.IntEnum): MINIMUM_SUPPORTED: int @@ -480,8 +480,8 @@ class SSLObject: def get_channel_binding(self, cb_type: str = "tls-unique") -> bytes | None: ... def verify_client_post_handshake(self) -> None: ... if sys.version_info >= (3, 13): - def get_verified_chain(self) -> Sequence[bytes]: ... - def get_unverified_chain(self) -> Sequence[bytes]: ... + def get_verified_chain(self) -> list[bytes]: ... + def get_unverified_chain(self) -> list[bytes]: ... @final class MemoryBIO: From 3fdbf7fa03daf94db1ae852d24ee36899e711c99 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 5 Apr 2024 18:21:49 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/ssl.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index a5f097b9a54d..15d86372531a 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -2,7 +2,7 @@ import enum import socket import sys from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer -from collections.abc import Callable, Iterable, Sequence +from collections.abc import Callable, Iterable from typing import Any, Literal, NamedTuple, TypedDict, final, overload from typing_extensions import Never, Self, TypeAlias