]> Repositories - Adafruit_Blinka-hackapet.git/commitdiff
Make micropython.const accept any constant type
authorGeorge Waters <gwatersdev@gmail.com>
Mon, 14 Jul 2025 15:20:32 +0000 (11:20 -0400)
committerGeorge Waters <gwatersdev@gmail.com>
Mon, 14 Jul 2025 15:20:32 +0000 (11:20 -0400)
micropython.const now supports any constant type, not just int. This
updates the type checking to reflect this. This also updates the name of
the file so that type checkers can find it.

src/micropython-stubs/__init__.pyi [moved from src/micropython-stubs/micropython.pyi with 95% similarity]

similarity index 95%
rename from src/micropython-stubs/micropython.pyi
rename to src/micropython-stubs/__init__.pyi
index 33dd6a9821ecd0dbe297d312f6743480a89aab32..5026b979322a398a523ae4c86feb8b1a27479667 100644 (file)
@@ -12,7 +12,7 @@ from typing import Callable, TypeVar, Any, NoReturn
 
 Fun = TypeVar("Fun", bound=Callable[..., Any])
 
 
 Fun = TypeVar("Fun", bound=Callable[..., Any])
 
-def const(x: int) -> int:
+def const[T](x: T) -> T:
     "Emulate making a constant"
 
 def native(f: Fun) -> Fun:
     "Emulate making a constant"
 
 def native(f: Fun) -> Fun: