Generating Python Stubs for MaixPy (For autocompletion in IDEs e.g, Pycharm).

Hi All,
Recently I found this project useful for developerts using Micropython.
It can generate .py files for autocompletion (function names, as presented in REPL). I put them in a folder and mark as Sources Root in Pycharm for autocompletion.

Steps to produce the stubs:

  1. Clone the micropython-stubber project or simply download and
  2. Modify the
    • Modify the path (Since /flash is not supported for folders):
      Line 355: stubber = Stubber(path='/sd')
    • Add additional modules for Maixpy:
      Append the modules after Line 62: self.modules.extend(['Maix','board','fpioa_manager','lcd','sensor','image','video','touchscreen','pye_mp','nes','lvgl'])
  3. Upload and to /sd
  4. REPL -> import createstubs (and wait for around 30 seconds).
  5. Download the files from your SD card

I also uploaded the stubs generated from my MaixGo (w/ lvgl). You can use it directly. (37.4 KB)


1 Like

nice work!