-
Notifications
You must be signed in to change notification settings - Fork 106
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
Type Hints for ESP32 #218
Type Hints for ESP32 #218
Conversation
Thank you very much! I'll try to review it in the nearest future (or at least not later than January) |
Sounds awesome! Ill keep adding any missing type hints as I run into them. |
Wouldn't be just easier to install the package micropython-{esp32,...}-stubs ? Somebody else is already doing the hard-work to keep boards and micropython libraries in sync. Just add an additional dependency and we're good to go. |
@PBrunot I had no idea this existed! Could you post a link? I agree that would be much better than manually keeping these up to date. Do you know of any similar packages for other boards or even the micropython core modules (as they too are out of date) |
I think this one is different, but it seems to have cover all the boards this plug-in supports + the core modules. We could completely remove the type hints folder in this repo and just install from here |
@PBrunot I have been playing around with this library a bit and it seems to be lacking in a few major ways. The first is that there are no built in comments, and second many of the actual type hints are missing. As in functions do not say what data types they take in or return. |
Yes you are right. Lack of comments is a big drawback.
Investigating why, my understanding is that micropython-stub is generating the typehints file by examinating binaries directly, which does not contain this information. I'm not sure if
* the comments are stripped for size reduction
* or just aren't there because the source is written in C and not python.
*If* we could build a "full documented" version of the modules from micropython repo, then micropython-stubs would do a better job. I don't know if that's even possible.
Le mar. 27 déc. 2022, 08:48, Ethan Stevenson ***@***.***> a
écrit :
… @PBrunot <https://github.com/PBrunot> I have been playing around with
this library a bit and it seems to be lacking in a few major ways. The
first is that there are no built in comments, and second many of the actual
type hints are missing. As in functions do not say what data types the take
in or return.
This is not very helpful beyond making the ide happy:
[image: image]
<https://user-images.githubusercontent.com/43613843/209631035-2aacec7e-acd3-43e0-b2f3-35652ebfc76e.png>
—
Reply to this email directly, view it on GitHub
<#218 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABPSQU6HIV7JF7Z4GP6LNPDWPKNMZANCNFSM6AAAAAATGC66NY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I spend some time yesterday looking into micropython code and it seems
clear to me that there is no way to extract detailed information from C
code (no descriptions, generic mp_obj_t , type and argcount check at
runtime). So parsing the docs maybe the best option indeed. I have not
understood yet the doc workflow with Sphynx that Micropython uses.
Le mer. 28 déc. 2022, 01:35, Ethan Stevenson ***@***.***> a
écrit :
… Yeah Im not sure what they were thinking when they made this tool, but how
are these hints helpful lol? They all just take args and kwargs return any:
[image: image]
<https://user-images.githubusercontent.com/43613843/209739559-df812d21-f262-4558-846f-4225df3795be.png>
I think the best way forward would be writing a custom tool that creates
stubs based on the micropython docs
—
Reply to this email directly, view it on GitHub
<#218 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABPSQU2N2JIDRWL35JVHNETWPODMDANCNFSM6AAAAAATGC66NY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
That is correct, we cannot extract the comments from the c code. However, there is a repo called micropython-libs that contains the raw python for all of the micropython libraries. There are some comments in there. The rest of the comments would need to be extracted from the official docs |
@Elizaveta239 Any update on this/how we need to move forward? |
Signed-off-by: Elizaveta Shashkova <elizabeth.shashkova@gmail.com>
Hi! I'm very sorry for the late response! Thank you very much for the contribution! I'm closing the PR, It's merged into master. I'll fix some compatibility issues and will publish the new version of the plugin soon. |
Dear @navastar,
Fully agree - that is what I have done. I parse the (sometimes incomplete) micropython documentation ( The best stubs are in 'publish' and on PyPi fyi: The reason that the stubs mentioned above contain is little / no information for the DS18x20 device is due to the fact that:
And my code is not smart enough to conjure information out of thin air. ( perhaps I should try to to add OpenAI for that, at the risk of mixing Circuitpython methods with Micropython ... ) @PBrunot @Elizaveta239, please let me know for fixes that you find that you need to make. That way I can either improve the documentation , or try to improve the logic, for esp32 , as well as for other ports. Please share the feedback here on on https://github.com/Josverl/micropython-stubs/discussions Happy to help you help other coders. |
Can't find |
Type-stubs are in the planning, and being worked on, for the Micropython project, based off the automated micropython -stubs that I created. Hope that set your mind at ease. |
I have created type hints for the ESP32! This includes the esp module (it differs from the esp8266 esp module) and the esp32 module. I would like to also create hints for the espnow module, however I don't think it is yet in the main branch of micropython. Please let me know If I am wrong about this and I will make a pr with hints for it.
Please have a look over my hints and make sure there are no glaring issues, I have gone over a few times and I think they are pretty solid. The only remaining issues as far as I can tell are a few functions that have no comments. I was unable to find any description of what they do in the official micropython docs.