Skip to content

Commit

Permalink
Remove other: Self type annotation
Browse files Browse the repository at this point in the history
If `Self + NDArray` is performed, this prevents `mypy` from falling back to `ndarray.__radd__()`, which has a return type of `NDArray`. This ensures that the arithmetic type is always `Self`. The runtime type checking will ensure valid arguments are passed.
  • Loading branch information
mhostetter committed Oct 14, 2023
1 parent 313bea3 commit 7f8df89
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/galois/_domains/_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,61 +454,61 @@ def astype(self, dtype, order="K", casting="unsafe", subok=True, copy=True):

# pylint: disable=useless-super-delegation,no-member

def __add__(self, other: Self) -> Self:
def __add__(self, other: npt.NDArray) -> Self:
return super().__add__(other)

def __iadd__(self, other: Self) -> Self:
def __iadd__(self, other: npt.NDArray) -> Self:
return super().__iadd__(other)

def __radd__(self, other: Self) -> Self:
def __radd__(self, other: npt.NDArray) -> Self:
return super().__radd__(other)

def __sub__(self, other: Self) -> Self:
def __sub__(self, other: npt.NDArray) -> Self:
return super().__sub__(other)

def __isub__(self, other: Self) -> Self:
def __isub__(self, other: npt.NDArray) -> Self:
return super().__isub__(other)

def __rsub__(self, other: Self) -> Self:
def __rsub__(self, other: npt.NDArray) -> Self:
return super().__rsub__(other)

def __mul__(self, other: int | npt.NDArray | Self) -> Self:
def __mul__(self, other: int | npt.NDArray) -> Self:
return super().__mul__(other)

def __imul__(self, other: int | npt.NDArray | Self) -> Self:
def __imul__(self, other: int | npt.NDArray) -> Self:
return super().__imul__(other)

def __rmul__(self, other: int | npt.NDArray | Self) -> Self:
def __rmul__(self, other: int | npt.NDArray) -> Self:
return super().__rmul__(other)

def __truediv__(self, other: Self) -> Self:
def __truediv__(self, other: npt.NDArray) -> Self:
return super().__truediv__(other)

def __itruediv__(self, other: Self) -> Self:
def __itruediv__(self, other: npt.NDArray) -> Self:
return super().__itruediv__(other)

def __rtruediv__(self, other: Self) -> Self:
def __rtruediv__(self, other: npt.NDArray) -> Self:
return super().__rtruediv__(other)

def __floordiv__(self, other: Self) -> Self:
def __floordiv__(self, other: npt.NDArray) -> Self:
return super().__floordiv__(other) # pylint: disable=too-many-function-args

def __ifloordiv__(self, other: Self) -> Self:
def __ifloordiv__(self, other: npt.NDArray) -> Self:
return super().__ifloordiv__(other)

def __rfloordiv__(self, other: Self) -> Self:
def __rfloordiv__(self, other: npt.NDArray) -> Self:
return super().__rfloordiv__(other)

def __neg__(self) -> Self:
return super().__neg__()

def __mod__(self, other: Self) -> Self:
def __mod__(self, other: npt.NDArray) -> Self:
return super().__mod__(other)

def __imod__(self, other: Self) -> Self:
def __imod__(self, other: npt.NDArray) -> Self:
return super().__imod__(other)

def __rmod__(self, other: Self) -> Self:
def __rmod__(self, other: npt.NDArray) -> Self:
return super().__rmod__(other)

def __pow__(self, other: int | npt.NDArray) -> Self:
Expand All @@ -520,10 +520,10 @@ def __ipow__(self, other: int | npt.NDArray) -> Self:
# def __rpow__(self, other) -> Self:
# return super().__rpow__(other)

def __matmul__(self, other: Self) -> Self:
def __matmul__(self, other: npt.NDArray) -> Self:
return super().__matmul__(other)

def __rmatmul__(self, other: Self) -> Self:
def __rmatmul__(self, other: npt.NDArray) -> Self:
return super().__rmatmul__(other)

def __lshift__(self, other: int | npt.NDArray) -> Self:
Expand Down

0 comments on commit 7f8df89

Please sign in to comment.