Skip to content

Commit

Permalink
Hack to provide better pyi signature for init methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentMazare committed Sep 5, 2024
1 parent 3307824 commit de6493c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions py_src/sphn/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def write_wav(filename, data, sample_rate):
pass

class FileReader:
def __init__(path):
def __init__(self, path):
pass

@property
Expand Down Expand Up @@ -121,7 +121,7 @@ class FileReader:
pass

class OpusStreamReader:
def __init__(sample_rate):
def __init__(self, sample_rate):
pass

def append_bytes(self, data):
Expand All @@ -145,7 +145,7 @@ class OpusStreamReader:
pass

class OpusStreamWriter:
def __init__(sample_rate):
def __init__(self, sample_rate):
pass

def append_pcm(self, pcm):
Expand Down
5 changes: 4 additions & 1 deletion stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ def pyi_file(obj, indent=""):

# Init
if obj.__text_signature__:
body += f"{indent}def __init__{obj.__text_signature__}:\n"
ts = obj.__text_signature__
if len(ts) > 1 and ts.startswith("(") and not ts.startswith("(self"):
ts = "(self, " + ts[1:]
body += f"{indent}def __init__{ts}:\n"
body += f"{indent+INDENT}pass\n"
body += "\n"

Expand Down

0 comments on commit de6493c

Please sign in to comment.