def test_dataset_groupy_typed_ops() -> None:
    """Tests for type checking of typed_ops on DatasetGroupBy"""

    ds = Dataset({"a": ("t", [1, 2, 3])}, coords={"x": ("t", [1, 2, 2])})
    grp = ds.groupby("x")

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

    _da = DataArray([5, 6], coords={"x": [1, 2]}, dims="x")
    _ds = _da.to_dataset(name="a")

    # __add__ as an example of binary ops
    _test(grp + _da)
    _test(grp + _ds)

    # __radd__ as an example of reflexive binary ops
    _test(_da + grp)
    _test(_ds + grp)

    # __eq__ as an example of cmp ops
    _test(grp == _da)
    _test(_da == grp)
    _test(grp == _ds)
    _test(_ds == grp)

    # __lt__ as another example of cmp ops
    _test(grp < _da)
    _test(_da > grp)
    _test(grp < _ds)
    _test(_ds > grp)
Tests for type checking of typed_ops on DatasetGroupBy
xarray/tests/test_typed_ops.py