Skip to content

Don't use ModuleType.__getattr__ if we know module symbols #11597

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
Nov 23, 2021
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
5 changes: 4 additions & 1 deletion mypy/checkmember.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,10 @@ def analyze_member_var_access(name: str,
elif isinstance(v, FuncDef):
assert False, "Did not expect a function"
elif (not v and name not in ['__getattr__', '__setattr__', '__getattribute__'] and
not mx.is_operator):
not mx.is_operator and mx.module_symbol_table is None):
# Above we skip ModuleType.__getattr__ etc. if we have a
# module symbol table, since the symbol table allows precise
# checking.
if not mx.is_lvalue:
for method_name in ('__getattribute__', '__getattr__'):
method = info.get_method(method_name)
Expand Down