Skip to content

Commit

Permalink
Merge pull request #610 from adafruit/micropython-pyi
Browse files Browse the repository at this point in the history
Provide stubs for micropython module in a more clearly compatible way
  • Loading branch information
makermelissa authored Sep 7, 2022
2 parents ad1ec71 + 22b67a2 commit b2e4f60
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
python_requires=">=3.7.0",
url="https://github.com/adafruit/Adafruit_Blinka",
package_dir={"": "src"},
packages=find_packages("src"),
packages=find_packages("src") + ["micropython-stubs"],
# py_modules lists top-level single file packages to include.
# find_packages only finds packages in directories with __init__.py files.
py_modules=[
Expand All @@ -74,8 +74,10 @@
"adafruit_blinka.microcontroller.bcm283x.pulseio": [
"libgpiod_pulsein",
"libgpiod_pulsein64",
]
],
"micropython-stubs": ["*.pyi"],
},
include_package_data=True,
install_requires=[
"Adafruit-PlatformDetect>=3.13.0",
"Adafruit-PureIO>=1.1.7",
Expand Down
25 changes: 25 additions & 0 deletions src/micropython-stubs/micropython.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""
`micropython` - MicroPython Specific Decorator Functions
========================================================
* Author(s): cefn
"""

from typing import Callable, TypeVar, Any, NoReturn

Fun = TypeVar("Fun", bound=Callable[..., Any])

def const(x: int) -> int:
"Emulate making a constant"

def native(f: Fun) -> Fun:
"Emulate making a native"

def viper(f: Fun) -> NoReturn:
"User is attempting to use a viper code emitter"

def asm_thumb(f: Fun) -> NoReturn:
"User is attempting to use an inline assembler"

0 comments on commit b2e4f60

Please sign in to comment.