File tree 2 files changed +23
-1
lines changed
2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -1906,7 +1906,11 @@ def process_imported_symbol(self,
1906
1906
fullname : str ,
1907
1907
module_public : bool ,
1908
1908
context : ImportBase ) -> None :
1909
- module_hidden = not module_public and fullname not in self .modules
1909
+ module_hidden = not module_public and not (
1910
+ # `from package import module` should work regardless of whether package
1911
+ # re-exports module
1912
+ isinstance (node .node , MypyFile ) and fullname in self .modules
1913
+ )
1910
1914
1911
1915
if isinstance (node .node , PlaceholderNode ):
1912
1916
if self .final_iteration :
Original file line number Diff line number Diff line change @@ -1910,6 +1910,24 @@ class C:
1910
1910
1911
1911
[builtins fixtures/module.pyi]
1912
1912
1913
+ [case testReExportChildStubs3]
1914
+ from util import mod
1915
+ reveal_type(mod) # N: Revealed type is "def () -> package.mod.mod"
1916
+
1917
+ from util import internal_detail # E: Module "util" has no attribute "internal_detail"
1918
+
1919
+ [file package/__init__.pyi]
1920
+ from .mod import mod as mod
1921
+
1922
+ [file package/mod.pyi]
1923
+ class mod: ...
1924
+
1925
+ [file util.pyi]
1926
+ from package import mod as mod
1927
+ # stubs require explicit re-export
1928
+ from package import mod as internal_detail
1929
+ [builtins fixtures/module.pyi]
1930
+
1913
1931
[case testNoReExportChildStubs]
1914
1932
import mod
1915
1933
from mod import C, D # E: Module "mod" has no attribute "C"
You can’t perform that action at this time.
0 commit comments