Skip to content

Commit

Permalink
Add unhashable to generate_ops
Browse files Browse the repository at this point in the history
  • Loading branch information
maresb committed Nov 9, 2023
1 parent 397682e commit d5d9e95
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions xarray/util/generate_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ def {method}(self) -> Self:
template_other_unary = """
def {method}(self, *args: Any, **kwargs: Any) -> Self:
return self._unary_op({func}, *args, **kwargs)"""
unhashable = """
# When __eq__ is defined but __hash__ is not, then an object is unhashable,
# and it should be declared as follows:
__hash__: None # type:ignore[assignment]"""

# For some methods we override return type `bool` defined by base class `object`.
# We need to add "# type: ignore[override]"
Expand Down Expand Up @@ -152,6 +156,7 @@ def binops(
template_binop,
extras | {"type_ignore": _type_ignore(type_ignore_eq)},
),
([(None, None)], unhashable, extras),
(BINOPS_REFLEXIVE, template_reflexive, extras),
]

Expand Down

0 comments on commit d5d9e95

Please sign in to comment.