Skip to content

TYP: type annotations #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Joren Hammudoglu <jhammudoglu@gmail.com>
  • Loading branch information
crusaderky and jorenham authored Mar 21, 2025
commit 6cd171bbfd46da3edac1d919a0d4583265a2543e
6 changes: 3 additions & 3 deletions array_api_strict/_array_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ def __rand__(self, other: Array | int, /) -> Array:
res = self._array.__rand__(other._array)
return self.__class__._new(res, device=self.device)

def __ifloordiv__(self, other: Array | complex, /) -> Array:
def __ifloordiv__(self, other: Array | float, /) -> Array:
"""
Performs the operation __ifloordiv__.
"""
Expand All @@ -1034,7 +1034,7 @@ def __ifloordiv__(self, other: Array | complex, /) -> Array:
self._array.__ifloordiv__(other._array)
return self

def __rfloordiv__(self, other: Array | complex, /) -> Array:
def __rfloordiv__(self, other: Array | float, /) -> Array:
"""
Performs the operation __rfloordiv__.
"""
Expand Down Expand Up @@ -1105,7 +1105,7 @@ def __imod__(self, other: Array | complex, /) -> Array:
self._array.__imod__(other._array)
return self

def __rmod__(self, other: Array | complex, /) -> Array:
def __rmod__(self, other: Array | float, /) -> Array:
"""
Performs the operation __rmod__.
"""
Expand Down
2 changes: 1 addition & 1 deletion array_api_strict/_creation_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Undef(Enum):


@contextmanager
def allow_array() -> Generator[None, None, None]:
def allow_array() -> Generator[None]:
"""
Temporarily enable Array.__array__. This is needed for np.array to parse
list of lists of Array objects.
Expand Down
1 change: 1 addition & 0 deletions array_api_strict/_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ def __exit__(
exc_type: type[BaseException] | None,
exc_value: BaseException | None,
traceback: TracebackType | None,
/,
) -> None:
set_array_api_strict_flags(**self.old_flags)

Expand Down
2 changes: 1 addition & 1 deletion array_api_strict/_utility_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
# currently specified.

# NumPy does not support prepend=None or append=None
kwargs: dict[str, Any] = dict(axis=axis, n=n)
kwargs: dict[str, int | npt.NDArray[Any]] = {"axis": axis, "n", n}

Check failure on line 59 in array_api_strict/_utility_functions.py

View workflow job for this annotation

GitHub Actions / check-ruff

Ruff

array_api_strict/_utility_functions.py:59:70: SyntaxError: Expected ':', found '}'

Check failure on line 59 in array_api_strict/_utility_functions.py

View workflow job for this annotation

GitHub Actions / check-ruff

Ruff

array_api_strict/_utility_functions.py:59:67: SyntaxError: Expected ':', found ','
if prepend is not None:
if prepend.device != x.device:
raise ValueError(f"Arrays from two different devices ({prepend.device} and {x.device}) can not be combined.")
Expand Down
Loading