From ea368c72696afba1eb4c12653123edd764c800bf Mon Sep 17 00:00:00 2001 From: Rebecca Chen Date: Fri, 8 Nov 2024 13:05:56 -0800 Subject: [PATCH] Type __call__ on builtins._NotImplementedType as None. (#12984) Currently, this is intentionally incorrectly typed in order to produce a better mypy error message. But pyright (and presumably other type checkers) end up just treating instances of _NotImplementedType as callable. With this change, the mypy error message gets a little worse, but other type checkers can understand that instances of _NotImplementedType aren't callable, which I think is an improvement. --- stdlib/builtins.pyi | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index f4e0e0ffe..14ad7ebaf 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -1284,9 +1284,7 @@ class property: @final class _NotImplementedType(Any): - # A little weird, but typing the __call__ as NotImplemented makes the error message - # for NotImplemented() much better - __call__: NotImplemented # type: ignore[valid-type] # pyright: ignore[reportInvalidTypeForm] + __call__: None NotImplemented: _NotImplementedType