Skip to content

Commit 39332c7

Browse files
committed
Add ruff fixes for new min Python version
1 parent 12274bf commit 39332c7

File tree

7 files changed

+15
-8
lines changed

7 files changed

+15
-8
lines changed

src/data_morph/plotting/animation.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
import re
77
from functools import wraps
88
from pathlib import Path
9-
from typing import TYPE_CHECKING, Callable
9+
from typing import TYPE_CHECKING
1010

1111
from PIL import Image
1212

1313
if TYPE_CHECKING:
14+
from collections.abc import Callable
15+
1416
from ..shapes.bases.shape import Shape
1517

1618

@@ -115,7 +117,7 @@ def wrapper(step: int | float) -> int | float:
115117
int or float
116118
The eased value at the current step, from 0.0 to 1.0.
117119
"""
118-
if not (isinstance(step, (int, float)) and 0 <= step <= 1):
120+
if not (isinstance(step, int | float) and 0 <= step <= 1):
119121
raise ValueError('Step must be an integer or float, between 0 and 1.')
120122
return easing_function(step)
121123

src/data_morph/plotting/style.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
"""Utility functions for styling Matplotlib plots."""
22

3-
from collections.abc import Generator
3+
from collections.abc import Callable, Generator
44
from contextlib import contextmanager
55
from functools import wraps
66
from importlib.resources import as_file, files
77
from pathlib import Path
8-
from typing import Any, Callable
8+
from typing import Any
99

1010
import matplotlib.pyplot as plt
1111

src/data_morph/shapes/bases/line_collection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,5 @@ def plot(self, ax: Axes | None = None) -> Axes:
121121
fig.get_layout_engine().set(w_pad=0.2, h_pad=0.2)
122122
_ = ax.axis('equal')
123123
for start, end in self.lines:
124-
ax.plot(*list(zip(start, end)), 'k-')
124+
ax.plot(*list(zip(start, end, strict=False)), 'k-')
125125
return ax

src/data_morph/shapes/lines/star.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Star shape."""
22

3+
import itertools
4+
35
from ...data.dataset import Dataset
46
from ..bases.line_collection import LineCollection
57

@@ -46,4 +48,4 @@ def __init__(self, dataset: Dataset) -> None:
4648
[xmin, ymin + y_range * 0.625],
4749
]
4850

49-
super().__init__(*list(zip(pts[:-1], pts[1:])))
51+
super().__init__(*list(itertools.pairwise(pts)))

tests/bounds/test_interval.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def test_getitem(self):
9191
def test_iter(self):
9292
"""Test that the __iter__() method is working."""
9393
limits = [0, 1]
94-
for bound, limit in zip(Interval(limits), limits):
94+
for bound, limit in zip(Interval(limits), limits, strict=False):
9595
assert bound == limit
9696

9797
@pytest.mark.parametrize(

tests/data/test_loader.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ def test_plot_available_datasets(self, monkeypatch, subset):
6767
assert len(populated_axs) == len(DataLoader.AVAILABLE_DATASETS)
6868
assert all(ax.get_xlabel() == ax.get_ylabel() == '' for ax in populated_axs)
6969

70-
for dataset, ax in zip(DataLoader.AVAILABLE_DATASETS, populated_axs):
70+
for dataset, ax in zip(
71+
DataLoader.AVAILABLE_DATASETS, populated_axs, strict=False
72+
):
7173
subplot_title = ax.get_title()
7274
assert subplot_title.startswith(dataset)
7375
assert subplot_title.endswith(' points)')

tests/shapes/circles/test_circle.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ def test_is_circle(self, shape):
3232
for x, y in zip(
3333
cx + shape.radius * np.cos(angles),
3434
cy + shape.radius * np.sin(angles),
35+
strict=False,
3536
):
3637
assert pytest.approx(shape.distance(x, y)) == 0

0 commit comments

Comments
 (0)