From 4d99b33f845bc594cc82d2e53124da02876e7aef Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 21 Feb 2023 00:35:38 +0000 Subject: [PATCH] Fix an unnecessary allowlist entry in `ssl.pyi` (#9776) --- stdlib/ssl.pyi | 5 ++++- tests/stubtest_allowlists/py3_common.txt | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index bbf8a4c6d..b73573dd5 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -291,11 +291,14 @@ ALERT_DESCRIPTION_UNSUPPORTED_CERTIFICATE: AlertDescription ALERT_DESCRIPTION_UNSUPPORTED_EXTENSION: AlertDescription ALERT_DESCRIPTION_USER_CANCELLED: AlertDescription -class _ASN1Object(NamedTuple): +class _ASN1ObjectBase(NamedTuple): nid: int shortname: str longname: str oid: str + +class _ASN1Object(_ASN1ObjectBase): + def __new__(cls, oid: str) -> Self: ... @classmethod def fromnid(cls, nid: int) -> Self: ... @classmethod diff --git a/tests/stubtest_allowlists/py3_common.txt b/tests/stubtest_allowlists/py3_common.txt index 43545b649..1a61c2295 100644 --- a/tests/stubtest_allowlists/py3_common.txt +++ b/tests/stubtest_allowlists/py3_common.txt @@ -168,8 +168,7 @@ shutil.rmtree # stubtest doesn't like that we have this as an instance of a cal socketserver.BaseServer.fileno # implemented in derived classes socketserver.BaseServer.get_request # implemented in derived classes socketserver.BaseServer.server_bind # implemented in derived classes -ssl.Purpose.__new__ # You cannot override __new__ in NamedTuple and runtime uses namedtuple. -ssl._ASN1Object.__new__ # You cannot override __new__ in NamedTuple and runtime uses namedtuple. +ssl.Purpose.__new__ # the multiple inheritance confuses mypy (sys.get_int_max_str_digits)? # Added in a patch release, backported to all security branches, but has yet to find its way to all GitHub Actions images sys.implementation # Actually SimpleNamespace but then you wouldn't have convenient attributes (sys.set_int_max_str_digits)? # Added in a patch release, backported to all security branches, but has yet to find its way to all GitHub Actions images