def test_dataset_typed_ops() -> None:
    """Tests for type checking of typed_ops on Dataset"""

    ds = Dataset({"a": ("t", [1, 2, 3])})

    def _test(ds: Dataset) -> None:
        # mypy checks the input type
        assert isinstance(ds, Dataset)

    _int: int = 1
    _list = [1, 2, 3]
    _ndarray = np.array([1, 2, 3])
    _var = Variable(dims=["t"], data=[1, 2, 3])
    _da = DataArray([1, 2, 3], dims=["t"])

    # __add__ as an example of binary ops
    _test(ds + _int)
    _test(ds + _list)
    _test(ds + _ndarray)
    _test(ds + _var)
    _test(ds + _da)
    _test(ds + ds)

    # __radd__ as an example of reflexive binary ops
    _test(_int + ds)
    _test(_list + ds)
    _test(_ndarray + ds)
    _test(_var + ds)
    _test(_da + ds)

    # __eq__ as an example of cmp ops
    _test(ds == _int)
    _test(ds == _list)
    _test(ds == _ndarray)
    _test(ds == _var)
    _test(ds == _da)
    _test(_int == ds)  # type: ignore[arg-type]  # typeshed problem
    _test(_list == ds)  # type: ignore[arg-type]  # typeshed problem
    _test(_ndarray == ds)
    _test(_var == ds)
    _test(_da == ds)

    # __lt__ as another example of cmp ops
    _test(ds < _int)
    _test(ds < _list)
    _test(ds < _ndarray)
    _test(ds < _var)
    _test(ds < _da)
    _test(_int > ds)
    _test(_list > ds)
    _test(_ndarray > ds)  # type: ignore[arg-type]  # numpy problem
    _test(_var > ds)
    _test(_da > ds)

    # __iadd__ as an example of inplace binary ops
    ds += _int
    ds += _list
    ds += _ndarray
    ds += _var
    ds += _da

    # __neg__ as an example of unary ops
    _test(-ds)
Tests for type checking of typed_ops on Dataset
xarray/tests/test_typed_ops.py