Skip to content

Raise custom error when builtin symbol is missing #2062

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
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
11 changes: 10 additions & 1 deletion mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2236,7 +2236,16 @@ def lookup_qualified(self, name: str) -> SymbolTableNode:
n = self.modules[parts[0]]
for i in range(1, len(parts) - 1):
n = cast(MypyFile, n.names.get(parts[i], None).node)
return n.names[parts[-1]]
last = parts[-1]
if last in n.names:
return n.names[last]
elif len(parts) == 2 and parts[0] == 'builtins':
raise KeyError("Could not find builtin symbol '{}'. (Are you running a "
"test case? If so, make sure to include a fixture that "
"defines this symbol.)".format(last))
else:
msg = "Failed qualified lookup: '{}' (fullname = '{}')."
raise KeyError(msg.format(last, name))

def enter_partial_types(self) -> None:
"""Push a new scope for collecting partial types."""
Expand Down