From 360e3088ef96a4ae05b13e6369456667218f131e Mon Sep 17 00:00:00 2001 From: Avasam Date: Sun, 6 Oct 2024 16:46:09 -0400 Subject: [PATCH 1/2] Add __code__ to types.MethodType --- stdlib/types.pyi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stdlib/types.pyi b/stdlib/types.pyi index 0f6592a9883e..0c5a43617040 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -424,6 +424,8 @@ class MethodType: @property def __closure__(self) -> tuple[CellType, ...] | None: ... # inherited from the added function @property + def __code__(self) -> CodeType: ... # inherited from the added function + @property def __defaults__(self) -> tuple[Any, ...] | None: ... # inherited from the added function @property def __func__(self) -> Callable[..., Any]: ... From 53c1c0c8f95eac19604b78ba8fa1cb1ba3af1b20 Mon Sep 17 00:00:00 2001 From: Avasam Date: Sun, 6 Oct 2024 16:52:16 -0400 Subject: [PATCH 2/2] Add to allowlist --- stdlib/@tests/stubtest_allowlists/common.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/@tests/stubtest_allowlists/common.txt b/stdlib/@tests/stubtest_allowlists/common.txt index 877307b96869..55dbdbae4b2e 100644 --- a/stdlib/@tests/stubtest_allowlists/common.txt +++ b/stdlib/@tests/stubtest_allowlists/common.txt @@ -494,6 +494,7 @@ typing(_extensions)?\.TextIO\.newlines typing(_extensions)?\.(Async)?ContextManager types.MethodType.__closure__ # read-only but not actually a property; stubtest thinks it doesn't exist. +types.MethodType.__code__ # read-only but not actually a property; stubtest thinks it doesn't exist. types.MethodType.__defaults__ # read-only but not actually a property; stubtest thinks it doesn't exist. types.ModuleType.__dict__ # read-only but not actually a property; stubtest thinks it's a mutable attribute. types.ModuleType.__getattr__ # this doesn't exist at runtime