Skip to main content

Provide stubs with documentation for the MicroPython running on Calliope Mini

Project description

CalliopeMini Stubs

Use this library to develop your python programs for the Calliope Mini using a state-of-the-art python IDE such as Visual Studio Code on your computer.

This library only helps by providing documentation, type annotations and function signatures. It does not contain a simulator/emulator and it does not allow to transfer the developed code to the Calliope Mini.

Setup VSCode

  • Install the ms-python.python extension.
  • pip install calliope-mini-stubs to get this package installed.
  • Select the correct python (e.g. if you pip installed into a virtual environment, chose the python from there).

Now you can create a file and begin it with from calliope_mini import display and upon typing display.sh you should see display.show as proposal and if you select it the help text for display.show.

To make more of the extension:

Tutorial

  1. Create a virtual environment

     % python3 -m venv --system-site-packages venv
    
  2. Activate it (python, pip, etc will be found in this directory from now on)

     % source ./venv/bin/activate
    
  3. Verify, that you are using this virtual envirnonment -- which python3 should generate something like this

     % which python3
     <path where you work>/venv/bin/python3
    
  4. Install this package

     % python3 -m pip install --upgrade calliope-mini-stubs
     Looking in indexes: ....
     Collecting calliope-mini-stubs
       Downloading https://....
     Installing collected packages: calliope-mini-stubs
     Successfully installed calliope-mini-stubs-<version>
    
  5. Launch Visual Studio Code

     % code .
    
  6. Create a new python file, for example hello_world.py.

  7. Make sure, that the correct interpreter is used. On the lower left corner of VSCode you should see the python from venv selected:

    VSCode displaying the current version of python used

    If this is not the correct one, then select the right interpreter. To do so:

    • run Ctrl + Shift + P and type Python: Select Interpreter

      VSCode prompt to enter the path to python

    • then type ./venv/bin/python and select that.

  8. In your python file, start typing, e.g. import calliope_mini. During typing, you should already get calliope_mini proposed. IntelliSense allows VSCode to give you hints on what objects/methods/... you can select in this place

    Intellisense proposes buttons A and B to chose from

    and VSCode can directly display the documentation for the method you currently use (e.g. the function signature and a human readable description)

    Intellisense shows radio documentation

License

This package is licensed under MIT license. See the LICENSE file.

It uses code from the package pseudo-microbit which is also MIT licensed (same as this package) with the copyright notice

Copyright (c) 2013-2016 The MicroPython-on-micro:bit Developers, as listed
in the accompanying AUTHORS file

Currently missing in this library

  • in module calliope_mini
    • i2c
    • uart
    • spi
  • module random

On Stub Files

Generatlly, stubs should be distributed in the form of .pyi files -- one .pyi with documentation/typing informatino for each .py file.

PEP 484 describes, how the .pyi files should look like.

PEP 561 describes, how to distribute them:

  • The package needs to be named foopkg-stubs for package foopkg
  • A file py.typed must be installed in the top-level of the package.

Problems

  • pylint does not recognize __init__.pyi files: https://github.com/PyCQA/pylint/issues/2873 This way, if you declare modules with interfaces only, pylint will display the error undefined variable ... or no ... in module .... (vscode will correctly show the methods/docstrings/..., though!) -> Solution: Use .py files instead of .pyi files.
  • static values such as Image.HAPPY are neither autocompleted nor properly recognized as type (i.e. a in a = Image.HEART is not detected as Image (or MicroBitImage)). If Image were an instance it would work... See the question how to get that working.

Working Examples for .pyi files

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

calliope-mini-stubs-0.0.4.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

calliope_mini_stubs-0.0.4-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file calliope-mini-stubs-0.0.4.tar.gz.

File metadata

  • Download URL: calliope-mini-stubs-0.0.4.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for calliope-mini-stubs-0.0.4.tar.gz
Algorithm Hash digest
SHA256 2a4313907e7183180394bb10158719e998a0540f274a78cf3ef7e5354582d356
MD5 f81f07e406d38e5d59fe9994484aa6fe
BLAKE2b-256 634a0ffe9455df7d328e9314342c98e9edd02a3d052d66b1cbbd009c7ef99a6a

See more details on using hashes here.

File details

Details for the file calliope_mini_stubs-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: calliope_mini_stubs-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for calliope_mini_stubs-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 dab4e774d398c8d08ad92b76f5d82b003761f137198fbfb07279b584a0e17791
MD5 7a92a1edf8de402f002e4e86884ff841
BLAKE2b-256 74e2fcb4c508d704c5fcb400b6353e1f1e3437d12f96dac9bed0801947c680b6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page