{
  "id": "josverl/micropython-stubber",
  "name": "micropython-stubber",
  "prettyName": "micropython-stubber",
  "description": "Generate and maintain stubs for different MicroPython ports to use with VSCode and Pylance, PyRight, Thonny, PyCharm or MyPy",
  "version": "",
  "author": "josverl",
  "license": "NOASSERTION",
  "tags": [
    "firmware-stubs",
    "micropython",
    "micropython-stubber",
    "micropython-stubs",
    "mypy",
    "mypy-stubs",
    "pylance",
    "pyright",
    "python",
    "static-typing",
    "typed",
    "vscode"
  ],
  "status": "VALID",
  "official": false,
  "source": "https://github.com/josverl/micropython-stubber",
  "updatedAt": "2025-06-28T07:00:20.686Z",
  "page": "https://checkmim.com/packages/josverl+micropython-stubber",
  "createdAt": "2025-05-27T04:35:51.746Z",
  "submittedBy": "oliverr",
  "install": {
    "mpremote": "mpremote mip install github:josverl/micropython-stubber",
    "mip": "import mip; mip.install(\"github:josverl/micropython-stubber\")"
  },
  "readme": "# Boost MicroPython productivity in VSCode\n \n  [![pypi version](https://badgen.net/pypi/v/micropython-stubber)](https://pypi.org/project/micropython-stubber/)\n  [![python versions](https://badgen.net/pypi/python/micropython-stubber)](https://badgen.net/pypi/python/micropython-stubber)\n  [![Ruff](https://img.shields.io/badge/code%20style-ruff-d7ff64.svg)](https://docs.astral.sh/ruff/ \"Ruff badge\")\n  [![Star on GitHub](https://img.shields.io/github/stars/josverl/micropython-stubber.svg?style=social)](https://github.com/josverl/micropython-stubber/stargazers)\n  [![All Contributors](https://img.shields.io/badge/all_contributors-19-green.svg?style=flat-square)](#Contributions)\n  <!-- break -->\n  [![pytest stubber](https://github.com/Josverl/micropython-stubber/actions/workflows/pytest.yml/badge.svg)](https://github.com/Josverl/micropython-stubber/actions/workflows/pytest.yml)\n  [![Documentation Status](https://readthedocs.org/projects/micropython-stubber/badge/?version=latest)](https://micropython-stubber.readthedocs.io/en/latest/?badge=latest \"Document build status badge\")\n  <!-- break -->\n  [![Open in VSCode](https://img.shields.io/static/v1?logo=visualstudiocode&label=&message=Open%20in%20Visual%20Studio%20Code&labelColor=2c2c32&color=007acc&logoColor=007acc\n)](https://open.vscode.dev/josverl/micropython-stubber)\n  \nThe IntelliSense and code linting that is so prevalent in modern editors, does not work out-of-the-gate for MicroPython projects.\nWhile the language is Python, the modules used are different from CPython, and also different ports have different modules and classes, or the same class with different parameters.\n\nWriting MicroPython code in a modern editor should not need to involve keeping a browser open to check for the exact parameters to read a sensor, light-up a LED or send a network request.\n\nFortunately with some additional configuration and data, it is possible to make the editors understand your flavor of MicroPython, whether you use one of the pre-compiled firmwares, but also if you run a one-off custom firmware version.\n\n\n![demo][]]\n\nIn order to achieve this a few things are needed:\n1) Stub files for the native / enabled modules in the firmware using PEP 484 Type Hints\n2) Specific configuration of the VS Code Python extensions \n3) Specific configuration of Pylint [ Optional ]\n4) Suppression of warnings that collide with the MicroPython principles or code optimization.\n\nPlease review the documentation on [https://micropython-stubber.readthedocs.io]  \n\nWith that in place, VSCode will understand MicroPython for the most part, and help you to write code, and catch more errors before deploying it to your board. \n\nNote that the above is not limited to VSCode and pylint, but it happens to be the combination that I use. \n\nA lot of subs have already been generated and are shared on PyPi, github or pre-installed by a tool, so it is quite likely that you can just grab a copy be be productive in a few minutes.\n\n## To install pre-built stubs from PyPI\nThis section describes how to install the stubs from PyPI, and how to use them in your project.\nIf you want to create or maintain stub - please see the next section.\n\n- Install in a typings folder (recommended) \n  `pip install -U micropython-<port>[-<board>]stubs --no-user --target ./typings`\n- Install in a venv (after activating) \n  `pip install -U micropython-<port>[-<board>]stubs --no-user`\n\nExamples:\n``` bash\npip install -U micropython-stm32-stubs\n\n# Install stubs for a specific version.\npip install -U micropython-esp32-stubs==1.20.0.*\n\n# Install stubs for a specific board.\npip install -U micropython-rp2-pico_w-stubs\n```\n\nFor more details how to use the stubs please refer to [the documentation on RTD](https://micropython-stubs.readthedocs.io/en/latest/20_using.html)\n\n\n1. The sister-repo [**MicroPython-stubs**][stubs-repo] contains [all stubs][all-stubs] I have collected with the help of others, and which can be used directly.\nThat repo also contains examples configuration files that can be easily adopted to your setup.\n\n2. Micropython-stubber uses [MPFlash](https://github.com/Josverl/mpflash?tab=readme-ov-file) in some of its operations.\n   mpflash was formerly hosted in this repo, but has been moved to its own repo.\n\n## Quick start to build stubs\n\n```bash\npip install micropython-stubber\n\ncd my_stub_workspace\nmkdir all-stubs\n\n# pick a firmware version (tag, stable, preview)\nstubber switch stable\n\n# generate doc-based stdlib stubs for the selected version\nstubber docstubs --enrich\n\n# capture frozen modules from reference firmware downloads\nstubber frozen --version stable --enrich\n\n# merge the pieces for one or more targets\nstubber merge --port esp32 --board ESP32_GENERIC --version stable\nstubber merge --port rp2 --board RPI_PICO_W --version stable\n\n# build final wheel-style outputs in all-stubs/<port>/<board>\nstubber build --port esp32 --board ESP32_GENERIC --version stable\n```\n\n- `switch` locks the workspace to a MicroPython release before running other commands.\n- `docstubs` pulls documentation-based stubs; `frozen` adds board-specific frozen modules.\n- `merge` and `build` combine everything into installable stubs under `all-stubs/`.\n\n## Common commands\n\n- List available firmware tags: `stubber switch --list`\n- Create merged stubs for every board of a port: `stubber merge --port esp32 --board all --version stable`\n- Rebuild already downloaded artifacts: `stubber build --port esp32 --board ESP32_GENERIC --version stable`\n- Enrich an existing stub set with docstrings/parameter hints: `stubber docstubs --enrich`\n\n## Outputs and where to use them\n\n- Generated wheels and folders end up under `all-stubs/<port>/<board>/<version>`.\n- Point your editor type checker (Pyright/Pylance/Mypy) to the `all-stubs` path or install the produced wheels into your project virtual environment.\n- For a full worked example, see the notebook [Manual stub build chain.ipynb](Manual%20stub%20build%20chain.ipynb) which mirrors the CLI workflow used above.\n\n### Working with Custom MicroPython Builds\n\nIf you're working with a fork, branch, or custom build of MicroPython (such as a custom RPi Pico W firmware), see the [Custom MicroPython Guide](docs/25_custom_micropython.md) for detailed instructions on how to generate stubs for your specific build.\n\n\n## Developing & testing \n\nThis is described in more detail in the [developing](docs/developing.md) and [testing](docs/testing.md)  documents in the docs folder.\n\n## Branch Main\nThe name of the default branch has been changed to `main`.\nIf you have cloned this repo before you main need to adjust the local repro to be aware of this, or create a fresh clone.\n\nTo update run the below command:  \n``` bash\ngit branch -m master main                    \ngit fetch origin\ngit branch -u origin/main main                      \ngit remote set-head origin -a\n```\n\nfor more info see [**Renaming a branch**](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-branches-in-your-repository/renaming-a-branch#updating-a-local-clone-after-a-branch-name-changes)\n\n## Licensing \n\n`MicroPython-Stubber` is licensed under the MIT license, and all contributions should follow this [LICENSE](LICENSE).\n\n\n# Contributions\n<!-- spell-checker: disable -->\n<!-- \nTo add via the cli run the following command:\nnpx all-contributors-cli add user things\nnpx all-contributors-cli generate\n\n - bug\n - tool\n - stubs\n - test\n - doc\n - code\n - research\n - ideas\n - content\n - mpflash\n -->\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<table>\n  <tbody>\n    <tr>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/Josverl\"><img src=\"https://avatars2.githubusercontent.com/u/981654?v=4?s=100\" width=\"100px;\" alt=\"Jos Verlinde\"/><br /><sub><b>Jos Verlinde</b></sub></a><br /><a href=\"https://github.com/Josverl/micropython-stubber/commits?author=josverl\" title=\"Code\">💻</a> <a href=\"#research-josverl\" title=\"Research\">🔬</a> <a href=\"#ideas-josverl\" title=\"Ideas, Planning, & Feedback\">🤔</a> <a href=\"#content-josverl\" title=\"Content\">🖋</a> <a href=\"#stubs-josverl\" title=\"MicroPython stubs\">🖍️</a> <a href=\"#test-josverl\" title=\"Test\">✅</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://thonny.org/\"><img src=\"https://avatars1.githubusercontent.com/u/46202078?v=4?s=100\" width=\"100px;\" alt=\"Thonny, Python IDE for beginners\"/><br /><sub><b>Thonny, Python IDE for beginners</b></sub></a><br /><a href=\"#ideas-thonny\" title=\"Ideas, Planning, & Feedback\">🤔</a> <a href=\"#research-thonny\" title=\"Research\">🔬</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://micropython.org/\"><img src=\"https://avatars1.githubusercontent.com/u/6298560?v=4?s=100\" width=\"100px;\" alt=\"MicroPython\"/><br /><sub><b>MicroPython</b></sub></a><br /><a href=\"#data-micropython\" title=\"Data\">🔣</a> <a href=\"#stubs-micropython\" title=\"MicroPython stubs\">🖍️</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/microsoft/pyright\"><img src=\"https://avatars.githubusercontent.com/u/6154722?v=4?s=100\" width=\"100px;\" alt=\"pyright\"/><br /><sub><b>pyright</b></sub></a><br /><a href=\"#tool-pyright\" title=\"Tools\">🔧</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/loboris\"><img src=\"https://avatars3.githubusercontent.com/u/6280349?v=4?s=100\" width=\"100px;\" alt=\"Boris Lovosevic\"/><br /><sub><b>Boris Lovosevic</b></sub></a><br /><a href=\"#data-loboris\" title=\"Data\">🔣</a> <a href=\"#stubs-loboris\" title=\"MicroPython stubs\">🖍️</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/pfalcon\"><img src=\"https://avatars3.githubusercontent.com/u/500451?v=4?s=100\" width=\"100px;\" alt=\"Paul Sokolovsky\"/><br /><sub><b>Paul Sokolovsky</b></sub></a><br /><a href=\"#data-pfalcon\" title=\"Data\">🔣</a> <a href=\"#stubs-pfalcon\" title=\"MicroPython stubs\">🖍️</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/pycopy\"><img src=\"https://avatars0.githubusercontent.com/u/67273174?v=4?s=100\" width=\"100px;\" alt=\"pycopy\"/><br /><sub><b>pycopy</b></sub></a><br /><a href=\"#data-pycopy\" title=\"Data\">🔣</a> <a href=\"#stubs-pycopy\" title=\"MicroPython stubs\">🖍️</a></td>\n    </tr>\n    <tr>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/pycom\"><img src=\"https://avatars2.githubusercontent.com/u/16415153?v=4?s=100\" width=\"100px;\" alt=\"Pycom\"/><br /><sub><b>Pycom</b></sub></a><br /><a href=\"#infra-pycom\" title=\"Infrastructure (Hosting, Build-Tools, etc)\">🚇</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/BradenM\"><img src=\"https://avatars1.githubusercontent.com/u/5913808?v=4?s=100\" width=\"100px;\" alt=\"Braden Mars\"/><br /><sub><b>Braden Mars</b></sub></a><br /><a href=\"https://github.com/Josverl/micropython-stubber/issues?q=author%3ABradenM\" title=\"Bug reports\">🐛</a> <a href=\"https://github.com/Josverl/micropython-stubber/commits?author=BradenM\" title=\"Code\">💻</a> <a href=\"#stubs-BradenM\" title=\"MicroPython stubs\">🖍️</a> <a href=\"#platform-BradenM\" title=\"Packaging/porting to new platform\">📦</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://binary.com.au/\"><img src=\"https://avatars2.githubusercontent.com/u/175909?v=4?s=100\" width=\"100px;\" alt=\"James Manners\"/><br /><sub><b>James Manners</b></sub></a><br /><a href=\"https://github.com/Josverl/micropython-stubber/commits?author=jmannau\" title=\"Code\">💻</a> <a href=\"https://github.com/Josverl/micropython-stubber/issues?q=author%3Ajmannau\" title=\"Bug reports\">🐛</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"http://patrickwalters.us/\"><img src=\"https://avatars0.githubusercontent.com/u/4002194?v=4?s=100\" width=\"100px;\" alt=\"Patrick\"/><br /><sub><b>Patrick</b></sub></a><br /><a href=\"https://github.com/Josverl/micropython-stubber/issues?q=author%3Aaskpatrickw\" title=\"Bug reports\">🐛</a> <a href=\"https://github.com/Josverl/micropython-stubber/commits?author=askpatrickw\" title=\"Code\">💻</a> <a href=\"#stubs-askpatrickw\" title=\"MicroPython stubs\">🖍️</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://opencollective.com/pythonseverywhere\"><img src=\"https://avatars3.githubusercontent.com/u/16009100?v=4?s=100\" width=\"100px;\" alt=\"Paul m. p. P.\"/><br /><sub><b>Paul m. p. P.</b></sub></a><br /><a href=\"#ideas-pmp-p\" title=\"Ideas, Planning, & Feedback\">🤔</a> <a href=\"#research-pmp-p\" title=\"Research\">🔬</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/edreamleo\"><img src=\"https://avatars0.githubusercontent.com/u/592928?v=4?s=100\" width=\"100px;\" alt=\"Edward K. Ream\"/><br /><sub><b>Edward K. Ream</b></sub></a><br /><a href=\"#plugin-edreamleo\" title=\"Plugin/utility libraries\">🔌</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/dastultz\"><img src=\"https://avatars3.githubusercontent.com/u/4334042?v=4?s=100\" width=\"100px;\" alt=\"Daryl Stultz\"/><br /><sub><b>Daryl Stultz</b></sub></a><br /><a href=\"#stubs-dastultz\" title=\"MicroPython stubs\">🖍️</a></td>\n    </tr>\n    <tr>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/cabletie\"><img src=\"https://avatars1.githubusercontent.com/u/2356734?v=4?s=100\" width=\"100px;\" alt=\"Keeping things together\"/><br /><sub><b>Keeping things together</b></sub></a><br /><a href=\"https://github.com/Josverl/micropython-stubber/issues?q=author%3Acabletie\" title=\"Bug reports\">🐛</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/vbolshakov\"><img src=\"https://avatars2.githubusercontent.com/u/2453324?v=4?s=100\" width=\"100px;\" alt=\"vbolshakov\"/><br /><sub><b>vbolshakov</b></sub></a><br /><a href=\"https://github.com/Josverl/micropython-stubber/issues?q=author%3Avbolshakov\" title=\"Bug reports\">🐛</a> <a href=\"#stubs-vbolshakov\" title=\"MicroPython stubs\">🖍️</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://lemariva.com/\"><img src=\"https://avatars2.githubusercontent.com/u/15173329?v=4?s=100\" width=\"100px;\" alt=\"Mauro Riva\"/><br /><sub><b>Mauro Riva</b></sub></a><br /><a href=\"#blog-lemariva\" title=\"Blogposts\">📝</a> <a href=\"https://github.com/Josverl/micropython-stubber/issues?q=author%3Alemariva\" title=\"Bug reports\">🐛</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/MathijsNL\"><img src=\"https://avatars0.githubusercontent.com/u/1612886?v=4?s=100\" width=\"100px;\" alt=\"MathijsNL\"/><br /><sub><b>MathijsNL</b></sub></a><br /><a href=\"https://github.com/Josverl/micropython-stubber/issues?q=author%3AMathijsNL\" title=\"Bug reports\">🐛</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"http://comingsoon.tm/\"><img src=\"https://avatars0.githubusercontent.com/u/13251689?v=4?s=100\" width=\"100px;\" alt=\"Callum Jacob Hays\"/><br /><sub><b>Callum Jacob Hays</b></sub></a><br /><a href=\"https://github.com/Josverl/micropython-stubber/issues?q=author%3ACallumJHays\" title=\"Bug reports\">🐛</a> <a href=\"#test-CallumJHays\" title=\"Test\">✅</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/v923z\"><img src=\"https://avatars0.githubusercontent.com/u/1310472?v=4?s=100\" width=\"100px;\" alt=\"Zoltán Vörös\"/><br /><sub><b>Zoltán Vörös</b></sub></a><br /><a href=\"#data-v923z\" title=\"Data\">🔣</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/vincent-l-j\"><img src=\"https://avatars.githubusercontent.com/u/20021376?v=4?s=100\" width=\"100px;\" alt=\"vincent-l-j\"/><br /><sub><b>vincent-l-j</b></sub></a><br /><a href=\"https://github.com/Josverl/micropython-stubber/commits?author=vincent-l-j\" title=\"Documentation\">📖</a></td>\n    </tr>\n    <tr>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/yegorLitvinov\"><img src=\"https://avatars.githubusercontent.com/u/20367310?v=4?s=100\" width=\"100px;\" alt=\"Egor Litvinov\"/><br /><sub><b>Egor Litvinov</b></sub></a><br /><a href=\"https://github.com/Josverl/micropython-stubber/issues?q=author%3AyegorLitvinov\" title=\"Bug reports\">🐛</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/samskiter\"><img src=\"https://avatars.githubusercontent.com/u/1271643?v=4?s=100\" width=\"100px;\" alt=\"Sam Duke\"/><br /><sub><b>Sam Duke</b></sub></a><br /><a href=\"https://github.com/Josverl/micropython-stubber/commits?author=samskiter\" title=\"Code\">💻</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/hlovatt\"><img src=\"https://avatars.githubusercontent.com/u/8424169?v=4?s=100\" width=\"100px;\" alt=\"Howard Lovatt\"/><br /><sub><b>Howard Lovatt</b></sub></a><br /><a href=\"#stubs-hlovatt\" title=\"MicroPython stubs\">🖍️</a> <a href=\"#research-hlovatt\" title=\"Research\">🔬</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://virtualwolf.org/\"><img src=\"https://avatars.githubusercontent.com/u/1644623?v=4?s=100\" width=\"100px;\" alt=\"VirtualWolf\"/><br /><sub><b>VirtualWolf</b></sub></a><br /><a href=\"#test-VirtualWolf\" title=\"Test\">✅</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/lukaskremla\"><img src=\"https://avatars.githubusercontent.com/u/155779787?v=4?s=100\" width=\"100px;\" alt=\"Lukas Kremla\"/><br /><sub><b>Lukas Kremla</b></sub></a><br /><a href=\"#test-lukaskremla\" title=\"Test\">✅</a></td>\n    </tr>\n  </tbody>\n</table>\n\n<!-- markdownlint-restore -->\n<!-- prettier-ignore-end -->\n\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n\n----------------------------\n\n--------------------------------\n\n\n\n[stubs-repo]:   https://github.com/Josverl/micropython-stubs\n[stubs-repo2]:  https://github.com/BradenM/micropy-stubs\n[micropython-stubber]: https://github.com/Josverl/micropython-stubber\n[micropython-stubs]: https://github.com/Josverl/micropython-stubs#micropython-stubs\n[micropy-cli]: https://github.com/BradenM/micropy-cli\n[using-the-stubs]: https://github.com/Josverl/micropython-stubs#using-the-stubs\n[demo]:         https://github.com/Josverl/micropython-stubber/blob/main/docs/img/demo.gif?raw=true\t\"demo of writing code using the stubs\"\n[stub processing order]: https://github.com/Josverl/micropython-stubber/blob/main/docs/img/stuborder_pylance.png?raw=true\t\"recommended stub processing order\"\n[naming-convention]: #naming-convention-and-stub-folder-structure\n[all-stubs]: https://github.com/Josverl/micropython-stubs/blob/main/firmwares.md\n[micropython]: https://github.com/micropython/micropython\n[micropython-lib]:  https://github.com/micropython/micropython-lib\n[pycopy]: https://github.com/pfalcon/pycopy\n[pycopy-lib]: https://github.com/pfalcon/pycopy-lib\n\n"
}