Package: micropython-typesheds
Micropython Typesheds (formerly known as Pyboard Typesheds)Rich typeshed (a.k.a.: type hints, interface stubs, and.pyifiles)
forMicroPython.
They arerichtypesheds because they give help document for
functions/methods, function/method arguments, function/method return types,
method overloads, classes, modules, protocols,
and constants/fields/properties.
These typesheds are useful for IDEs that understand type hints,
like PyCharm and VSCode, and for IDE plugins like the PyCharm's MicroPython plugin.What the typesheds doOnce installed, see next section, the typesheds offer:Code completion (in this case prompting completion forpyb):Rich help text (in this case constructor forLCD160CRshowing argument types, argument defaults, return types and
overloads as well as a description):Type errors (in this case afloatinstead of anint):Typos (in this casecolourinstead ofcolor; error can be avoided by
using code completion, see point 1 above):Using the typeshedsThere are four ways of installing the Typesheds:
via an IDE plugin, manually install into the IDE,
use PyPI, copy the.pyifiles into a project,
and manually copy the.pyifiles into a project.Via an IDE pluginFor PyCharmCurrently, December 2021, JetBrains have added many of these typesheds to their
MicroPython plugin (many thanks to JetBrains and in particular Andrey Vlasovskikh).
Therefore, installing the JetBrains Micropython plugin
will be the easiest solution and also
the typesheds will get updated everytime the plugin is updated:Install theMicroPython plugin.Enable the plugin for the project
(two stages in project preferences/options:
add the plugin to the project and then select options in the plugin):The other options, below, unfortunately require manual updating and are more
involved (though not difficult).Manually install in an IDEFor PyCharmIf the very latest typesheds are required then they can be installed from
this repository directly.Note:The following procedure, below, only needs to be done for one project;
after which all projects using the
MicroPython plugin will pick up the typesheds.Install and enable the plugin, see previous section above.Download the ZIPed.pyifiles from GitHub:Unpack the ZIP file.Drag (or copy and past) the.pyi(only) files into the Micropython Plugin
(see image for which directory to put each file in):Disable and re-enable plugin by going to preferences/options un-tick
Micropython support and Apply then re-tick
MicroPython support and OK
(so that it picks up the changes):Use PyPI to copy the.pyifiles into a project or IDEInstall the typesheds' installerpipinstall--upgrademicropython-typeshedsCopy the typesheds to where they are required.
EG typeshed location for IDE or plugin or top
level of project.Note:The following command, below, needs
to be done forallrequired locations:python-mmicropython_typesheds<destination-directory>Copy.pyifiles into a projectNote:The following procedure, below, needs to be done forallprojects:Download the ZIPed.pyifiles from GitHub:Unpack the ZIP file.Drag the.pyi(only) files from directorymicropython_typeshedsinto the top level of a project:PhilosophyThe typesheds are generated byhttps://github.com/hlovatt/PyBoardTypeshedGeneratorfrom the MicroPython.rstdoc files.The philosophy of generating the typesheds is to take a superset of what is
in the docs and what is listed by thedircommand on a MicroPython board
(the docs anddirdon't agree!).
An example of thedircommand having more information than the docs is the docs
forpyb.Pinmentionsboardandcpuclasses and implies they contain
declarations of availablePins;dir(pyb.Pin.cpu)on the other hand lists thePins,
therefore the generated typeshed containsboardandcpuwithPindefinitions.