Skip to content

Commit d4b245a

Browse files
authored
stubgen.py: enhance 'param_str' method to handle default value that is a nanobind object (#1024)
1 parent 3537332 commit d4b245a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/stubgen.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,10 @@ def param_str(self, p: Parameter) -> str:
10641064
if has_def:
10651065
result += " = " if has_type else "="
10661066
p_default_str = self.expr_str(p.default)
1067+
if p_default_str is None:
1068+
# self.expr_str(p.default) could return None in some rare cases,
1069+
# e.g. p.default is a nanobind object. If so, use ellipsis as a placeholder.
1070+
p_default_str = "..."
10671071
assert p_default_str
10681072
result += p_default_str
10691073
return result

0 commit comments

Comments
 (0)