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

Remove unnecessary __ne__ fallbacks #1827

Merged
merged 1 commit into from
Nov 3, 2024
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
14 changes: 4 additions & 10 deletions build_scripts/build_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,10 @@ def save_to_cache_file(self):
)

def __eq__(self, other):
return all([
self.py_version == other.py_version,
self.build_type == other.build_type,
])

def __ne__(self, other):
return any([
self.py_version != other.py_version,
self.build_type != other.build_type,
])
return (
self.py_version == other.py_version
and self.build_type == other.build_type
)

@classmethod
def current_build_config(cls, debug):
Expand Down
3 changes: 0 additions & 3 deletions pytype/abstract/_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,9 +785,6 @@ def __eq__(self, other: "ParameterizedClass") -> bool:
)
return NotImplemented

def __ne__(self, other: "ParameterizedClass") -> bool:
return not self == other

def __hash__(self):
if self._hash is None:
if isinstance(
Expand Down
6 changes: 0 additions & 6 deletions pytype/abstract/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,9 +542,6 @@ def __eq__(self, other: "_TypeVariable") -> bool:
)
return NotImplemented

def __ne__(self, other: "_TypeVariable") -> bool:
return not self == other

def __hash__(self) -> int:
return hash((
self.name,
Expand Down Expand Up @@ -710,9 +707,6 @@ def __eq__(self, other: "Union") -> bool:
return self.options == other.options
return NotImplemented

def __ne__(self, other: "Union") -> bool:
return not self == other

def __hash__(self) -> int:
# Use the names of the parameter values to approximate a hash, to avoid
# infinite recursion on recursive type annotations.
Expand Down
9 changes: 0 additions & 9 deletions pytype/pytd/booleq.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,6 @@ def __eq__(self, other):
and self.right == other.right
)

def __ne__(self, other):
return not self == other

def simplify(self, assignments):
"""Simplify this equality.
Expand Down Expand Up @@ -236,9 +233,6 @@ def __init__(self, exprs):
def __eq__(self, other):
return self.__class__ == other.__class__ and self.exprs == other.exprs

def __ne__(self, other):
return not self == other

def __repr__(self):
return f"And({list(self.exprs)!r})"

Expand Down Expand Up @@ -288,9 +282,6 @@ def __init__(self, exprs):
def __eq__(self, other): # for unit tests
return self.__class__ == other.__class__ and self.exprs == other.exprs

def __ne__(self, other):
return not self == other

def __repr__(self):
return f"Or({list(self.exprs)!r})"

Expand Down
3 changes: 0 additions & 3 deletions pytype/pytd/pytd.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,9 +562,6 @@ def __eq__(self, other):
return frozenset(self.type_list) == frozenset(other.type_list)
return NotImplemented

def __ne__(self, other):
return not self == other

def __hash__(self):
return hash(self.type_list)

Expand Down
Loading