Skip to content

Commit 54dbd58

Browse files
committed
nit
1 parent 90fb03c commit 54dbd58

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

array_api_compat/common/_helpers.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from typing import TYPE_CHECKING
1212

1313
if TYPE_CHECKING:
14-
from typing import Callable, Optional, Union, Any
14+
from typing import Callable, Literal, Optional, Union, Any
1515
from ._typing import Array, Device
1616

1717
import sys
@@ -819,16 +819,17 @@ def _parse_copy_param(x, copy: bool | None | Literal["_force_false"]) -> bool:
819819
"""Preprocess and validate a copy parameter, in line with the same
820820
parameter in np.asarray(), np.astype(), etc.
821821
"""
822-
if copy is None:
823-
return not is_writeable_array(x)
824-
if copy is False:
822+
if copy is True:
823+
return True
824+
elif copy is False:
825825
if not is_writeable_array(x):
826826
raise ValueError("Cannot avoid modifying parameter in place")
827+
return False
828+
elif copy is None:
829+
return not is_writeable_array(x)
827830
elif copy == "_force_false":
828831
return False
829-
elif copy is not True:
830-
raise ValueError(f"Invalid value for copy: {copy!r}")
831-
return copy
832+
raise ValueError(f"Invalid value for copy: {copy!r}")
832833

833834

834835
_undef = object()

0 commit comments

Comments
 (0)