Typesheds

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
hlovatt
Posts: 54
Joined: Thu Aug 15, 2019 3:52 am
Location: Sydney

Typesheds

Post by hlovatt » Sat Jul 25, 2020 4:31 am

Hi all,

Is there an interest in adding typesheds (type hint interfaces) to MicroPython to help IDEs that understand types and/or show documentation: PyCharm, VSCode, etc.?

So far I have generated `pyb.pyi` and `uarray.pyi`, the files are at https://github.com/hlovatt/PyBoardTypeshed and the code used to generate them is at https://github.com/hlovatt/PyBoardTypeshedGenerator. The generating code parses the current documentation, `.rst`, files.

Is this something of interest to officially include in MicroPython (i.e. to add a top level `typeshed` folder containing `.pyi` files)?

Howard.

PS If typesheds were available for the whole of MicroPython then in the future instead of generating typesheds from `.rst`, the `.rst` could be generated from the typesheds!

`.rst` from typeshed would lead to improved documentation by having type information in it, more complete, and also having a standard Python structure. The current documentation is in places unstructured (e.g. "Hardware Note" for `Accel`) and incomplete (e.g. no definition of `board` nor `cpu` in `pyb`). The typesheds generated using the generator code referenced above fix some of these issues.

User avatar
jimmo
Posts: 1769
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Typesheds

Post by jimmo » Mon Jul 27, 2020 5:29 am

hlovatt wrote:
Sat Jul 25, 2020 4:31 am
Is this something of interest to officially include in MicroPython (i.e. to add a top level `typeshed` folder containing `.pyi` files)?
This sounds really good. I don't know anything at all about typesheds but from what you've put together there it looks like a much better way to maintain the documentation. I'll have to investigate further!

Post Reply