-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Research and create stubbins for MicroPython/our Boards as per Kirk's wishes.
From Kirk:
The TL;DR is:
Create micro python language/symbol files for our boards using Micro-Python Stubs pacakge
To get this to work will take a little hacking
The stub files are added to vscode to enable MicroPython code editing and syntax chekcing
The MicroPico extension uses these stub files to ID and support MicroPython boards.
One of the key items needed to get support for Micro Python in vscode is to have the language symbols added to the syntax/language validation extension in vscode.
For MicroPython, this is implemented by a system called MicroPython Stubs (I keep wanting to call it stubbings ..) - Details of this are here:
https://micropython-stubs.readthedocs.io/en/main/index.html
https://github.com/Josverl/micropython-stubs
We need to build out stubs for our boards. This is done using the stubber command, and outlined here:
https://micropython-stubs.readthedocs.io/en/main/diy_stubs_files.html
Basically, you build stubs for our boards and then do a PR to merge them into the overall stub/stubber package.
I gave it a try this morning , but couldn’t complete the process. Partially b/c our boards are not in the latest preview (I think) and possibly the stubber command has an issue or two
One issue is I believe this section of code needs to be uncommented so the board name is correct :
https://github.com/Josverl/micropython-stubber/blob/96c7b89a1e9a8f1b63d0486ac7fcbd402d3dad8c/mip/v5/createstubs_lvgl.py#L614
MicroPico Extension
Once we have board stubs in place with the main stubs package, they can be added to the MicroPico Extension, which uses the stubs for board support.
You can manually generate stubs and add them to vscode, so that PyLance uses them when you edit micro python code.
This is outlined here:
https://micropython-stubs.readthedocs.io/en/main/27_micropico.html
Just adding the stubs removes any syntax warnings issued for micro python code when editing in vscode.
I installed the stubs for the pico2_w board using this command (on macOS)
pip install -U micropython_rp2_rpi_pico_w_stubs --no-user —target ~/.micropico-stubs/included
And once I added the noted python setting lines to my settings.json file in vscode I was able to edit MicroPython code without warnings.
Tasks:
- Create stubs for a single board
- Test stubs in VSCode
- Create stubs for all boards? -> might be automatically done for mainline MP
- Submit stubs to necessary repos? -> might be automatically done for mainline MP
Metadata
Metadata
Assignees
Labels
Type
Projects
Status