Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repos:
- id: rst-inline-touching-normal
- id: text-unicode-replacement-char
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.20
rev: v0.16.1
hooks:
- id: ruff-check
args: ["--fix", "--show-fixes"]
Expand All @@ -37,12 +37,12 @@ repos:
# make sure this is the most recent version of black
additional_dependencies: ["black==25.11.0"]
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.9.4
rev: v3.9.6
hooks:
- id: prettier
args: ["--cache-location=.prettier_cache/cache"]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v2.1.0
rev: v2.3.0
hooks:
- id: mypy
# Copied from setup.cfg
Expand Down Expand Up @@ -80,7 +80,7 @@ repos:
hooks:
- id: typos
- repo: https://github.com/zizmorcore/zizmor-pre-commit
rev: v1.26.1
rev: v1.29.0
hooks:
- id: zizmor
args: ["--offline"]
2 changes: 1 addition & 1 deletion xarray/backends/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1400,7 +1400,7 @@ def open_mfdataset(
preprocess: Callable[[Dataset], Dataset] | None = None,
engine: T_Engine = None,
data_vars: (
Literal["all", "minimal", "different"] | None | list[str] | CombineKwargDefault
Literal["all", "minimal", "different"] | list[str] | CombineKwargDefault | None
) = _DATA_VARS_DEFAULT,
coords=_COORDS_DEFAULT,
combine: Literal["by_coords", "nested"] = "by_coords",
Expand Down
6 changes: 3 additions & 3 deletions xarray/backends/file_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __init__(
*args: Any,
mode: Any = _OMIT_MODE,
kwargs: Mapping[str, Any] | None = None,
lock: Lock | None | Literal[False] = None,
lock: Lock | Literal[False] | None = None,
cache: MutableMapping[Any, T_File] | None = None,
manager_id: Hashable | None = None,
ref_counts: dict[Any, int] | None = None,
Expand Down Expand Up @@ -355,7 +355,7 @@ def __init__(
opener: Callable[..., T_File],
*args: Any,
mode: Any = _OMIT_MODE,
lock: Lock | None | Literal[False] = None,
lock: Lock | Literal[False] | None = None,
kwargs: Mapping[str, Any] | None = None,
):
kwargs = {} if kwargs is None else dict(kwargs)
Expand Down Expand Up @@ -458,7 +458,7 @@ def __init__(
value: T_File,
*,
close: Callable[[], None] | None = None,
lock: Lock | None | Literal[False] = None,
lock: Lock | Literal[False] | None = None,
):
if close is None:
close = value.close
Expand Down
2 changes: 1 addition & 1 deletion xarray/backends/locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def combine_locks(locks: Sequence[Lock]) -> Lock:
return DummyLock()


def ensure_lock(lock: Lock | None | Literal[False]) -> Lock:
def ensure_lock(lock: Lock | Literal[False] | None) -> Lock:
"""Ensure that the given object is a lock."""
if lock is None or lock is False:
return DummyLock()
Expand Down
4 changes: 0 additions & 4 deletions xarray/backends/store.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

from collections.abc import Iterable
from typing import TYPE_CHECKING

from xarray import conventions
from xarray.backends.common import (
Expand All @@ -13,9 +12,6 @@
from xarray.core.coordinates import Coordinates
from xarray.core.dataset import Dataset

if TYPE_CHECKING:
pass


class StoreBackendEntrypoint(BackendEntrypoint):
description = "Open AbstractDataStore instances in Xarray"
Expand Down
2 changes: 1 addition & 1 deletion xarray/backends/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ def _datatree_to_netcdf(
compute: bool = True,
invalid_netcdf: bool = False,
auto_complex: bool | None = None,
) -> None | memoryview | Delayed:
) -> memoryview | Delayed | None:
"""Implementation of `DataTree.to_netcdf`."""

if format not in [None, *get_args(T_DataTreeNetcdfTypes)]:
Expand Down
2 changes: 1 addition & 1 deletion xarray/coding/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def encode(self, variable: Variable, name=None) -> Variable:
# which all backends support natively (GH11199)
if data.dtype.kind == "T":
data = np.asarray(data, dtype=object)
data[data == None] = "" # noqa: E711
data[data == None] = ""
data = np.asarray(data, dtype="U")
variable = Variable(dims, data, attrs, encoding)

Expand Down
2 changes: 1 addition & 1 deletion xarray/coding/times.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ def _encode_datetime_with_cftime(dates, units: str, calendar: str) -> np.ndarray
dates = np.atleast_1d(dates)

# Find all the None position
none_position = dates == None # noqa: E711
none_position = dates == None
filtered_dates = dates[~none_position]

# Since netCDF files do not support storing float128 values, we ensure
Expand Down
5 changes: 1 addition & 4 deletions xarray/computation/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@
from __future__ import annotations

import operator
from typing import TYPE_CHECKING, Literal
from typing import Literal

import numpy as np

from xarray.core import dtypes, duck_array_ops

if TYPE_CHECKING:
pass

try:
import bottleneck as bn

Expand Down
4 changes: 2 additions & 2 deletions xarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -3571,13 +3571,13 @@ def interpolate_na(
limit: int | None = None,
use_coordinate: bool | str = True,
max_gap: (
None
| int
int
| float
| str
| pd.Timedelta
| np.timedelta64
| datetime.timedelta
| None
) = None,
keep_attrs: bool | None = None,
**kwargs: Any,
Expand Down
4 changes: 2 additions & 2 deletions xarray/core/datatree.py
Original file line number Diff line number Diff line change
Expand Up @@ -1811,7 +1811,7 @@ def map_over_datasets(

def map_over_datasets(
self,
func: Callable[..., Dataset | None | tuple[Dataset | None, ...]],
func: Callable[..., Dataset | tuple[Dataset | None, ...] | None],
*args: Any,
kwargs: Mapping[str, Any] | None = None,
) -> DataTree | tuple[DataTree, ...]:
Expand Down Expand Up @@ -2034,7 +2034,7 @@ def to_netcdf(
write_inherited_coords: bool = False,
compute: bool = True,
**kwargs,
) -> None | memoryview | Delayed:
) -> memoryview | Delayed | None:
"""
Write datatree contents to a netCDF file.

Expand Down
2 changes: 1 addition & 1 deletion xarray/core/datatree_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def map_over_datasets(


def map_over_datasets(
func: Callable[..., Dataset | None | tuple[Dataset | None, ...]],
func: Callable[..., Dataset | tuple[Dataset | None, ...] | None],
*args: Any,
kwargs: Mapping[str, Any] | None = None,
) -> DataTree | tuple[DataTree, ...]:
Expand Down
4 changes: 2 additions & 2 deletions xarray/structure/combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,9 +799,9 @@ def combine_by_coords(
data_objects: Iterable[Dataset | DataArray] = [],
compat: CompatOptions | CombineKwargDefault = _COMPAT_DEFAULT,
data_vars: Literal["all", "minimal", "different"]
| None
| list[str]
| CombineKwargDefault = _DATA_VARS_DEFAULT,
| CombineKwargDefault
| None = _DATA_VARS_DEFAULT,
coords: str | CombineKwargDefault = _COORDS_DEFAULT,
fill_value: object = dtypes.NA,
join: JoinOptions | CombineKwargDefault = _JOIN_DEFAULT,
Expand Down
28 changes: 14 additions & 14 deletions xarray/tests/test_dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -6616,7 +6616,7 @@ def test_argmin_dim(

minindices_x = {
key: xr.where(
nanindices_x[key] == None, # noqa: E711
nanindices_x[key] == None,
minindices_x[key],
nanindices_x[key],
)
Expand All @@ -6634,7 +6634,7 @@ def test_argmin_dim(

minindices_y = {
key: xr.where(
nanindices_y[key] == None, # noqa: E711
nanindices_y[key] == None,
minindices_y[key],
nanindices_y[key],
)
Expand All @@ -6652,7 +6652,7 @@ def test_argmin_dim(

minindices_z = {
key: xr.where(
nanindices_z[key] == None, # noqa: E711
nanindices_z[key] == None,
minindices_z[key],
nanindices_z[key],
)
Expand All @@ -6670,7 +6670,7 @@ def test_argmin_dim(

minindices_xy = {
key: xr.where(
nanindices_xy[key] == None, # noqa: E711
nanindices_xy[key] == None,
minindices_xy[key],
nanindices_xy[key],
)
Expand All @@ -6688,7 +6688,7 @@ def test_argmin_dim(

minindices_xz = {
key: xr.where(
nanindices_xz[key] == None, # noqa: E711
nanindices_xz[key] == None,
minindices_xz[key],
nanindices_xz[key],
)
Expand All @@ -6706,7 +6706,7 @@ def test_argmin_dim(

minindices_yz = {
key: xr.where(
nanindices_yz[key] == None, # noqa: E711
nanindices_yz[key] == None,
minindices_yz[key],
nanindices_yz[key],
)
Expand All @@ -6724,7 +6724,7 @@ def test_argmin_dim(

minindices_xyz = {
key: xr.where(
nanindices_xyz[key] == None, # noqa: E711
nanindices_xyz[key] == None,
minindices_xyz[key],
nanindices_xyz[key],
)
Expand Down Expand Up @@ -6855,7 +6855,7 @@ def test_argmax_dim(

maxindices_x = {
key: xr.where(
nanindices_x[key] == None, # noqa: E711
nanindices_x[key] == None,
maxindices_x[key],
nanindices_x[key],
)
Expand All @@ -6873,7 +6873,7 @@ def test_argmax_dim(

maxindices_y = {
key: xr.where(
nanindices_y[key] == None, # noqa: E711
nanindices_y[key] == None,
maxindices_y[key],
nanindices_y[key],
)
Expand All @@ -6891,7 +6891,7 @@ def test_argmax_dim(

maxindices_z = {
key: xr.where(
nanindices_z[key] == None, # noqa: E711
nanindices_z[key] == None,
maxindices_z[key],
nanindices_z[key],
)
Expand All @@ -6909,7 +6909,7 @@ def test_argmax_dim(

maxindices_xy = {
key: xr.where(
nanindices_xy[key] == None, # noqa: E711
nanindices_xy[key] == None,
maxindices_xy[key],
nanindices_xy[key],
)
Expand All @@ -6927,7 +6927,7 @@ def test_argmax_dim(

maxindices_xz = {
key: xr.where(
nanindices_xz[key] == None, # noqa: E711
nanindices_xz[key] == None,
maxindices_xz[key],
nanindices_xz[key],
)
Expand All @@ -6945,7 +6945,7 @@ def test_argmax_dim(

maxindices_yz = {
key: xr.where(
nanindices_yz[key] == None, # noqa: E711
nanindices_yz[key] == None,
maxindices_yz[key],
nanindices_yz[key],
)
Expand All @@ -6963,7 +6963,7 @@ def test_argmax_dim(

maxindices_xyz = {
key: xr.where(
nanindices_xyz[key] == None, # noqa: E711
nanindices_xyz[key] == None,
maxindices_xyz[key],
nanindices_xyz[key],
)
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1685,7 +1685,7 @@ def test_convenient_facetgrid_4d(self) -> None:
def test_facetgrid_col_wrap_auto(
self,
n: int,
figsize: None | tuple[int, int],
figsize: tuple[int, int] | None,
aspect: int,
expected_shape: tuple[int, int],
) -> None:
Expand Down
Loading