]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
tooling: write_pyi.py: only emit raw docstrings when the original docstring contains... 1218/head
authorJames Addison <james@reciperadar.com>
Sat, 8 Apr 2023 21:21:23 +0000 (22:21 +0100)
committerJames Addison <james@reciperadar.com>
Sun, 9 Apr 2023 20:57:55 +0000 (21:57 +0100)
tools/write_pyi.py

index fcf9d36307d112e6e4f8f4378a47319ee6e54792..4fbf36617ae2cfb54b401477d9ab5d736aac3409 100644 (file)
@@ -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"""