Skip to content

Commit 448e657

Browse files
authored
Assert original type exists during function redefinition (#13509)
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
1 parent 55d757e commit 448e657

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

mypy/checker.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -959,11 +959,7 @@ def _visit_func_def(self, defn: FuncDef) -> None:
959959
# Function definition overrides a variable initialized via assignment or a
960960
# decorated function.
961961
orig_type = defn.original_def.type
962-
if orig_type is None:
963-
# XXX This can be None, as happens in
964-
# test_testcheck_TypeCheckSuite.testRedefinedFunctionInTryWithElse
965-
self.msg.note("Internal mypy error checking function redefinition", defn)
966-
return
962+
assert orig_type is not None, f"Error checking function redefinition {defn}"
967963
if isinstance(orig_type, PartialType):
968964
if orig_type.type is None:
969965
# Ah this is a partial type. Give it the type of the function.

0 commit comments

Comments
 (0)