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.
This commit is contained in:
Rebecca Chen
2024-11-08 13:05:56 -08:00
committed by GitHub
parent 76537eb81b
commit ea368c7269

View File

@@ -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