Skip to content

Commit 5e4e18f

Browse files
Appending to dictionary immediately following its definition (#10448)
1 parent b2ff8e0 commit 5e4e18f

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

xarray/util/generate_ops.py

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -222,32 +222,33 @@ def unops() -> list[OpsType]:
222222
# ruff does not reformat everything. When reformatting, the
223223
# type-ignores end up in the wrong line :/
224224

225-
ops_info = {}
226-
# TODO add inplace ops for DataTree?
227-
ops_info["DataTreeOpsMixin"] = binops(other_type="DtCompatible") + unops()
228-
ops_info["DatasetOpsMixin"] = (
229-
binops_overload(other_type="DsCompatible", overload_types=["DataTree"])
230-
+ inplace(other_type="DsCompatible", type_ignore="misc")
231-
+ unops()
232-
)
233-
ops_info["DataArrayOpsMixin"] = (
234-
binops_overload(other_type="DaCompatible", overload_types=["Dataset", "DataTree"])
235-
+ inplace(other_type="DaCompatible", type_ignore="misc")
236-
+ unops()
237-
)
238-
ops_info["VariableOpsMixin"] = (
239-
binops_overload(
240-
other_type="VarCompatible", overload_types=["T_DA", "Dataset", "DataTree"]
241-
)
242-
+ inplace(other_type="VarCompatible", type_ignore="misc")
243-
+ unops()
244-
)
245-
ops_info["DatasetGroupByOpsMixin"] = binops(
246-
other_type="Dataset | DataArray", return_type="Dataset"
247-
)
248-
ops_info["DataArrayGroupByOpsMixin"] = binops(
249-
other_type="T_Xarray", return_type="T_Xarray"
250-
)
225+
ops_info = {
226+
# TODO add inplace ops for DataTree?
227+
"DataTreeOpsMixin": binops(other_type="DtCompatible") + unops(),
228+
"DatasetOpsMixin": (
229+
binops_overload(other_type="DsCompatible", overload_types=["DataTree"])
230+
+ inplace(other_type="DsCompatible", type_ignore="misc")
231+
+ unops()
232+
),
233+
"DataArrayOpsMixin": (
234+
binops_overload(
235+
other_type="DaCompatible", overload_types=["Dataset", "DataTree"]
236+
)
237+
+ inplace(other_type="DaCompatible", type_ignore="misc")
238+
+ unops()
239+
),
240+
"VariableOpsMixin": (
241+
binops_overload(
242+
other_type="VarCompatible", overload_types=["T_DA", "Dataset", "DataTree"]
243+
)
244+
+ inplace(other_type="VarCompatible", type_ignore="misc")
245+
+ unops()
246+
),
247+
"DatasetGroupByOpsMixin": binops(
248+
other_type="Dataset | DataArray", return_type="Dataset"
249+
),
250+
"DataArrayGroupByOpsMixin": binops(other_type="T_Xarray", return_type="T_Xarray"),
251+
}
251252

252253
MODULE_PREAMBLE = '''\
253254
"""Mixin classes with arithmetic operators."""

0 commit comments

Comments
 (0)