From c68408f7ceffcc1cf7613277394fec1ac117fbbc Mon Sep 17 00:00:00 2001 From: Stephen Morton Date: Thu, 12 Dec 2024 16:07:12 -0800 Subject: [PATCH 1/3] a few more allowlist entries moved to don't fix --- stdlib/@tests/stubtest_allowlists/common.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/common.txt b/stdlib/@tests/stubtest_allowlists/common.txt index 9000131fde9c..d6215057db26 100644 --- a/stdlib/@tests/stubtest_allowlists/common.txt +++ b/stdlib/@tests/stubtest_allowlists/common.txt @@ -17,10 +17,6 @@ ctypes.CDLL._FuncPtr # None at class level but initialized in __init__ to this ctypes.memmove # CFunctionType ctypes.memset # CFunctionType fractions.Fraction.__new__ # overload is too complicated for stubtest to resolve -functools.cached_property.__set__ # Stub is a white lie; see comments in the stub -hmac.new # Stub is a white lie; see comments in the stub -http.HTTPStatus.description # set in __new__ -http.HTTPStatus.phrase # set in __new__ http.client.HTTPConnection.response_class # the actual type at runtime is abc.ABCMeta importlib.abc.Loader.exec_module # See Lib/importlib/_abc.py. Might be defined for backwards compatibility importlib.abc.MetaPathFinder.find_spec # Not defined on the actual class, but expected to exist. @@ -362,7 +358,11 @@ email.policy.EmailPolicy.message_factory # "type" at runtime, but protocol in s enum.auto.__or__ # enum.auto is magic, see comments enum.auto.__and__ # enum.auto is magic, see comments enum.auto.__xor__ # enum.auto is magic, see comments +functools.cached_property.__set__ # doesn't exist, but cached_property is settable by another mechanism _?hashlib.scrypt # Raises TypeError if salt, n, r or p are None +hmac.new # Raises TypeError if optional argument digestmod is not provided +http.HTTPStatus.description # set in __new__; work-around for enum wierdness +http.HTTPStatus.phrase # set in __new__; work-around for enum wierdness imaplib.IMAP4_SSL.ssl # Depends on the existence and flags of SSL # runtime is *args, **kwargs due to a wrapper; we have more accurate signatures in the stubs From 143e51dbcffdc6b8638f69ef2a42163b69f02223 Mon Sep 17 00:00:00 2001 From: Stephen Morton Date: Fri, 13 Dec 2024 12:50:46 -0800 Subject: [PATCH 2/3] move optparse.Values.__getattr__ to don't fix --- stdlib/@tests/stubtest_allowlists/common.txt | 2 +- stdlib/optparse.pyi | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/stdlib/@tests/stubtest_allowlists/common.txt b/stdlib/@tests/stubtest_allowlists/common.txt index d6215057db26..0aceede02021 100644 --- a/stdlib/@tests/stubtest_allowlists/common.txt +++ b/stdlib/@tests/stubtest_allowlists/common.txt @@ -22,7 +22,6 @@ importlib.abc.Loader.exec_module # See Lib/importlib/_abc.py. Might be defined importlib.abc.MetaPathFinder.find_spec # Not defined on the actual class, but expected to exist. importlib.abc.PathEntryFinder.find_spec # Not defined on the actual class, but expected to exist. numbers.Number.__hash__ # typeshed marks this as abstract but code just sets this as None -optparse.Values.__getattr__ # Some attributes are set in __init__ using setattr select.poll # Depends on configuration selectors.DevpollSelector # Depends on configuration shutil.rmtree # stubtest doesn't like that we have this as an instance of a callback protocol instead of a function @@ -438,6 +437,7 @@ multiprocessing.synchronize.Condition.release multiprocessing.synchronize.SemLock.acquire multiprocessing.synchronize.SemLock.release +optparse.Values.__getattr__ # Some attributes are set in __init__ using setattr os._wrap_close.read # Methods that come from __getattr__() at runtime os._wrap_close.readable # Methods that come from __getattr__() at runtime os._wrap_close.readline # Methods that come from __getattr__() at runtime diff --git a/stdlib/optparse.pyi b/stdlib/optparse.pyi index d6db7a06f291..6096ac4a2a1d 100644 --- a/stdlib/optparse.pyi +++ b/stdlib/optparse.pyi @@ -182,6 +182,8 @@ class Values: def ensure_value(self, attr: str, value): ... def read_file(self, filename: str, mode: str = "careful") -> None: ... def read_module(self, modname: str, mode: str = "careful") -> None: ... + # __getattr__ doesn't exist, but anything passed as a default to __init__ + # is set on the instance. def __getattr__(self, name: str): ... def __setattr__(self, name: str, value, /) -> None: ... def __eq__(self, other: object) -> bool: ... From 402e43bfad4fb8b337074646d33b0dece16da1ce Mon Sep 17 00:00:00 2001 From: Stephen Morton Date: Fri, 13 Dec 2024 12:57:37 -0800 Subject: [PATCH 3/3] tkinter.Misc.after to don't fix --- stdlib/@tests/stubtest_allowlists/common.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stdlib/@tests/stubtest_allowlists/common.txt b/stdlib/@tests/stubtest_allowlists/common.txt index 0aceede02021..6c3e3086f9e4 100644 --- a/stdlib/@tests/stubtest_allowlists/common.txt +++ b/stdlib/@tests/stubtest_allowlists/common.txt @@ -33,7 +33,6 @@ tarfile.TarFile.errors # errors is initialized for some reason as None even tho tkinter.simpledialog.[A-Z_]+ tkinter.simpledialog.TclVersion tkinter.simpledialog.TkVersion -tkinter.Misc.after # we intentionally don't allow everything that "works" at runtime tkinter.Text.count # stubtest somehow thinks that index1 parameter has a default value, but it doesn't in any of the overloads unittest.mock.patch # It's a complicated overload and I haven't been able to figure out why stubtest doesn't like it weakref.WeakKeyDictionary.update @@ -459,6 +458,8 @@ threading.Condition.release # Condition functions are exported in __init__ # Marking it as a function will make it impossible for users to use the Lock type as an annotation. threading.RLock +tkinter.Misc.after # we intentionally don't allow everything that "works" at runtime + # Methods that come from __getattr__() at runtime tkinter.Tk.adderrorinfo tkinter.Tk.call