diff --git a/xarray/core/dataarray.py b/xarray/core/dataarray.py index e63b6c9975f..3becce7e432 100644 --- a/xarray/core/dataarray.py +++ b/xarray/core/dataarray.py @@ -2244,7 +2244,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`.