-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically identify the class name based on the specified line number. #2280
Conversation
@@ -142,35 +143,48 @@ def get_indent(code_lines: list[str], line_number: int) -> str: | |||
return n_spaces * " " | |||
|
|||
|
|||
def insert_embed_line_to_module(module: Module, line_number: int): | |||
def insert_embed_line_to_module(module: Module, run_config: Dict) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of passing run_config
inside here, an alternative could be to return the scene names from this function and then update the scene_names
of run_config
from somewhere outside, e.g. in get_module
that is calling insert_embed_line_to_module)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about the suggestion.
The reason I am searching for the scene name within this specific function is to access the module's lines to locate the keyword class
above the specifed line number.
Co-authored-by: Splines <[email protected]>
Co-authored-by: Splines <[email protected]>
There are some cases where the scene that has the embed line is not the same as the one I'm running. For example, suppose you define some SceneA with a certain construct. Then you define SceneB as a subclass, which doesn't have its own construct method (so it effectively uses that of SceneA), but makes other changes to the class variables, methods, etc. The desired behavior is that if you do pass in a scene names, like This should be a pretty quick fix, I believe all you need to do is check whether run_config already has scene_names defined, and if so, don't do the search for the scene. |
Thanks @3b1b for the feedback. |
Looks good to me |
这是来自QQ邮箱的假期自动回复邮件。
您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。
|
Motivation
Whenever some user passes the command
-e <line_number>
, it feels redundant to specify the class name.The closest class name (above the specified
<line_number>
) should automatically be identified by the program, and updates the value ofscene_names
key in therun_config
dict.Proposed Changes
I couldn't find a better position to insert the code than in the
insert_embed_line_to_module
function. As it ensures that thescene_names
updates only when thee
flag is passed, and also the module lines can be used to determine the class name.Also, resolving minor bugs in
text_mobject
andstring_mobject
files.