Skip to content

Commit f7ed277

Browse files
committed
Fix: Avoid generating invalid stubs syntax in case if description ends with '
1 parent 5d6af26 commit f7ed277

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/fake_bpy_module/generator/writers.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,11 @@ def _write_class_code(self, class_node: ClassNode) -> None:
491491
if (not desc_node.empty()) or (dtype_str is not None):
492492
wt.add("''' ")
493493
if not desc_node.empty():
494-
wt.add(f"{desc_node.astext()}")
494+
desc_text = desc_node.astext()
495+
wt.add(f"{desc_text}")
496+
# Add space to avoid syntax error with 4 single quotes in a row.
497+
if dtype_str is None and desc_text.endswith("'"):
498+
wt.add(' ')
495499
if dtype_str is not None:
496500
wt.new_line(2)
497501
wt.addln(f":type: {dtype_str}")

0 commit comments

Comments
 (0)