Skip to content

Commit

Permalink
Type __call__ on builtins._NotImplementedType as None. (#12984)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rchen152 authored Nov 8, 2024
1 parent 76537eb commit ea368c7
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ea368c7

Please sign in to comment.