[Python] Do not use mutable default argument#4613
[Python] Do not use mutable default argument#4613jirikuncar wants to merge 8 commits intoOpenAPITools:masterfrom
Conversation
512c7c4 to
31c80b6
Compare
modules/openapi-generator/src/main/resources/python/configuration.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/python/configuration.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/python/configuration.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/python/configuration.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/python/configuration.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/python/configuration.mustache
Outdated
Show resolved
Hide resolved
b0dec03 to
6b058b7
Compare
|
@spacether thank you for the review. I have cleaned up the configuration template even more based on your suggestions. |
modules/openapi-generator/src/main/resources/python/configuration.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/python/configuration.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/python/configuration.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/python/configuration.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/python/configuration.mustache
Outdated
Show resolved
Hide resolved
6b058b7 to
2808b6d
Compare
2808b6d to
da67f9f
Compare
According to @spacether it is better to document only property getter with combined signature of both getter and setter instead of individual getters and setters.
|
@jirikuncar it sounds like there may have been a misunderstanding here. My comments were asking that you preserve the docstring information from the setters as you were deleting the types shown there. I also give a reason why the docstring for both the getter and the setter exists in the getter. In my opinion having the docstring in the getter + setter is helpful for the following reasons. As a dev I want to be able to:
If you want to delete the setter docstrings I am okay with that as long as the needed information still exists in the getter docstrings. |
|
|
||
| @property | ||
| def debug(self): | ||
| """Debug status |
There was a problem hiding this comment.
Please add a type description to this docstring
We are losing the information when we delete it from the setter
There was a problem hiding this comment.
@spacether I don't get your comment.
@property
def debug(self):
"""The debug status.
:param value: The debug status, True or False.
:type: bool
"""There was a problem hiding this comment.
Sorry, my mistake, I missed the remaining bool type here. This is good.
|
@jirikuncar can you check out the Travis CI error here? |
|
I might revisit this one in the future by updating docstrings to follow PEP 257 ( A minimal changed for mutable defaults has been moved to #4665. |
Avoid using mutable default arguments in Python.
PR checklist
./bin/(or Windows batch scripts under.\bin\windows) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run./bin/{LANG}-petstore.sh,./bin/openapi3/{LANG}-petstore.shif updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).master,4.3.x,5.0.x. Default:master.--
cc @taxpon (2017/07) @frol (2017/07) @mbohlool (2017/07) @cbornet (2017/09) @kenjones-cisco (2017/11) @tomplus (2018/10) @Jyhess (2019/01) @slash-arun (2019/11) @spacether (2019/11)