How to override the aioble pyi stub files in Visual Studio code #13553
-
When installing the latest version of Micropython on the PICO W, the bluetooth aioble library is included (however it is in byte code form). VS Code has a set of pyi stub files in the .vscode directory (actually its a short cut to the massive AppData directory). However, the type of the variables in the stubs are Incomplete which does not help me understand what the variables/classes. etc are. The source code, on the other hand, does contain types for many of these values and I have downloaded that source. Being relatively inept when it comes to Python programming (and especially configuration) what I would like to do is to configure VS code such that statements like 'import aioble' point to the source and not the stubs. Does anyone know now to do this? Would it be as straight forward as replacing the aioble stub directory contents with the aioble source? Somehow I have a feeling that would create a hidden disaster. I tried replacing the code in the AppData folder and after restarting VS code, it appears to work but I don't know what the side effects might be. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
A few points of explanation:
I would expect that your project's .vscode folder looks somewhat like this, if not , can you please share some more details here :
While this is not the intended configuration, the simplest way is to:
You can do this for any module that is written in MicroPython. This method will not work for No harm will de done, no kittens will be hurt, and pythons will continue to hatch eggs, but type checking will run (a bit) slower.
Now you may ask, if this can be done, then why not do this already in the stubs ?
I have been trying to grok the inner workings of python type-checking for years, and still continue to learn each month, and meanwhile type checking also continues to evolve and grows new capabilities with each Python version. Please let me know if this helps and If you think I should I should add this to the documentation at https://micropython-stubs.readthedocs.io/ |
Beta Was this translation helpful? Give feedback.
A few points of explanation:
fallback
stubs (.vscode\extensions\ms-python.vscode-pylance-2023.12.1\dist\typeshed-fallback
)In none of the many of such configuration I have seen, is this a shortcut to App Data, but you o…