Skip to content

Commit d19263a

Browse files
authored
TYP: Replace typing.Optional[T] with T | None in the numpy.typing tests (numpy#26954)
Since Python 3.10 typing.Optional[T] has been deprecated in favour of the T | None syntax. See https://typing.readthedocs.io/en/latest/spec/historical.html#union-and-optional .
1 parent f858539 commit d19263a

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

numpy/typing/tests/data/pass/arithmetic.py

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

3-
from typing import Any, Optional
3+
from typing import Any
44
import numpy as np
55
import pytest
66

@@ -26,8 +26,8 @@
2626

2727

2828
class Object:
29-
def __array__(self, dtype: Optional[np.typing.DTypeLike] = None,
30-
copy: Optional[bool] = None) -> np.ndarray[Any, np.dtype[np.object_]]:
29+
def __array__(self, dtype: np.typing.DTypeLike = None,
30+
copy: bool | None = None) -> np.ndarray[Any, np.dtype[np.object_]]:
3131
ret = np.empty((), dtype=object)
3232
ret[()] = self
3333
return ret

numpy/typing/tests/data/pass/ufunclike.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import annotations
2-
from typing import Any, Optional
2+
from typing import Any
33
import numpy as np
44

55

@@ -13,8 +13,8 @@ def __floor__(self) -> Object:
1313
def __ge__(self, value: object) -> bool:
1414
return True
1515

16-
def __array__(self, dtype: Optional[np.typing.DTypeLike] = None,
17-
copy: Optional[bool] = None) -> np.ndarray[Any, np.dtype[np.object_]]:
16+
def __array__(self, dtype: np.typing.DTypeLike | None = None,
17+
copy: bool | None = None) -> np.ndarray[Any, np.dtype[np.object_]]:
1818
ret = np.empty((), dtype=object)
1919
ret[()] = self
2020
return ret

0 commit comments

Comments
 (0)