Skip to content

Commit

Permalink
Fixed stub parsing for Pylance. Thanks to numpy project for a minute …
Browse files Browse the repository at this point in the history
…detail around it
  • Loading branch information
themarpe committed Jun 1, 2022
1 parent fbafc41 commit 6f614ac
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion generate_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import re
import tempfile
import os
import textwrap

# Usage
if len(sys.argv) < 3:
Expand Down Expand Up @@ -32,7 +33,15 @@
contents = file.read()

# Add imports
stubs_import = 'import depthai.node as node\nimport typing\nimport json\n' + contents
stubs_import = textwrap.dedent('''
# Ensures that the stubs are picked up - thanks, numpy project
from depthai import (
node as node,
)
import typing
import json
''') + contents

# Create 'create' overloads
nodes = re.findall('def \S*\(self\) -> node.(\S*):', stubs_import)
Expand Down

0 comments on commit 6f614ac

Please sign in to comment.