@@ -1808,6 +1808,12 @@ def visit_import_from(self, imp: ImportFrom) -> None:
1808
1808
missing_submodule = False
1809
1809
imported_id = as_id or id
1810
1810
1811
+ # Modules imported in a stub file without using 'from Y import X as X' will
1812
+ # not get exported.
1813
+ # When implicit re-exporting is disabled, we have the same behavior as stubs.
1814
+ use_implicit_reexport = not self .is_stub_file and self .options .implicit_reexport
1815
+ module_public = use_implicit_reexport or (as_id is not None and id == as_id )
1816
+
1811
1817
# If the module does not contain a symbol with the name 'id',
1812
1818
# try checking if it's a module instead.
1813
1819
if not node :
@@ -1825,15 +1831,12 @@ def visit_import_from(self, imp: ImportFrom) -> None:
1825
1831
fullname = module_id + '.' + id
1826
1832
gvar = self .create_getattr_var (module .names ['__getattr__' ], imported_id , fullname )
1827
1833
if gvar :
1828
- self .add_symbol (imported_id , gvar , imp )
1834
+ self .add_symbol (
1835
+ imported_id , gvar , imp , module_public = module_public ,
1836
+ module_hidden = not module_public
1837
+ )
1829
1838
continue
1830
1839
1831
- # Modules imported in a stub file without using 'from Y import X as X' will
1832
- # not get exported.
1833
- # When implicit re-exporting is disabled, we have the same behavior as stubs.
1834
- use_implicit_reexport = not self .is_stub_file and self .options .implicit_reexport
1835
- module_public = use_implicit_reexport or (as_id is not None and id == as_id )
1836
-
1837
1840
if node and not node .module_hidden :
1838
1841
self .process_imported_symbol (
1839
1842
node , module_id , id , imported_id , fullname , module_public , context = imp
0 commit comments