Skip to content

Commit e71bb12

Browse files
Branches of the if statement have similar implementation (#10475)
* Branches of the `if` statement have similar implementation Issue introduced by 16b53ac / #8937. It looks like the `sys.version_info >= (3, 11)` test is incorrect, as `typing.TypeAlias` was added in version 3.10, not 3.11: https://docs.python.org/3/library/typing.html#typing.TypeAlias * Branches of the `if` statement have similar implementation Introduced by 17933e7 / #7426.
1 parent 129d9af commit e71bb12

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

asv_bench/benchmarks/dataset_io.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -678,13 +678,7 @@ def open(
678678
lock: xr.backends.locks.SerializableLock | None = None,
679679
autoclose: bool = False,
680680
):
681-
if lock is None:
682-
if mode == "r":
683-
locker = xr.backends.locks.SerializableLock()
684-
else:
685-
locker = xr.backends.locks.SerializableLock()
686-
else:
687-
locker = lock
681+
locker = lock or xr.backends.locks.SerializableLock()
688682

689683
manager = xr.backends.CachingFileManager(
690684
xr.backends.DummyFileManager,

xarray/namedarray/_typing.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import annotations
22

3-
import sys
43
from collections.abc import Callable, Hashable, Iterable, Mapping, Sequence
54
from enum import Enum
65
from types import EllipsisType, ModuleType
@@ -20,10 +19,7 @@
2019
import numpy as np
2120

2221
try:
23-
if sys.version_info >= (3, 11):
24-
from typing import TypeAlias
25-
else:
26-
from typing import TypeAlias
22+
from typing import TypeAlias
2723
except ImportError:
2824
if TYPE_CHECKING:
2925
raise

0 commit comments

Comments
 (0)