]> Repositories - Adafruit_Blinka-hackapet.git/commitdiff
Merge pull request #610 from adafruit/micropython-pyi 8.2.2
authorMelissa LeBlanc-Williams <melissa@adafruit.com>
Wed, 7 Sep 2022 14:58:34 +0000 (07:58 -0700)
committerGitHub <noreply@github.com>
Wed, 7 Sep 2022 14:58:34 +0000 (07:58 -0700)
Provide stubs for micropython module in a more clearly compatible way

setup.py
src/micropython-stubs/micropython.pyi [new file with mode: 0644]

index 67ef7ee4c7d30cf86fa36f2fabb0affb246ae53d..51df79116680efa093914aed56b6012cecd2620b 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -52,7 +52,7 @@ setup(
     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=[
@@ -74,8 +74,10 @@ setup(
         "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",
diff --git a/src/micropython-stubs/micropython.pyi b/src/micropython-stubs/micropython.pyi
new file mode 100644 (file)
index 0000000..33dd6a9
--- /dev/null
@@ -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"