Skip to content

Commit 8cdc67a

Browse files
authored
Merge pull request #2 from tannewt/improve_verification
Better handle //| and do __init__.c first.
2 parents c7b721f + 8c77252 commit 8cdc67a

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

tools/extract_pyi.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,22 @@
2020
if not os.path.isdir(module_path):
2121
continue
2222
pyi_lines = []
23-
for class_file in os.listdir(module_path):
23+
classes = os.listdir(module_path)
24+
classes = [x for x in sorted(classes) if x.endswith(".c")]
25+
if classes[-1] == "__init__.c":
26+
classes.insert(0, classes.pop())
27+
for class_file in classes:
2428
class_path = os.path.join(module_path, class_file)
2529
with open(class_path, "r") as f:
2630
for line in f:
27-
if line.startswith("//| "):
28-
pyi_lines.append(line[4:])
31+
if line.startswith("//|"):
32+
if line[3] == " ":
33+
line = line[4:]
34+
elif line[3] == "\n":
35+
line = line[3:]
36+
else:
37+
continue
38+
pyi_lines.append(line)
2939

3040
stub_filename = os.path.join(stub_directory, module + ".pyi")
3141
print(stub_filename)

0 commit comments

Comments
 (0)