diff --git a/mypy/checker.py b/mypy/checker.py index f3a93d1eeda1..9f8299e6805d 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -5134,13 +5134,10 @@ def type_check_raise(self, e: Expression, s: RaiseStmt, optional: bool = False) # https://github.com/python/mypy/issues/11089 self.expr_checker.check_call(typ, [], [], e) - if ( - isinstance(typ, Instance) - and typ.type.fullname in {"builtins._NotImplementedType", "types.NotImplementedType"} - ) or ( + if (isinstance(typ, Instance) and typ.type.fullname in NOT_IMPLEMENTED_TYPE_NAMES) or ( isinstance(e, CallExpr) and isinstance(e.callee, RefExpr) - and e.callee.fullname in {"builtins.NotImplemented"} + and e.callee.fullname == "builtins.NotImplemented" ): self.fail( message_registry.INVALID_EXCEPTION.with_additional_msg(