diff --git a/xarray/core/concat.py b/xarray/core/concat.py index c7a7c178bd8..26cf36b3b07 100644 --- a/xarray/core/concat.py +++ b/xarray/core/concat.py @@ -536,9 +536,10 @@ def _dataset_concat( result_encoding = datasets[0].encoding # check that global attributes are fixed across all datasets if necessary - for ds in datasets[1:]: - if compat == "identical" and not utils.dict_equiv(ds.attrs, result_attrs): - raise ValueError("Dataset global attributes not equal.") + if compat == "identical": + for ds in datasets[1:]: + if not utils.dict_equiv(ds.attrs, result_attrs): + raise ValueError("Dataset global attributes not equal.") # we've already verified everything is consistent; now, calculate # shared dimension sizes so we can expand the necessary variables