Skip to content

Commit 48658e4

Browse files
committed
Use 'from __future__ import annotations' in the function stubs
Otherwise the annotation for -inf will fail, since inf is stubbed as None. We also don't need to evaluate the other annotations either, even though they shouldn't fail.
1 parent ca73a6b commit 48658e4

12 files changed

+24
-0
lines changed

array_api_tests/function_stubs/array_object.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
2. There is no real way to test that anyway.
1515
"""
1616

17+
from __future__ import annotations
18+
1719
from ._types import array
1820

1921
def __abs__(x: array) -> array:

array_api_tests/function_stubs/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
2. There is no real way to test that anyway.
1515
"""
1616

17+
from __future__ import annotations
18+
1719

1820
e = None
1921

array_api_tests/function_stubs/creation_functions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
2. There is no real way to test that anyway.
1515
"""
1616

17+
from __future__ import annotations
18+
1719
from ._types import Optional, Tuple, Union, array, device, dtype
1820

1921
def arange(start: Union[int, float], *, stop: Optional[Union[int, float]] = None, step: Union[int, float] = 1, dtype: Optional[dtype] = None, device: Optional[device] = None) -> array:

array_api_tests/function_stubs/elementwise_functions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
2. There is no real way to test that anyway.
1515
"""
1616

17+
from __future__ import annotations
18+
1719
from ._types import array
1820

1921
def abs(x: array) -> array:

array_api_tests/function_stubs/linear_algebra_functions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
2. There is no real way to test that anyway.
1515
"""
1616

17+
from __future__ import annotations
18+
1719
from ._types import Literal, Optional, Tuple, Union, array
1820
from .constants import inf
1921

array_api_tests/function_stubs/manipulation_functions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
2. There is no real way to test that anyway.
1515
"""
1616

17+
from __future__ import annotations
18+
1719
from ._types import Optional, Tuple, Union, array
1820

1921
def concat(arrays: Tuple[array], *, axis: Optional[int] = 0) -> array:

array_api_tests/function_stubs/searching_functions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
2. There is no real way to test that anyway.
1515
"""
1616

17+
from __future__ import annotations
18+
1719
from ._types import Tuple, array
1820

1921
def argmax(x: array, *, axis: int = None, keepdims: bool = False) -> array:

array_api_tests/function_stubs/set_functions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
2. There is no real way to test that anyway.
1515
"""
1616

17+
from __future__ import annotations
18+
1719
from ._types import Tuple, Union, array
1820

1921
def unique(x: array, *, return_counts: bool = False, return_index: bool = False, return_inverse: bool = False, sorted: bool = True) -> Union[array, Tuple[array, ...]]:

array_api_tests/function_stubs/sorting_functions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
2. There is no real way to test that anyway.
1515
"""
1616

17+
from __future__ import annotations
18+
1719
from ._types import array
1820

1921
def argsort(x: array, *, axis: int = -1, descending: bool = False, stable: bool = True) -> array:

array_api_tests/function_stubs/statistical_functions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
2. There is no real way to test that anyway.
1515
"""
1616

17+
from __future__ import annotations
18+
1719
from ._types import Optional, Tuple, Union, array
1820

1921
def max(x: array, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, keepdims: bool = False) -> array:

array_api_tests/function_stubs/utility_functions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
2. There is no real way to test that anyway.
1515
"""
1616

17+
from __future__ import annotations
18+
1719
from ._types import Optional, Tuple, Union, array
1820

1921
def all(x: array, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, keepdims: bool = False) -> array:

generate_stubs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
2. There is no real way to test that anyway.
4444
"""
4545
46+
from __future__ import annotations
47+
4648
from ._types import *
4749
from .constants import *
4850
'''

0 commit comments

Comments
 (0)