Refactor/backend
This is the "thonnycontrib/backend/py5_imported_mode_backend.py" cleanup.
However, after some testings, I've concluded this file can be deleted and it won't change the plugin's behavior!
Basically, this file adds 'from py5 import *\n' to a py5mode sketch. But it seems like library py5 is somehow already doing that!
Therefore, my advice is to fully delete this "backend" folder from this plugin project!
https://github.com/py5coding/thonny-py5mode/issues/89
There's no need to prepend the user's code with from py5 import * because the run sketch utility does that for you. Did you test it with this removed? If it is fine without it, we should get rid of it.
Also, I'd rather not merge this until after the next release. I don't want to merge non-critical things until we test the release and push it to pypi.
Also, I'd rather not merge this until after the next release.
As I have already stated, these pull requests belong to ongoing type hint fix refactoring batches.
They're not supposed to be merged right now.
Did you test it with this removed?
Yup! File renamed, removed, purposefully typing wrong Python syntax to crash the file, etc.
For all those experimental cases, p5mode plugin kept working normally w/ no apparent changes on its behavior!
Seems like we don't need a Thonny backend hack anymore. :D
Also, I'd rather not merge this until after the next release.
As I have already stated, these pull requests belong to ongoing type hint fix refactoring batches.
Yes, and this PR is appreciated and is helpful. We also need to test the latest release candidate. Once we do a test of the release candidate on each OS we can do a release. I was hoping you and @villares could do the testing here since both of you use the plugin much more than I do. When you and @villares let me know the release candidate works fine on each OS we will be ready.
Seems like we don't need a Thonny backend hack anymore. :D
I'm fine with removing it but am reminded of Chesterton's Fence. Why was that code added in the first place? I feel like we are missing something.
Why was that code added in the first place?
https://github.com/py5coding/thonny-py5mode/blob/0.4.6-alpha/thonnycontrib/backend/py5_imported_mode_backend.py#L32-L34
prefix = 'from py5 import *\n'
cmd['source'] = prefix + cmd['source']
cmd['row'] += 1
From the excerpt above, I believe it's just a hack to add 'from py5 import *\n' at the top of a sketch.
But given run_sketch() already does that, we should get rid of this backend; given it hacks class MainCPythonBackend for all Thonny addons!
I was hoping you and @villares could do the testing here
Well, I'm testing on my Arch-based Linux distro Garuda. :penguin: @villares can test on Windows. And some times, he has access to MacOS.
given it hacks class MainCPythonBackend for all Thonny addons!
Really? Then we definitely shouldn't do this, hacking the code is not a good practice.
given it hacks class MainCPythonBackend for all Thonny addons!
Really? Then we definitely shouldn't do this, hacking the code is not a good practice.
These monkey-patch cases are very common across the whole plugin code! Dunno whether this is Thonny's intended approach for injecting plugin behavior into the editor... Maybe much later I'll look up if there's an actual proper way to inject behavior for Thonny plugins.