@@ -1659,7 +1659,7 @@ def visit_import_from(self, imp: ImportFrom) -> None:
1659
1659
else :
1660
1660
# Missing module.
1661
1661
missing_name = import_id + '.' + id
1662
- self .add_unknown_symbol (imported_id , imp , target_name = missing_name )
1662
+ self .add_unknown_imported_symbol (imported_id , imp , target_name = missing_name )
1663
1663
1664
1664
def report_missing_module_attribute (self , import_id : str , source_id : str , imported_id : str ,
1665
1665
context : Node ) -> None :
@@ -1674,7 +1674,7 @@ def report_missing_module_attribute(self, import_id: str, source_id: str, import
1674
1674
if extra :
1675
1675
message += " {}" .format (extra )
1676
1676
self .fail (message , context )
1677
- self .add_unknown_symbol (imported_id , context )
1677
+ self .add_unknown_imported_symbol (imported_id , context )
1678
1678
1679
1679
if import_id == 'typing' :
1680
1680
# The user probably has a missing definition in a test fixture. Let's verify.
@@ -4045,7 +4045,7 @@ def add_module_symbol(self, id: str, as_id: str, module_public: bool,
4045
4045
module_public = module_public ,
4046
4046
module_hidden = module_hidden )
4047
4047
else :
4048
- self .add_unknown_symbol (as_id , context , target_name = id )
4048
+ self .add_unknown_imported_symbol (as_id , context , target_name = id )
4049
4049
4050
4050
def add_local (self , node : Union [Var , FuncDef , OverloadedFuncDef ], context : Context ) -> None :
4051
4051
"""Add local variable or function."""
@@ -4062,9 +4062,15 @@ def add_imported_symbol(self, name: str, node: SymbolTableNode, context: Context
4062
4062
module_hidden = module_hidden )
4063
4063
self .add_symbol_table_node (name , symbol , context )
4064
4064
4065
- def add_unknown_symbol (self , name : str , context : Context ,
4066
- target_name : Optional [str ] = None ) -> None :
4067
- """Add symbol that we don't know what it points to (due to error, for example)."""
4065
+ def add_unknown_imported_symbol (self , name : str , context : Context ,
4066
+ target_name : Optional [str ] = None ) -> None :
4067
+ """Add symbol that we don't know what it points to because resolving an import failed.
4068
+
4069
+ This can happen if a module is missing, or it is present, but doesn't have
4070
+ the imported attribute. The `target_name` is the name of symbol in the namespace
4071
+ it is imported from. For example, for 'from mod import x as y' the target_name is
4072
+ 'mod.x'. This is currently used only to track logical dependencies.
4073
+ """
4068
4074
existing = self .current_symbol_table ().get (name )
4069
4075
if existing and isinstance (existing .node , Var ) and existing .node .is_suppressed_import :
4070
4076
# This missing import was already added -- nothing to do here.
0 commit comments