Skip to content

Commit e14a2a0

Browse files
Tinyu-Zhaolbuque
authored andcommitted
tools: Add stub file generation script.
Signed-off-by: [email protected] <[email protected]>
1 parent 1e6800d commit e14a2a0

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

pyrightconfig.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"include": [
3+
"m5stack/**"
4+
],
5+
"exclude": [],
6+
"ignore": [],
7+
"defineConstant": {
8+
"DEBUG": true
9+
},
10+
"stubPath": "stubs",
11+
"reportMissingImports": "error",
12+
"reportMissingTypeStubs": false,
13+
"executionEnvironments": [
14+
{
15+
"root": "./",
16+
"reportMissingImports": "warning"
17+
},
18+
]
19+
}

tools/gen_stubs.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
from pathlib import Path
6+
import sys, shutil, subprocess
7+
8+
r = Path(sys.argv[1]) if len(sys.argv) > 1 else Path(__file__).resolve().parent.parent
9+
s = r / "stubs"
10+
l = r / "m5stack/libs"
11+
12+
if s.exists():
13+
shutil.rmtree(s)
14+
s.mkdir()
15+
16+
for p in sorted(l.iterdir()):
17+
if p.is_dir() and not p.name.startswith("__"):
18+
subprocess.run(["pyright", "--createstub", f"m5stack.libs.{p.name}"], cwd=r)

0 commit comments

Comments
 (0)