@@ -53,6 +53,7 @@ def __init__(
5353 lines_collection : LinesCollection | None = None ,
5454 modules_collection : ModulesCollection | None = None ,
5555 allow_inspection : bool = True ,
56+ store_source : bool = True ,
5657 ) -> None :
5758 """Initialize the loader.
5859
@@ -71,6 +72,7 @@ def __init__(
7172 self .lines_collection : LinesCollection = lines_collection or LinesCollection ()
7273 self .modules_collection : ModulesCollection = modules_collection or ModulesCollection ()
7374 self .allow_inspection : bool = allow_inspection
75+ self .store_source : bool = store_source
7476 self .finder : ModuleFinder = ModuleFinder (search_paths )
7577 self ._time_stats : dict = {
7678 "time_spent_visiting" : 0 ,
@@ -456,7 +458,8 @@ def _create_module(self, module_name: str, module_path: Path | list[Path]) -> Mo
456458 )
457459
458460 def _visit_module (self , code : str , module_name : str , module_path : Path , parent : Module | None = None ) -> Module :
459- self .lines_collection [module_path ] = code .splitlines (keepends = False )
461+ if self .store_source :
462+ self .lines_collection [module_path ] = code .splitlines (keepends = False )
460463 start = datetime .now (tz = timezone .utc )
461464 module = visit (
462465 module_name ,
0 commit comments