]> Repositories - Adafruit_Blinka-hackapet.git/blob - src/micropython/__init__.py
Add typing information to micropython
[Adafruit_Blinka-hackapet.git] / src / micropython / __init__.py
1 # SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
2 #
3 # SPDX-License-Identifier: MIT
4 """
5 `micropython` - MicroPython Specific Decorator Functions
6 ========================================================
7
8 * Author(s): cefn
9 """
10
11 from typing import Callable, TypeVar, Any
12
13 Fun = TypeVar("Fun", bound=Callable[..., Any])
14
15
16 def const(x: int) -> int:
17     "Emulate making a constant"
18     return x
19
20
21 def native(f: Fun) -> Fun:
22     "Emulate making a native"
23     return f
24
25
26 def viper(f: Fun) -> None:
27     "User is attempting to use a viper code emitter"
28     raise SyntaxError("invalid micropython decorator")
29
30
31 def asm_thumb(f: Fun) -> None:
32     "User is attempting to use an inline assembler"
33     raise SyntaxError("invalid micropython decorator")