Skip to content

Commit 09b4aa1

Browse files
committed
micropython/bundle-typing: Add bundle for typing modules.
Signed-off-by: Jos Verlinde <jos_verlinde@hotmail.com>
1 parent d75eb3c commit 09b4aa1

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# type: ignore[all]
2+
# Bundle to simplify including typing support in MicroPython projects.
3+
# This is not a full implementation of the typing module, but balances
4+
# functionality with code size, while ignoring type hints at runtime
5+
# to save resources.
6+
# Usage:
7+
# require("bundle-typing")
8+
# require("bundle-typing", extensions=True)
9+
10+
metadata(
11+
version="1.0.0",
12+
description="Limited runtime typing support for MicroPython.",
13+
)
14+
15+
options.defaults(opt_level=3, extensions=False)
16+
17+
# Primary typing related modules
18+
require("__future__", opt_level=options.opt_level)
19+
require("typing", opt_level=options.opt_level)
20+
require("typing_extensions", opt_level=options.opt_level)
21+
22+
# Optional typing modules
23+
if options.extensions:
24+
require("collections", opt_level=options.opt_level)
25+
require("collections-abc", opt_level=options.opt_level)
26+
require("abc", opt_level=options.opt_level)

0 commit comments

Comments
 (0)