Skip to content

Commit 6a67b83

Browse files
committed
Don't crash on the function redefinition example
1 parent 737ccb3 commit 6a67b83

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

mypy/checker.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,8 +604,11 @@ def visit_func_def(self, defn: FuncDef) -> Type:
604604
else:
605605
# Function definition overrides a variable initialized via assignment.
606606
orig_type = defn.original_def.type
607-
# XXX This can be None, as happens in
608-
# test_testcheck_TypeCheckSuite.testRedefinedFunctionInTryWithElse
607+
if orig_type is None:
608+
# XXX This can be None, as happens in
609+
# test_testcheck_TypeCheckSuite.testRedefinedFunctionInTryWithElse
610+
self.msg.note("Internal mypy error checking function redefinition.", defn)
611+
return None
609612
if isinstance(orig_type, PartialType):
610613
if orig_type.type is None:
611614
# Ah this is a partial type. Give it the type of the function.

0 commit comments

Comments
 (0)