Closed koldomon closed 1 year ago
Hi @koldomon
We are doing some preliminary work in looking at what a great experience for embedded Python development would be. If you don't mind please share what all you would like to see here, so we can take that into consideration.
Thanks
Hi @gramster Thank you very much for taking a closer look. I really have to excuse if I write "strange wishes", as I stated, I'm totally new to python.
that's all :-)
It's great if VSCode also has the "Code insight" feature as in PyCharm plugins for MicroPython devices. https://plugins.jetbrains.com/plugin/9777-micropython
I found out, that someone of the micropython community is already working on that problem https://github.com/Josverl/micropython-stubber Maybe you can corporate together?
Hi,
Indeed I have been working on this topic of language support, and am trying to land on a solution that can support decent support for the different micropython and firmware versions under development, as they all differ slightly and even the same firmware may have different modules available depending on compiltation or the frozen modules added.
In my view the ability to automatically generate the stubs for a specific firmware has the advantage that VSCode can work with all the different firmwares , without the need to manually code the stubs , and keep them up to date / with the various versions
the downside of the generated stubs is that they have no parameter or type information. some of that can be remedied, and others may be resolved by manually adding / augmenting the stubs
Happy to combine work on this, or if not then I will try to continue my work this into an add-on myself/ in any case I would welcome some more insights into how to influence the syntax highlighting and checking with the Python / Intellisense add-ins, as I suspect that im currently using the try and fail approach.
I would also be interested in understanding how to setup unit tests for such an approach. (can't build it if you cant test it)
as they all differ slightly and even the same firmware may have different modules available depending on compiltation or the frozen modules added.
@Josverl apart from frozen modules, is it possible to mock those modules from documentation+C headers so they give PEP 484 annotations ( and then offer to merge them back in Micropython documentation ) ? can https://github.com/Josverl/micropython-stubber actually help for that ?
Currently micropython-stubber does not take use the source files for micropython into account at all. there are 2 reasons for this :
I have been considering to enrich the the stubs based om HTMLor RST documentation; but that is also quite unstructured across firmware flavours and authors.
Hi all,
I've been working on a project called micropy-cli that aims to help solve this issue. Using pre-generated stubs from Josverl's micropython-stubber, it attempts to automate both stub management and project dependencies. (enabling autocompletion/intellisense for them too). It's not exactly integration, but I believe its the best we can get until more work can be done here.
FWIW MicroPython is now supported by the Device Simulator Express extension for the micro:bit device.
@brettcannon Can you please re-review if we need to have a support for this in the extension? 😄 I assume we won't be using this in the browser, so not sure where this could be helpful as of today.
Since everyone seems to be after IntelliSense, I'm going to move this to PyLance.
can we get some instructions on how to set this up to repro the issue user is reporting? For pylance to work properly, we need python interpreter to get some environment information. and stubs for builtin/stdlibs.
none of them seems possible with microPython. but without actual way to set it up and repro, hard to be sure.
please reopen with instructions to set up and repro the issue. will close the issue until then.
@heejaechang, Just to close the loop: you are correct on the requirements, a nd I have worked on automated generation of MicroPython stub packages and find that both Pylance and Pyright work quite well with these once they are installed.
The only hustle is the need to specify python.analysis.typeshedPaths
in a configuration file, where PyCharm does not require this for the same project.
see https://micropython-stubs.readthedocs.io/en/latest/22_vscode.html for the VSCode & Pylance config
@Josverl thank you for the comment. one question. for the interpreter, is it using the regular python interpreter for pylance/pyright? or is there micropython for x86?
otherwise, basically, all supports you want is override regular stdlib stubs to the one from micropython?
adding @luabud @judej for input.
If we want to add some kind of support for micropython. one way we can do is I think we somehow detect the workspace is for micropython and we automatically switch typeshed folder to the micropython one and auto configure to what this says - https://micropython-stubs.readthedocs.io/en/latest/22_vscode.html#sample-vscode-configuration-file
and one way to find out whether it is micropython workspace is checking whether micropython-stubs is installed in current workspace? (https://micropython-stubs.readthedocs.io/en/latest/22_vscode.html#install-the-stubs-from-pypi)
Moving this issue to discussion as an enhancement request for comments and upvotes.
Environment data
I want to use Visual Studio Code to develop MicroPython on a ESP8266. But I'm really new to Python and this is my really first project. I installed VSCode on Linux Mint19.1 (working fine), installed the Extenions "MicroPython IDE" and "Pymakr" (both are working fine), but when I'm writing Code, there is no code-completion for some modules and "machine" is always marked with "unresolved import". Then I cloned the github repo from micropython and "linked" it in my settings.json ("python.autoComplete.extraPaths": ["/home/me/src/micropython/ports/esp8266", "/home/me/src/micropython/drivers"]). With that extrapath i get most module with code-completion and all the nice intellisense features, but not for "machine" or "network". And I'm stuck at this point. I already tried to get some help in the micropython forum but had no success.
what i want to do: build some nice IOT devices with micropython what i am actually doing: trying to get the environment working
I'm a developer for VB.NET for years and I know to ask "the right" people if you have a problem. So PLEASE can some of you amazing people spend a few hours to support micropython in visual studio code. PLEASE PLEASE PLEASE help.
greetings Markus