Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] add float to reserved word list #16689

Merged
merged 8 commits into from
Oct 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
generatorName: python
outputDir: samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true
inputSpec: modules/openapi-generator/src/test/resources/3_0/python/echo_api.yaml
inputSpec: modules/openapi-generator/src/test/resources/3_0/echo_api.yaml
templateDir: modules/openapi-generator/src/main/resources/python
additionalProperties:
hideGenerationTimestamp: "true"
Expand Down
2 changes: 1 addition & 1 deletion bin/configs/python-echo-api.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
generatorName: python
outputDir: samples/client/echo_api/python
inputSpec: modules/openapi-generator/src/test/resources/3_0/python/echo_api.yaml
inputSpec: modules/openapi-generator/src/test/resources/3_0/echo_api.yaml
templateDir: modules/openapi-generator/src/main/resources/python
additionalProperties:
hideGenerationTimestamp: "true"
5 changes: 5 additions & 0 deletions docs/generators/python-aiohttp.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>async</li>
<li>auth_settings</li>
<li>await</li>
<li>base64</li>
<li>body_params</li>
<li>break</li>
<li>class</li>
<li>continue</li>
<li>date</li>
<li>def</li>
<li>del</li>
<li>elif</li>
Expand All @@ -90,6 +92,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>exec</li>
<li>false</li>
<li>finally</li>
<li>float</li>
<li>for</li>
<li>form_params</li>
<li>from</li>
Expand All @@ -99,6 +102,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>import</li>
<li>in</li>
<li>is</li>
<li>json</li>
<li>lambda</li>
<li>local_var_files</li>
<li>none</li>
Expand All @@ -113,6 +117,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>raise</li>
<li>resource_path</li>
<li>return</li>
<li>schema</li>
<li>self</li>
<li>true</li>
<li>try</li>
Expand Down
5 changes: 5 additions & 0 deletions docs/generators/python-blueplanet.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>async</li>
<li>auth_settings</li>
<li>await</li>
<li>base64</li>
<li>body_params</li>
<li>break</li>
<li>class</li>
<li>continue</li>
<li>date</li>
<li>def</li>
<li>del</li>
<li>elif</li>
Expand All @@ -90,6 +92,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>exec</li>
<li>false</li>
<li>finally</li>
<li>float</li>
<li>for</li>
<li>form_params</li>
<li>from</li>
Expand All @@ -99,6 +102,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>import</li>
<li>in</li>
<li>is</li>
<li>json</li>
<li>lambda</li>
<li>local_var_files</li>
<li>none</li>
Expand All @@ -113,6 +117,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>raise</li>
<li>resource_path</li>
<li>return</li>
<li>schema</li>
<li>self</li>
<li>true</li>
<li>try</li>
Expand Down
5 changes: 5 additions & 0 deletions docs/generators/python-fastapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>async</li>
<li>auth_settings</li>
<li>await</li>
<li>base64</li>
<li>body_params</li>
<li>break</li>
<li>class</li>
<li>continue</li>
<li>date</li>
<li>def</li>
<li>del</li>
<li>elif</li>
Expand All @@ -85,6 +87,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>exec</li>
<li>false</li>
<li>finally</li>
<li>float</li>
<li>for</li>
<li>form_params</li>
<li>from</li>
Expand All @@ -94,6 +97,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>import</li>
<li>in</li>
<li>is</li>
<li>json</li>
<li>lambda</li>
<li>local_var_files</li>
<li>none</li>
Expand All @@ -108,6 +112,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>raise</li>
<li>resource_path</li>
<li>return</li>
<li>schema</li>
<li>self</li>
<li>true</li>
<li>try</li>
Expand Down
5 changes: 5 additions & 0 deletions docs/generators/python-flask.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>async</li>
<li>auth_settings</li>
<li>await</li>
<li>base64</li>
<li>body_params</li>
<li>break</li>
<li>class</li>
<li>continue</li>
<li>date</li>
<li>def</li>
<li>del</li>
<li>elif</li>
Expand All @@ -90,6 +92,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>exec</li>
<li>false</li>
<li>finally</li>
<li>float</li>
<li>for</li>
<li>form_params</li>
<li>from</li>
Expand All @@ -99,6 +102,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>import</li>
<li>in</li>
<li>is</li>
<li>json</li>
<li>lambda</li>
<li>local_var_files</li>
<li>none</li>
Expand All @@ -113,6 +117,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>raise</li>
<li>resource_path</li>
<li>return</li>
<li>schema</li>
<li>self</li>
<li>true</li>
<li>try</li>
Expand Down
10 changes: 10 additions & 0 deletions docs/generators/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,15 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## RESERVED WORDS

<ul class="column-ul">
<li>all_params</li>
<li>and</li>
<li>as</li>
<li>assert</li>
<li>async</li>
<li>auth_settings</li>
<li>await</li>
<li>base64</li>
<li>body_params</li>
<li>break</li>
<li>class</li>
<li>continue</li>
Expand All @@ -86,23 +89,30 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>exec</li>
<li>false</li>
<li>finally</li>
<li>float</li>
<li>for</li>
<li>form_params</li>
<li>from</li>
<li>global</li>
<li>header_params</li>
<li>if</li>
<li>import</li>
<li>in</li>
<li>is</li>
<li>json</li>
<li>lambda</li>
<li>local_var_files</li>
<li>none</li>
<li>nonlocal</li>
<li>not</li>
<li>or</li>
<li>pass</li>
<li>path_params</li>
<li>print</li>
<li>property</li>
<li>query_params</li>
<li>raise</li>
<li>resource_path</li>
<li>return</li>
<li>schema</li>
<li>self</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ public AbstractPythonCodegen() {
"header_params", "form_params", "local_var_files", "body_params", "auth_settings",
// @property
"property",
// typing keywords
"schema", "base64", "json",
"date", "float",
// python reserved words
"and", "del", "from", "not", "while", "as", "elif", "global", "or", "with",
"assert", "else", "if", "pass", "yield", "break", "except", "import",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,6 @@ public PythonClientCodegen() {
// default HIDE_GENERATION_TIMESTAMP to true
hideGenerationTimestamp = Boolean.TRUE;

// from https://docs.python.org/3/reference/lexical_analysis.html#keywords
setReservedWordsLowerCase(
Arrays.asList(
// pydantic keyword
"schema", "base64", "json",
"date",
// @property
"property",
// python reserved words
"and", "del", "from", "not", "while", "as", "elif", "global", "or", "with",
"assert", "else", "if", "pass", "yield", "break", "except", "import",
"print", "class", "exec", "in", "raise", "continue", "finally", "is",
"return", "def", "for", "lambda", "try", "self", "nonlocal", "None", "True",
"False", "async", "await"));

cliOptions.clear();
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "python package name (convention: snake_case).")
.defaultValue("openapi_client"));
Expand Down
Loading