Skip to content
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

Handle method names that are python reserved words. #84

Conversation

lizlooney
Copy link
Collaborator

The code generated for blocks that call methods defined in the same module match the method definition blocks. For example, if you create a method named "raise" and you drop a call block for it on the same blockly workspace, the python code for both the definition and the call will be "raise2".

Added known issue to readme: renaming a method definition doesn't update call blocks.

Fixes #73

Added known issue to readme: renaming a method definition doesn't update call blocks.
@lizlooney lizlooney requested a review from alan412 March 1, 2025 04:46
Copy link
Collaborator

@alan412 alan412 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem like the right way to solve this problem. It feels like it should all be done in mrc_class_method_def using .mrcPythonMethodName. That way the same code we will need for when a user renames a method can be used for when they put in a reserved word

@alan412
Copy link
Collaborator

alan412 commented Mar 1, 2025

Although i did test it and it does work.

@lizlooney
Copy link
Collaborator Author

lizlooney commented Mar 4, 2025

It feels like it should all be done in mrc_class_method_def using .mrcPythonMethodName.

I agree! That would be the best solution!

I tried to set .mrcPythonMethodName to funcName, like this:
Screenshot 2025-03-03 at 10 05 03 PM

But, that made it so the python method name stayed that name, even if the user changed the method name on the block. I looked for where it handles the event that happens when the user edits the method name on the blocks (so I could set .mrcPythonMethodName to ''), but I couldn't find a handler for that. Is there already an event handler for that?

I'm still working on this.

@lizlooney
Copy link
Collaborator Author

I made some more progress on this by looking at how blockly does their procedure blocks.

@lizlooney
Copy link
Collaborator Author

I'm closing this PR. I'll make a new one with a better implementation.

@lizlooney lizlooney closed this Mar 5, 2025
@lizlooney lizlooney deleted the pr_method_name_python_reserved_word branch March 5, 2025 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle method names that are python reserved words
2 participants