diff --git a/xarray/coding/cftimeindex.py b/xarray/coding/cftimeindex.py index 6898809e3b0..ded4c88fb80 100644 --- a/xarray/coding/cftimeindex.py +++ b/xarray/coding/cftimeindex.py @@ -270,16 +270,12 @@ def format_times( def format_attrs(index, separator=", "): """Format attributes of CFTimeIndex for __repr__.""" - attrs = { - "dtype": f"'{index.dtype}'", - "length": f"{len(index)}", - "calendar": f"{index.calendar!r}", - "freq": f"{index.freq!r}", - } - - attrs_str = [f"{k}={v}" for k, v in attrs.items()] - attrs_str = f"{separator}".join(attrs_str) - return attrs_str + return ( + f"dtype='{index.dtype}'{separator}" + f"length={len(index)}{separator}" + f"calendar={index.calendar!r}{separator}" + f"freq={index.freq!r}" + ) class CFTimeIndex(pd.Index):