You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When I run the python-flask generator, some generated models output SyntaxWarning in Python 3.12. This issue is caused by the {{{pattern}}} in the line here, which may contain a backslash (\), making the string a potential source of warnings.
Introduced feature in Python 3.12
Starting from Python 3.12, a backslash-character pair generates a SyntaxWarning instead of a DeprecationWarning. In future Python versions, this will be escalated to a SyntaxError.
docker run -v /tmp/example/example/models/example.py:/example.py -w /models --rm python:3.12-alpine python -Wa -m py_compile /example.py
/example.py:63: SyntaxWarning: invalid escape sequence '\.'
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
Related issues/PRs
None found. Searched using the keyword SyntaxWarning, but no relevant issues/PRs were identified.
Suggest a fix
Modify the line in modules/openapi-generator/src/main/resources/python-flask/model.mustache from:
raise ValueError("Invalid value for `{{name}}`, must be a follow pattern or equal to `{{{pattern}}}`") # noqa: E501
to:
raise ValueError(r"Invalid value for `{{name}}`, must be a follow pattern or equal to `{{{pattern}}}`") # noqa: E501
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
Description
When I run the
python-flask
generator, some generated models outputSyntaxWarning
in Python 3.12. This issue is caused by the{{{pattern}}}
in the line here, which may contain a backslash (\
), making the string a potential source of warnings.Introduced feature in Python 3.12
Starting from Python 3.12, a backslash-character pair generates a
SyntaxWarning
instead of aDeprecationWarning
. In future Python versions, this will be escalated to aSyntaxError
.openapi-generator version
Latest master branch (1518237)
OpenAPI declaration file content or url
example.yaml
Generation Details
Steps to reproduce
Related issues/PRs
None found. Searched using the keyword SyntaxWarning, but no relevant issues/PRs were identified.
Suggest a fix
Modify the line in
modules/openapi-generator/src/main/resources/python-flask/model.mustache
from:to:
The text was updated successfully, but these errors were encountered: