mirror of
https://github.com/django/django.git
synced 2025-08-06 03:48:38 +00:00
Fixed #30651 -- Made __eq__() methods return NotImplemented for not implemented comparisons.
Changed __eq__ to return NotImplemented instead of False if compared to an object of the same type, as is recommended by the Python data model reference. Now these models can be compared to ANY (or other objects with __eq__ overwritten) without returning False automatically.
This commit is contained in:
parent
6475e6318c
commit
54ea290e5b
20 changed files with 71 additions and 33 deletions
|
@ -89,13 +89,14 @@ class ExclusionConstraint(BaseConstraint):
|
|||
return path, args, kwargs
|
||||
|
||||
def __eq__(self, other):
|
||||
return (
|
||||
isinstance(other, self.__class__) and
|
||||
self.name == other.name and
|
||||
self.index_type == other.index_type and
|
||||
self.expressions == other.expressions and
|
||||
self.condition == other.condition
|
||||
)
|
||||
if isinstance(other, self.__class__):
|
||||
return (
|
||||
self.name == other.name and
|
||||
self.index_type == other.index_type and
|
||||
self.expressions == other.expressions and
|
||||
self.condition == other.condition
|
||||
)
|
||||
return super().__eq__(other)
|
||||
|
||||
def __repr__(self):
|
||||
return '<%s: index_type=%s, expressions=%s%s>' % (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue