From ee58564201f082de128980d36903b59cde13935e Mon Sep 17 00:00:00 2001 From: Ekin Dursun Date: Wed, 8 May 2024 15:47:51 +0300 Subject: [PATCH] Escape backslashes in docstrings Python 3.12 gives a `SyntaxWarning: invalid escape sequence` when it sees an unescaped backslash. --- src/aaz_dev/cli/templates/aaz/command/_cmd.py.j2 | 4 ++-- src/aaz_dev/cli/templates/aaz/group/__cmd_group.py.j2 | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/aaz_dev/cli/templates/aaz/command/_cmd.py.j2 b/src/aaz_dev/cli/templates/aaz/command/_cmd.py.j2 index d7e2bd38..5b1dcd53 100644 --- a/src/aaz_dev/cli/templates/aaz/command/_cmd.py.j2 +++ b/src/aaz_dev/cli/templates/aaz/command/_cmd.py.j2 @@ -34,10 +34,10 @@ class {{ leaf.cls_name }}( AAZCommand {%- endif -%} ): - """{{ leaf.help.short }} + """{{ leaf.help.short|replace('\\', '\\\\') }} {%- if leaf.help.long is not none and leaf.help.long|length %} - {{ leaf.help.long.split('\n')|join('\n ') }} + {{ leaf.help.long.split('\n')|join('\n ')|replace('\\', '\\\\') }} {%- endif %} {%- if leaf.help.examples is not none and leaf.help.examples|length %} {%- for example in leaf.help.examples %} diff --git a/src/aaz_dev/cli/templates/aaz/group/__cmd_group.py.j2 b/src/aaz_dev/cli/templates/aaz/group/__cmd_group.py.j2 index e9662383..0a17f52c 100644 --- a/src/aaz_dev/cli/templates/aaz/group/__cmd_group.py.j2 +++ b/src/aaz_dev/cli/templates/aaz/group/__cmd_group.py.j2 @@ -22,10 +22,10 @@ from azure.cli.core.aaz import * ) {%- endif %} class __CMDGroup(AAZCommandGroup): - """{{ node.help.short }} + """{{ node.help.short|replace('\\', '\\\\') }} {%- if node.help.long is not none and node.help.long|length %} - {{ node.help.long.split('\n')|join('\n ') }} + {{ node.help.long.split('\n')|join('\n ')|replace('\\', '\\\\') }} {%- endif %} """ pass