From d357e21c1d7fb4c8fb97f8bc885790dc0da254f5 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Fri, 6 Dec 2024 10:07:07 -0600 Subject: [PATCH] Change how ModuleLoader receives is_reload information Use on the fly import of reload_manager rather than altering the args --- manimlib/config.py | 8 ++++---- manimlib/reload_manager.py | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/manimlib/config.py b/manimlib/config.py index 87120480..cd6dd4a7 100644 --- a/manimlib/config.py +++ b/manimlib/config.py @@ -215,7 +215,7 @@ def get_indent(line: str): def get_module_with_inserted_embed_line( - file_name: str, scene_name: str, line_marker: str, is_during_reload + file_name: str, scene_name: str, line_marker: str ): """ This is hacky, but convenient. When user includes the argument "-e", it will try @@ -277,7 +277,8 @@ def get_module_with_inserted_embed_line( with open(new_file, 'w') as fp: fp.writelines(new_lines) - module = ModuleLoader.get_module(new_file, is_during_reload) + from manimlib.reload_manager import reload_manager + module = ModuleLoader.get_module(new_file, is_during_reload=reload_manager.is_reload) # This is to pretend the module imported from the edited lines # of code actually comes from the original file. module.__file__ = file_name @@ -291,9 +292,8 @@ def get_scene_module(args: Namespace) -> Module: if args.embed is None: return ModuleLoader.get_module(args.file) else: - is_reload = args.is_reload if hasattr(args, "is_reload") else False return get_module_with_inserted_embed_line( - args.file, args.scene_names[0], args.embed, is_reload + args.file, args.scene_names[0], args.embed ) diff --git a/manimlib/reload_manager.py b/manimlib/reload_manager.py index a8446873..e8f7f485 100644 --- a/manimlib/reload_manager.py +++ b/manimlib/reload_manager.py @@ -64,7 +64,6 @@ class ReloadManager: self.args.embed = str(overwrite_start_at_line) # Args to Config - self.args.is_reload = self.is_reload # Where is this used? scene_config = manimlib.config.get_scene_config(self.args) run_config = manimlib.config.get_run_config(self.args)