Skip to content

Commit

Permalink
Enable UP006,UP007
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Jul 17, 2024
1 parent 5c2c798 commit 902226d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ extend-ignore = [
"E221", # multiple spaces before operator
"E226", # missing whitespace around arithmetic operator
"E402", # module-level import not at top of file
"UP006", # updated annotations due to __future__ import
"UP007", # updated annotations due to __future__ import
]

[tool.ruff.lint.flake8-quotes]
Expand Down
28 changes: 14 additions & 14 deletions sumpy/toys.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

from functools import partial
from numbers import Number
from typing import TYPE_CHECKING, Optional, Sequence, Union
from typing import TYPE_CHECKING, Sequence

from pytools import memoize_method

Expand Down Expand Up @@ -508,7 +508,7 @@ def eval(self, targets: np.ndarray) -> np.ndarray:
def __neg__(self) -> PotentialSource:
return -1*self

def __add__(self, other: Union[Number, np.number, PotentialSource]
def __add__(self, other: Number | np.number | PotentialSource
) -> PotentialSource:
if isinstance(other, (Number, np.number)):
other = ConstantPotential(self.toy_ctx, other)
Expand All @@ -520,16 +520,16 @@ def __add__(self, other: Union[Number, np.number, PotentialSource]
__radd__ = __add__

def __sub__(self,
other: Union[Number, np.number, PotentialSource]) -> PotentialSource:
other: Number | np.number | PotentialSource) -> PotentialSource:
return self.__add__(-other)

def __rsub__(self,
other: Union[Number, np.number, PotentialSource]
other: Number | np.number | PotentialSource
) -> PotentialSource:
return (-self).__add__(other)

def __mul__(self,
other: Union[Number, np.number, PotentialSource]) -> PotentialSource:
other: Number | np.number | PotentialSource) -> PotentialSource:
if isinstance(other, (Number, np.number)):
other = ConstantPotential(self.toy_ctx, other)
elif not isinstance(other, PotentialSource):
Expand Down Expand Up @@ -608,7 +608,7 @@ class PointSources(PotentialSource):

def __init__(self,
toy_ctx: ToyContext, points: np.ndarray, weights: np.ndarray,
center: Optional[np.ndarray] = None):
center: np.ndarray | None = None):
super().__init__(toy_ctx)

self.points = points
Expand Down Expand Up @@ -741,7 +741,7 @@ def eval(self, targets: np.ndarray) -> np.ndarray:


def multipole_expand(psource: PotentialSource,
center: np.ndarray, order: Optional[int] = None,
center: np.ndarray, order: int | None = None,
rscale: float = 1, **expn_kwargs) -> MultipoleExpansion:
if isinstance(psource, PointSources):
if order is None:
Expand All @@ -764,7 +764,7 @@ def multipole_expand(psource: PotentialSource,

def local_expand(
psource: PotentialSource,
center: np.ndarray, order: Optional[int] = None, rscale: Number = 1,
center: np.ndarray, order: int | None = None, rscale: Number = 1,
**expn_kwargs) -> LocalExpansion:
if isinstance(psource, PointSources):
if order is None:
Expand Down Expand Up @@ -820,8 +820,8 @@ def logplot(fp: FieldPlotter, psource: PotentialSource, **kwargs) -> None:
def combine_inner_outer(
psource_inner: PotentialSource,
psource_outer: PotentialSource,
radius: Optional[float],
center: Optional[np.ndarray] = None) -> PotentialSource:
radius: float | None,
center: np.ndarray | None = None) -> PotentialSource:
if center is None:
center = psource_inner.center
if radius is None:
Expand All @@ -835,7 +835,7 @@ def combine_inner_outer(

def combine_halfspace(psource_pos: PotentialSource,
psource_neg: PotentialSource, axis: int,
center: Optional[np.ndarray] = None) -> PotentialSource:
center: np.ndarray | None = None) -> PotentialSource:
if center is None:
center = psource_pos.center

Expand All @@ -849,8 +849,8 @@ def combine_halfspace_and_outer(
psource_pos: PotentialSource,
psource_neg: PotentialSource,
psource_outer: PotentialSource,
axis: int, radius: Optional[Number] = None,
center: Optional[np.ndarray] = None) -> PotentialSource:
axis: int, radius: Number | None = None,
center: np.ndarray | None = None) -> PotentialSource:

if center is None:
center = psource_pos.center
Expand All @@ -863,7 +863,7 @@ def combine_halfspace_and_outer(


def l_inf(psource: PotentialSource, radius: float,
center: Optional[np.ndarray] = None, npoints: int = 100,
center: np.ndarray | None = None, npoints: int = 100,
debug: bool = False) -> np.number:
if center is None:
center = psource.center
Expand Down

0 comments on commit 902226d

Please sign in to comment.