From f4045d5c0d3ba6d03e19d607239dfbaddb3aa449 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Wed, 24 Aug 2022 23:15:41 -0700 Subject: [PATCH] Use hard assert in checker The code involved is really old. The mentioned test case does not trigger any errors. I cannot find any mention of this error message in any non-ancient mypy issues --- mypy/checker.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/mypy/checker.py b/mypy/checker.py index ccf58d8254976..9da5a9ba3745a 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -959,11 +959,7 @@ def _visit_func_def(self, defn: FuncDef) -> None: # Function definition overrides a variable initialized via assignment or a # decorated function. orig_type = defn.original_def.type - if orig_type is None: - # XXX This can be None, as happens in - # test_testcheck_TypeCheckSuite.testRedefinedFunctionInTryWithElse - self.msg.note("Internal mypy error checking function redefinition", defn) - return + assert orig_type is not None, f"Error checking function redefinition {defn}" if isinstance(orig_type, PartialType): if orig_type.type is None: # Ah this is a partial type. Give it the type of the function.