From 43fd18935c44dae9528c2ef10d262243e9db7381 Mon Sep 17 00:00:00 2001 From: jops-wtakase <92840130+jops-wtakase@users.noreply.github.com> Date: Thu, 10 Oct 2024 15:48:02 +0900 Subject: [PATCH] [python-flask] Fix #19487 SyntaxWarning (#19489) * Bugfix: #19487: Fix SyntaxWarning * Fix a bug which generates SyntaxWarning * Chore: #19487: Generate sample --- .../src/main/resources/python-flask/model.mustache | 2 +- .../petstore/python-flask/openapi_server/models/category.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/python-flask/model.mustache b/modules/openapi-generator/src/main/resources/python-flask/model.mustache index 47394704bf9..bf1818f6c10 100644 --- a/modules/openapi-generator/src/main/resources/python-flask/model.mustache +++ b/modules/openapi-generator/src/main/resources/python-flask/model.mustache @@ -147,7 +147,7 @@ class {{classname}}(Model): {{/minimum}} {{#pattern}} if {{name}} is not None and not re.search(r'{{{vendorExtensions.x-regex}}}', {{name}}{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501 - raise ValueError("Invalid value for `{{name}}`, must be a follow pattern or equal to `{{{pattern}}}`") # noqa: E501 + raise ValueError(r"Invalid value for `{{name}}`, must be a follow pattern or equal to `{{{pattern}}}`") # noqa: E501 {{/pattern}} {{#maxItems}} if {{name}} is not None and len({{name}}) > {{maxItems}}: diff --git a/samples/server/petstore/python-flask/openapi_server/models/category.py b/samples/server/petstore/python-flask/openapi_server/models/category.py index 233e4db0d42..9f9805e6f38 100644 --- a/samples/server/petstore/python-flask/openapi_server/models/category.py +++ b/samples/server/petstore/python-flask/openapi_server/models/category.py @@ -86,6 +86,6 @@ class Category(Model): :type name: str """ if name is not None and not re.search(r'^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$', name): # noqa: E501 - raise ValueError("Invalid value for `name`, must be a follow pattern or equal to `/^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$/`") # noqa: E501 + raise ValueError(r"Invalid value for `name`, must be a follow pattern or equal to `/^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$/`") # noqa: E501 self._name = name