@@ -1762,8 +1762,15 @@ def visit_import_from(self, imp: ImportFrom) -> None:
1762
1762
# Target module exists but the imported name is missing or hidden.
1763
1763
self .report_missing_module_attribute (module_id , id , imported_id , imp )
1764
1764
else :
1765
+ module_public = (
1766
+ not self .is_stub_file
1767
+ and self .options .implicit_reexport
1768
+ or as_id is not None
1769
+ )
1765
1770
# Import of a missing (sub)module.
1766
- self .add_unknown_imported_symbol (imported_id , imp , target_name = fullname )
1771
+ self .add_unknown_imported_symbol (
1772
+ imported_id , imp , target_name = fullname , module_public = module_public
1773
+ )
1767
1774
1768
1775
def process_imported_symbol (self ,
1769
1776
node : SymbolTableNode ,
@@ -4415,7 +4422,9 @@ def add_module_symbol(self,
4415
4422
module_public = module_public ,
4416
4423
module_hidden = module_hidden )
4417
4424
else :
4418
- self .add_unknown_imported_symbol (as_id , context , target_name = id )
4425
+ self .add_unknown_imported_symbol (
4426
+ as_id , context , target_name = id , module_public = module_public
4427
+ )
4419
4428
4420
4429
def add_local (self , node : Union [Var , FuncDef , OverloadedFuncDef ], context : Context ) -> None :
4421
4430
"""Add local variable or function."""
@@ -4440,7 +4449,8 @@ def add_imported_symbol(self,
4440
4449
def add_unknown_imported_symbol (self ,
4441
4450
name : str ,
4442
4451
context : Context ,
4443
- target_name : Optional [str ] = None ) -> None :
4452
+ target_name : Optional [str ] = None ,
4453
+ module_public : bool = True ) -> None :
4444
4454
"""Add symbol that we don't know what it points to because resolving an import failed.
4445
4455
4446
4456
This can happen if a module is missing, or it is present, but doesn't have
@@ -4468,7 +4478,7 @@ def add_unknown_imported_symbol(self,
4468
4478
any_type = AnyType (TypeOfAny .from_unimported_type , missing_import_name = var ._fullname )
4469
4479
var .type = any_type
4470
4480
var .is_suppressed_import = True
4471
- self .add_symbol (name , var , context )
4481
+ self .add_symbol (name , var , context , module_public = module_public )
4472
4482
4473
4483
#
4474
4484
# Other helpers
0 commit comments