Skip to content

Commit d6ef302

Browse files
committed
Python 3.9 fixes
1 parent 73e998e commit d6ef302

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

array_api_strict/_array_object.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import operator
1919
from collections.abc import Iterator
2020
from enum import IntEnum
21-
from types import EllipsisType, ModuleType
21+
from types import ModuleType
2222
from typing import Any, Literal, SupportsIndex
2323

2424
import numpy as np
@@ -42,6 +42,10 @@
4242
from ._flags import get_array_api_strict_flags, set_array_api_strict_flags
4343
from ._typing import PyCapsule
4444

45+
try:
46+
from types import EllipsisType # Python >=3.10
47+
except ImportError:
48+
EllipsisType = type(Ellipsis)
4549

4650
class Device:
4751
_device: str
@@ -345,7 +349,7 @@ def _validate_index(
345349
| tuple[int | slice | EllipsisType | None, ...]
346350
| Array
347351
),
348-
op: Literal["getitem", "setitem"],
352+
op: Literal["getitem", "setitem"] = "getitem",
349353
) -> None:
350354
"""
351355
Validate an index according to the array API.

array_api_strict/_dtypes.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import warnings
24
from typing import Any
35

array_api_strict/_helpers.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Private helper routines.
22
"""
3+
from __future__ import annotations
34

45
from ._array_object import Array
56
from ._dtypes import _dtype_categories

0 commit comments

Comments
 (0)