[Python] Improve model equality implementation#4663
Merged
wing328 merged 2 commits intoswagger-api:masterfrom Jan 27, 2017
mailmojo:fix-python-model-eq
Merged
[Python] Improve model equality implementation#4663wing328 merged 2 commits intoswagger-api:masterfrom mailmojo:fix-python-model-eq
wing328 merged 2 commits intoswagger-api:masterfrom
mailmojo:fix-python-model-eq
Conversation
The model equality implementation template blindly tried accessing the `__dict__` attribute of the variable to compare equality against. This attribute does not exist for a lot of Python built-in types (`None`, `str` etc.) and the equality check would simply crash. This adds a simple guard to only continue with equality check if the variable to compare is an instance of the model being compared against.
Contributor
|
@fdanielsen thanks for the PR. The change looks good to me. I'll merge it later today if no one has any feedback/question. cc @scottrw93 |
Contributor
|
This PR looks good to me also. |
Contributor
|
@frol thanks for reviewing the change 👍 PR merged into master. Thanks for the contribution from @fdanielsen |
davidgri
pushed a commit
to davidgri/swagger-codegen
that referenced
this pull request
May 11, 2017
* [Python] Improve model equality implementation The model equality implementation template blindly tried accessing the `__dict__` attribute of the variable to compare equality against. This attribute does not exist for a lot of Python built-in types (`None`, `str` etc.) and the equality check would simply crash. This adds a simple guard to only continue with equality check if the variable to compare is an instance of the model being compared against. * Remove wrong auto-update of Python requirements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The model equality implementation template blindly tried accessing the
__dict__attribute of the variable to compare equality against. This attribute does not exist for a lot of Python built-in types (None,stretc.) and the equality check would simply crash.This adds a simple guard to only continue with equality check if the variable to compare is an instance of the model being compared against.
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.shand./bin/security/{LANG}-petstore.shif updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates)2.3.0branch for breaking (non-backward compatible) changes.Description of the PR
Simple update to the Python model mustache template to improve model equality check implementation.