Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/stubgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,17 @@ def put_function(self, fn: Callable[..., Any], name: Optional[str] = None, paren
overload = self.import_object("typing", "overload")
self.write_ln(f"@{overload}")

sig_str = f"{name}{self.signature_str(signature(fno))}"
try:
sig = signature(fno)
except ValueError:
sig = None

if sig is not None:
sig_str = f"{name}{self.signature_str(sig)}"
else:
# If inspect.signature fails, use a maximally permissive type.
any_type = self.import_object("typing", "Any")
sig_str = f"{name}(*args, **kwargs) -> {any_type}"

# Potentially copy docstring from the implementation function
docstr = fno.__doc__
Expand Down