def test_dataarray_groupy_typed_ops() -> None:
    """Tests for type checking of typed_ops on DataArrayGroupBy"""

    da = DataArray([1, 2, 3], coords={"x": ("t", [1, 2, 2])}, dims=["t"])
    grp = da.groupby("x")

    def _testda(da: DataArray) -> None:
        # mypy checks the input type
        assert isinstance(da, DataArray)

    def _testds(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
    _testda(grp + _da)
    _testds(grp + _ds)

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

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

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