Skip to content

Commit 4c202f3

Browse files
committed
Merge pull request #773 from SixtyCapital/ide-recognize-ops
IDEs resolves ops
2 parents eda0d02 + 1005a9e commit 4c202f3

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):
@@ -481,6 +481,12 @@ def where(self, cond):
481481
"""
482482
return self._where(cond)
483483

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

485491
def squeeze(xarray_obj, dims, dim=None):
486492
"""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)