@@ -1114,6 +1114,7 @@ def __init__(self,
11141114 caller_state : 'State' = None ,
11151115 caller_line : int = 0 ,
11161116 ancestor_for : 'State' = None ,
1117+ root_source : bool = False ,
11171118 ) -> None :
11181119 assert id or path or source is not None , "Neither id, path nor source given"
11191120 self .manager = manager
@@ -1148,6 +1149,7 @@ def __init__(self,
11481149 # - skip -> don't analyze, make the type Any
11491150 follow_imports = self .options .follow_imports
11501151 if (follow_imports != 'normal'
1152+ and not root_source # Honor top-level modules
11511153 and path .endswith ('.py' ) # Stubs are always normal
11521154 and id != 'builtins' # Builtins is always normal
11531155 and not (caller_state and
@@ -1519,6 +1521,9 @@ def write_cache(self) -> None:
15191521def dispatch (sources : List [BuildSource ], manager : BuildManager ) -> None :
15201522 manager .log ("Mypy version %s" % __version__ )
15211523 graph = load_graph (sources , manager )
1524+ if not graph :
1525+ print ("Nothing to do?!" )
1526+ return
15221527 manager .log ("Loaded graph with %d nodes" % len (graph ))
15231528 if manager .options .dump_graph :
15241529 dump_graph (graph )
@@ -1596,7 +1601,8 @@ def load_graph(sources: List[BuildSource], manager: BuildManager) -> Graph:
15961601 # Seed the graph with the initial root sources.
15971602 for bs in sources :
15981603 try :
1599- st = State (id = bs .module , path = bs .path , source = bs .text , manager = manager )
1604+ st = State (id = bs .module , path = bs .path , source = bs .text , manager = manager ,
1605+ root_source = True )
16001606 except ModuleNotFound :
16011607 continue
16021608 if st .id in graph :
0 commit comments