Skip to content

Commit 1005a9e

Browse files
committed
empty ops methods on base xr object, so IDEs resolve
1 parent a59e6dd commit 1005a9e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

xarray/core/common.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from .pycompat import basestring, iteritems, suppress, dask_array_type
55
from . import formatting
6-
from .utils import SortedKeysDict
6+
from .utils import SortedKeysDict, not_implemented
77

88

99
class ImplementsArrayReduce(object):
@@ -477,6 +477,12 @@ def where(self, cond):
477477
"""
478478
return self._where(cond)
479479

480+
# this has no runtime function - these are listed so IDEs know these methods
481+
# are defined and don't warn on these operations
482+
__lt__ = __le__ =__ge__ = __gt__ = __add__ = __sub__ = __mul__ = \
483+
__truediv__ = __floordiv__ = __mod__ = __pow__ = __and__ = __xor__ = \
484+
__or__ = __div__ = __eq__ = __ne__ = not_implemented
485+
480486

481487
def squeeze(xarray_obj, dims, dim=None):
482488
"""Squeeze the dims of an xarray object."""

xarray/core/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,3 +431,7 @@ def hashable(v):
431431
except TypeError:
432432
return False
433433
return True
434+
435+
436+
def not_implemented(*args, **kwargs):
437+
return NotImplemented

0 commit comments

Comments
 (0)