From 8a07787f48b4cf3c46fcb9107c5b31388b7b32d2 Mon Sep 17 00:00:00 2001 From: Amy Pircher <8506086+akpircher@users.noreply.github.com> Date: Mon, 23 May 2022 17:06:09 -0700 Subject: [PATCH] Add precise overloads for SSLContext.get_ca_certs (#7933) --- stdlib/@python2/ssl.pyi | 7 ++++++- stdlib/ssl.pyi | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/stdlib/@python2/ssl.pyi b/stdlib/@python2/ssl.pyi index 2c6b32567..edc22ff15 100644 --- a/stdlib/@python2/ssl.pyi +++ b/stdlib/@python2/ssl.pyi @@ -225,7 +225,12 @@ class SSLContext: def load_verify_locations( self, cafile: StrPath | None = ..., capath: StrPath | None = ..., cadata: Text | bytes | None = ... ) -> None: ... - def get_ca_certs(self, binary_form: bool = ...) -> list[_PeerCertRetDictType] | list[bytes]: ... + @overload + def get_ca_certs(self, binary_form: Literal[False] = ...) -> list[_PeerCertRetDictType]: ... + @overload + def get_ca_certs(self, binary_form: Literal[True]) -> list[bytes]: ... + @overload + def get_ca_certs(self, binary_form: bool = ...) -> Any: ... def set_default_verify_paths(self) -> None: ... def set_ciphers(self, __cipherlist: str) -> None: ... def set_alpn_protocols(self, alpn_protocols: Iterable[str]) -> None: ... diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index 8445435fa..9f0420029 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -412,7 +412,12 @@ class SSLContext: def load_verify_locations( self, cafile: StrOrBytesPath | None = ..., capath: StrOrBytesPath | None = ..., cadata: str | bytes | None = ... ) -> None: ... - def get_ca_certs(self, binary_form: bool = ...) -> list[_PeerCertRetDictType] | list[bytes]: ... + @overload + def get_ca_certs(self, binary_form: Literal[False] = ...) -> list[_PeerCertRetDictType]: ... + @overload + def get_ca_certs(self, binary_form: Literal[True]) -> list[bytes]: ... + @overload + def get_ca_certs(self, binary_form: bool = ...) -> Any: ... def get_ciphers(self) -> list[_Cipher]: ... def set_default_verify_paths(self) -> None: ... def set_ciphers(self, __cipherlist: str) -> None: ...