Skip to content

Commit 76e292f

Browse files
committed
Fixed stub generation
1 parent e043880 commit 76e292f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

generate_stubs.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
MODULE_NAME = sys.argv[1]
1313
DIRECTORY = sys.argv[2]
1414

15-
print(f'Generating stubs for module: {MODULE_NAME} in directory: {DIRECTORY}')
15+
print(f'Generating stubs for module: "{MODULE_NAME}" in directory: "{DIRECTORY}"')
1616

1717
try:
1818

@@ -33,14 +33,18 @@
3333

3434
# Add imports
3535
stubs_import = 'import depthai.node as node\nimport typing\nimport json\n' + contents
36+
3637
# Create 'create' overloads
3738
nodes = re.findall('def \S*\(self\) -> node.(\S*):', stubs_import)
3839
overloads = ''
3940
for node in nodes:
4041
overloads = overloads + f'\\1@overload\\1def create(self, arg0: typing.Type[node.{node}]) -> node.{node}: ...'
41-
#print(f'{overloads}')
4242
final_stubs = re.sub(r"([\s]*)def create\(self, arg0: object\) -> Node: ...", f'{overloads}', stubs_import)
4343

44+
# Modify "*View" naming
45+
nodes = re.findall('View\\[(\S*)\\]', final_stubs)
46+
final_stubs = re.sub(r"View\[(\S*)\]", f'View_\\1', final_stubs)
47+
4448
# Writeout changes
4549
file.seek(0)
4650
file.write(final_stubs)

0 commit comments

Comments
 (0)