Giter Club home page Giter Club logo

micropython-test-stubs's Introduction

esp32-test-stubs

Sample PoC of PyPi packaging PEP-561 stubs for Micropython Esp32.

As it is only "proof-of-concept" it NOT assumed to for production use and package can be deleted in the future. Another purspose of this project is collect info about stubbing

For the production implementation please see:

Installation

pip3 install esp32-test-stubs

Script

Next script correct working in PyCharm for autocompete and analyzing with only installed stub package via standart pip command. All types does not show any warnings and recognized properly:

import machine
machine.freq()

import esp32
esp32.NVS()
esp32.wake_on_ext0("Test")

from esp.sub_pkg import sub_pkg_fun
sub_pkg_fun()

from esp32.sub_pkg import sub_pkg_function
sub_pkg_function()

import uuid

# Points to stdlib
uuid.uuid4()

# Points to stub (mean partial stub, so extent stdlib)
# (see uuid-stubs and py.typed)
uuid.uuid6()

import upip
upip.cleanup()

Stubs possible locations

  • Project root *.pyi files
  • <package>-stubs with __init__.pyi (see stub-only packages)
  • <package>-stubs/<sub_package>.pyi (see stub-only-packages)
  • "custom folders" (Not recommended) - like src, marked as package = [{ include = "*.pyi" , from = "src"}], under hood all *.pyi will be moved into package root during package build.
    CONS:
    • "custom folders" does not recognize as stub source before stub package will pack properly.
    • stubs not moved properly in in target *.tar.gz build, so it led to potential errors during stub recognition from pure sources.

Note: all of these variants should be explicitly marked in pyproject.toml in Poetry (see package section pyproject.toml)

Poetry commands

  • Prepare

    poetry config repositories.testpypi https://test.pypi.org/legacy/
    poetry config pypi-token.testpypi <TOKEN>
    
    poetry config repositories.pypi https://upload.pypi.org/legacy/
    poetry config pypi-token.pypi <TOKEN>
  • Publish

    poetry publish --build -r testpypi
    poetry publish --build -r pypi

Stub lib examples

Links

Footnotes

micropython-test-stubs's People

Contributors

mrkeuz avatar josverl avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.