How to find function arguments for non documented modules? (for the purpose of trying to write a cross port library) #14058
Replies: 1 comment 3 replies
-
I started out with a similar question about 5 years ago, and based on that I created the micropython-stubs project to combine the available information from available sources ( docs , frozen .py, interrogating the firmware directly) , and make that available to IDEs and typecheckers. I agree that there are still a large number of MicroPython classes, methods and functions that have very sparse, or no documentation. And if there is no documentation - there is no information on the parameters. As MicroPython tries to be as similar to CPython as possible, its documentation is a good fallback , and this is why i include a link to the CPython stdlib docs where possible. On comparing the similarities/differences across ports, I know there are many and I have some thoughts on how to compare those ( Run a AST / CST parser on the stubs, and compare the syntax trees ) Update: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I've been going down the road of trying to write a library that will work across the esp32, esp8266 and rp2 ports, and so I'm only using modules that are available on all of those boards for a given micropython version, which I've been getting by using the REPL to
help("modules")
for each board.But trying to go further with that by only using functions that are shared across all ports that take the same amount of arguments has me a bit stuck. The micropython documentation site is great for all of the info on there, but as soon as i want something that isn't documented, an arbitrary example of that being DHT11 (actually probably not the BEST example since it does have BASIC documentation under the esp reference with an example, but not for rp2 and not "proper" documentation"), I can't seem to find a good way to ensure if writing portable code using that module is possible.
I initially tried grabbing the stubs myself off each board, which was time consuming, and ended up resulting in function arguments not being available anyway, and i read online that others in the python community use the
inspect
module to do this, but that does not seem to be available on micropython, likewise with many dunder methods on objects. I've also seen some micropython specific info online about getting details from reading the c code, and if that's a genuinely possibility (meaning you can READ the differences between different ports), then i can live with that, but i would need help as i did try that, but I'm not familiar with the C language, and i couldn't even find a specific function i wanted to know about trying to navigate the repo naively.So I'm looking for direction or advice on how to find if a specific function is available on a port, and which arguments it takes for that port. How are others writing microptyhon code to be portable across ports? How do you develop with micropython efficiently without relying on the documentation website for every function argument, or when there is no documentation available at all?
Beta Was this translation helpful? Give feedback.
All reactions