Skip to content

Commit 652bee0

Browse files
committed
Emit error on 'raise NotImplemented'
1 parent 94c49a8 commit 652bee0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

mypy/checker.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4746,6 +4746,14 @@ def type_check_raise(self, e: Expression, s: RaiseStmt, optional: bool = False)
47464746
# https://github.com/python/mypy/issues/11089
47474747
self.expr_checker.check_call(typ, [], [], e)
47484748

4749+
if isinstance(typ, Instance) and typ.type.fullname == "builtins._NotImplementedType":
4750+
self.fail(
4751+
message_registry.INVALID_EXCEPTION.with_additional_msg(
4752+
'; did you mean "NotImplementedError"?'
4753+
),
4754+
s,
4755+
)
4756+
47494757
def visit_try_stmt(self, s: TryStmt) -> None:
47504758
"""Type check a try statement."""
47514759
# Our enclosing frame will get the result if the try/except falls through.

0 commit comments

Comments
 (0)