diff --git a/xarray/core/dataarray.py b/xarray/core/dataarray.py index 13a3a507c7b..503ac71db87 100644 --- a/xarray/core/dataarray.py +++ b/xarray/core/dataarray.py @@ -2227,7 +2227,7 @@ def to_masked_array(self, copy: bool = True) -> np.ma.MaskedArray: isnull = pd.isnull(values) return np.ma.MaskedArray(data=values, mask=isnull, copy=copy) - def to_netcdf(self, *args, **kwargs) -> Optional["Delayed"]: + def to_netcdf(self, *args, **kwargs) -> Union[bytes, "Delayed", None]: """Write DataArray contents to a netCDF file. All parameters are passed directly to `xarray.Dataset.to_netcdf`.