Skip to content

Assert original type exists during function redefinition #13509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down