From 352ab8829525435f78838687e12156a3fa3a3d86 Mon Sep 17 00:00:00 2001 From: James Addison Date: Sat, 8 Apr 2023 22:21:23 +0100 Subject: [PATCH] tooling: write_pyi.py: only emit raw docstrings when the original docstring contains unprintable and/or backslash (escape marker) characters --- tools/write_pyi.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/write_pyi.py b/tools/write_pyi.py index fcf9d363..4fbf3661 100644 --- a/tools/write_pyi.py +++ b/tools/write_pyi.py @@ -218,7 +218,8 @@ def _generate_stub_for_meth( fn_doc = base_method.__doc__ if base_method else fn.__doc__ has_docs = gen_docs and fn_doc is not None - docs = 'r"""' + f"{fn_doc}" + '"""' if has_docs else "" + string_prefix = "r" if chr(92) in fn_doc else "" + docs = f'{string_prefix}"""' + f"{fn_doc}" + '"""' if has_docs else "" func_text = textwrap.dedent( f""" -- 2.47.3