forked from loafle/openapi-generator-original
[Python] Improve model equality implementation (#4663)
* [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 commit is contained in:
@@ -172,6 +172,9 @@ class {{classname}}(object):
|
||||
"""
|
||||
Returns true if both objects are equal
|
||||
"""
|
||||
if not isinstance(other, {{classname}}):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
|
||||
def __ne__(self, other):
|
||||
|
||||
Reference in New Issue
Block a user