Skip to content

Commit 4d77303

Browse files
committed
style: add missing type hints
1 parent 64c3b12 commit 4d77303

File tree

9 files changed

+40
-31
lines changed

9 files changed

+40
-31
lines changed

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def serialize(self, data: Image, **_kwargs: Any) -> SerializedData:
2020

2121

2222
@pytest.fixture()
23-
def snapshot_jpeg(snapshot) -> SnapshotAssertion:
23+
def snapshot_jpeg(snapshot: SnapshotAssertion) -> SnapshotAssertion:
2424
return snapshot.use_extension(JPEGImageExtension)
2525

2626

@@ -32,5 +32,5 @@ def serialize(self, data: Image, **_kwargs: Any) -> SerializedData:
3232

3333

3434
@pytest.fixture()
35-
def snapshot_png(snapshot) -> SnapshotAssertion:
35+
def snapshot_png(snapshot: SnapshotAssertion) -> SnapshotAssertion:
3636
return snapshot.use_extension(PNGImageSnapshotExtension)

tests/safeds/data/image/containers/test_image.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from safeds.data.image.typing import ImageFormat
77
from safeds.data.tabular.containers import Table
88
from safeds.exceptions import OutOfBoundsError
9+
from syrupy import SnapshotAssertion
910

1011
from tests.helpers import resolve_resource_path
1112

@@ -236,7 +237,7 @@ class TestConvertToGrayscale:
236237
["image/plane.png"],
237238
ids=["plane"],
238239
)
239-
def test_convert_to_grayscale(self, resource_path: str, snapshot_png) -> None:
240+
def test_convert_to_grayscale(self, resource_path: str, snapshot_png: SnapshotAssertion) -> None:
240241
image = Image.from_png_file(resolve_resource_path(resource_path))
241242
assert image.convert_to_grayscale() == snapshot_png
242243

@@ -264,7 +265,7 @@ class TestFlipVertically:
264265
["image/plane.png"],
265266
ids=["plane"],
266267
)
267-
def test_should_flip_vertically(self, resource_path: str, snapshot_png) -> None:
268+
def test_should_flip_vertically(self, resource_path: str, snapshot_png: SnapshotAssertion) -> None:
268269
image = Image.from_png_file(resolve_resource_path(resource_path))
269270
assert image.flip_vertically() == snapshot_png
270271

@@ -280,7 +281,7 @@ class TestFlipHorizontally:
280281
["image/plane.png"],
281282
ids=["plane"],
282283
)
283-
def test_should_flip_horizontally(self, resource_path: str, snapshot_png) -> None:
284+
def test_should_flip_horizontally(self, resource_path: str, snapshot_png: SnapshotAssertion) -> None:
284285
image = Image.from_png_file(resolve_resource_path(resource_path))
285286
assert image.flip_horizontally() == snapshot_png
286287

@@ -295,11 +296,11 @@ class TestAdjustContrast:
295296
("resource_path", "factor"),
296297
[
297298
("image/plane.png", 0.75),
298-
("image/plane.png", 5)
299+
("image/plane.png", 5),
299300
],
300-
ids=["small factor", "large factor"]
301+
ids=["small factor", "large factor"],
301302
)
302-
def test_should_adjust_contrast(self, resource_path: str, factor: float, snapshot_png) -> None:
303+
def test_should_adjust_contrast(self, resource_path: str, factor: float, snapshot_png: SnapshotAssertion) -> None:
303304
image = Image.from_png_file(resolve_resource_path(resource_path))
304305
assert image.adjust_contrast(factor) == snapshot_png
305306

@@ -323,11 +324,11 @@ class TestAdjustBrightness:
323324
("resource_path", "factor"),
324325
[
325326
("image/plane.png", 0.5),
326-
("image/plane.png", 10)
327+
("image/plane.png", 10),
327328
],
328-
ids=["small factor", "large factor"]
329+
ids=["small factor", "large factor"],
329330
)
330-
def test_should_adjust_brightness(self, resource_path: str, factor: float, snapshot_png) -> None:
331+
def test_should_adjust_brightness(self, resource_path: str, factor: float, snapshot_png: SnapshotAssertion) -> None:
331332
image = Image.from_png_file(resolve_resource_path(resource_path))
332333
assert image.adjust_brightness(factor) == snapshot_png
333334

@@ -352,7 +353,7 @@ class TestInvertColors:
352353
["image/plane.png"],
353354
ids=["invert-colors"],
354355
)
355-
def test_should_invert_colors(self, resource_path: str, snapshot_png) -> None:
356+
def test_should_invert_colors(self, resource_path: str, snapshot_png: SnapshotAssertion) -> None:
356357
image = Image.from_png_file(resolve_resource_path(resource_path))
357358
assert image.invert_colors() == snapshot_png
358359

@@ -367,7 +368,7 @@ class TestColorAdjust:
367368
],
368369
ids=["add color", "remove color", "remove all color"],
369370
)
370-
def test_should_adjust_colors(self, resource_path: str, factor: float, snapshot_png) -> None:
371+
def test_should_adjust_colors(self, resource_path: str, factor: float, snapshot_png: SnapshotAssertion) -> None:
371372
image = Image.from_png_file(resolve_resource_path(resource_path))
372373
assert image.adjust_color_balance(factor) == snapshot_png
373374

@@ -410,7 +411,9 @@ class TestAddGaussianNoise:
410411
],
411412
ids=["minimum noise", "some noise", "very noisy"],
412413
)
413-
def test_should_add_noise(self, resource_path: str, standard_deviation: float, snapshot_png) -> None:
414+
def test_should_add_noise(
415+
self, resource_path: str, standard_deviation: float, snapshot_png: SnapshotAssertion
416+
) -> None:
414417
image = Image.from_png_file(resolve_resource_path(resource_path))
415418
assert image.add_gaussian_noise(standard_deviation) == snapshot_png
416419

@@ -435,7 +438,7 @@ class TestBlur:
435438
["image/plane.png"],
436439
ids=["blur"],
437440
)
438-
def test_should_return_blurred_image(self, resource_path: str, snapshot_png) -> None:
441+
def test_should_return_blurred_image(self, resource_path: str, snapshot_png: SnapshotAssertion) -> None:
439442
image = Image.from_png_file(resolve_resource_path(resource_path))
440443
assert image.blur(2) == snapshot_png
441444

@@ -446,7 +449,7 @@ class TestCrop:
446449
["image/plane.png"],
447450
ids=["crop"],
448451
)
449-
def test_should_return_cropped_image(self, resource_path: str, snapshot_png) -> None:
452+
def test_should_return_cropped_image(self, resource_path: str, snapshot_png: SnapshotAssertion) -> None:
450453
image = Image.from_png_file(resolve_resource_path(resource_path))
451454
assert image.crop(0, 0, 100, 100) == snapshot_png
452455

@@ -461,7 +464,7 @@ class TestSharpen:
461464
],
462465
ids=["negative factor", "small factor", "large factor"],
463466
)
464-
def test_should_sharpen(self, resource_path: str, factor: float, snapshot_png) -> None:
467+
def test_should_sharpen(self, resource_path: str, factor: float, snapshot_png: SnapshotAssertion) -> None:
465468
image = Image.from_png_file(resolve_resource_path(resource_path))
466469
assert image.sharpen(factor) == snapshot_png
467470

@@ -477,7 +480,7 @@ class TestRotate:
477480
["image/plane.png"],
478481
ids=["rotate-clockwise"],
479482
)
480-
def test_should_return_clockwise_rotated_image(self, resource_path: str, snapshot_png) -> None:
483+
def test_should_return_clockwise_rotated_image(self, resource_path: str, snapshot_png: SnapshotAssertion) -> None:
481484
image = Image.from_png_file(resolve_resource_path(resource_path))
482485
assert image.rotate_right() == snapshot_png
483486

@@ -486,7 +489,9 @@ def test_should_return_clockwise_rotated_image(self, resource_path: str, snapsho
486489
["image/plane.png"],
487490
ids=["rotate-counter-clockwise"],
488491
)
489-
def test_should_return_counter_clockwise_rotated_image(self, resource_path: str, snapshot_png) -> None:
492+
def test_should_return_counter_clockwise_rotated_image(
493+
self, resource_path: str, snapshot_png: SnapshotAssertion
494+
) -> None:
490495
image = Image.from_png_file(resolve_resource_path(resource_path))
491496
assert image.rotate_left() == snapshot_png
492497

@@ -497,6 +502,6 @@ class TestFindEdges:
497502
["image/plane.png"],
498503
ids=["find_edges"],
499504
)
500-
def test_should_return_edges_of_image(self, resource_path: str, snapshot_png) -> None:
505+
def test_should_return_edges_of_image(self, resource_path: str, snapshot_png: SnapshotAssertion) -> None:
501506
image = Image.from_png_file(resolve_resource_path(resource_path))
502507
assert image.find_edges() == snapshot_png

tests/safeds/data/tabular/containers/_column/test_plot_boxplot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import pytest
22
from safeds.data.tabular.containers import Table
33
from safeds.exceptions import NonNumericColumnError
4+
from syrupy import SnapshotAssertion
45

56

6-
def test_should_match_snapshot(snapshot_png) -> None:
7+
def test_should_match_snapshot(snapshot_png: SnapshotAssertion) -> None:
78
table = Table({"A": [1, 2, 3]})
89
boxplot = table.get_column("A").plot_boxplot()
910
assert boxplot == snapshot_png
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
from safeds.data.tabular.containers import Table
2+
from syrupy import SnapshotAssertion
23

34

4-
def test_should_match_snapshot_numeric(snapshot_png) -> None:
5+
def test_should_match_snapshot_numeric(snapshot_png: SnapshotAssertion) -> None:
56
table = Table({"A": [1, 2, 3]})
67
histogram = table.get_column("A").plot_histogram()
78
assert histogram == snapshot_png
89

910

10-
def test_should_match_snapshot_str(snapshot_png) -> None:
11+
def test_should_match_snapshot_str(snapshot_png: SnapshotAssertion) -> None:
1112
table = Table({"A": ["A", "B", "Apple"]})
1213
histogram = table.get_column("A").plot_histogram()
1314
assert histogram == snapshot_png

tests/safeds/data/tabular/containers/_table/test_plot_boxplots.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pytest
22
from safeds.data.tabular.containers import Table
33
from safeds.exceptions import NonNumericColumnError
4+
from syrupy import SnapshotAssertion
45

56

67
@pytest.mark.parametrize(
@@ -12,7 +13,7 @@
1213
],
1314
ids=["one column", "four columns (some non-numeric)", "four columns (all numeric)"],
1415
)
15-
def test_should_match_snapshot(table: Table, snapshot_png) -> None:
16+
def test_should_match_snapshot(table: Table, snapshot_png: SnapshotAssertion) -> None:
1617
boxplots = table.plot_boxplots()
1718
assert boxplots == snapshot_png
1819

tests/safeds/data/tabular/containers/_table/test_plot_correlation_heatmap.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22
from safeds.data.tabular.containers import Table
3+
from syrupy import SnapshotAssertion
34

45

56
@pytest.mark.parametrize(
@@ -9,7 +10,7 @@
910
],
1011
ids=["normal"],
1112
)
12-
def test_should_match_snapshot(table: Table, snapshot_png) -> None:
13+
def test_should_match_snapshot(table: Table, snapshot_png: SnapshotAssertion) -> None:
1314
correlation_heatmap = table.plot_correlation_heatmap()
1415
assert correlation_heatmap == snapshot_png
1516

tests/safeds/data/tabular/containers/_table/test_plot_histograms.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import pytest
2-
from safeds.data.image.containers import Image
32
from safeds.data.tabular.containers import Table
4-
5-
from tests.helpers import resolve_resource_path
3+
from syrupy import SnapshotAssertion
64

75

86
@pytest.mark.parametrize(
@@ -20,7 +18,7 @@
2018
],
2119
ids=["one column", "four columns"],
2220
)
23-
def test_should_match_snapshot(table: Table, snapshot_png) -> None:
21+
def test_should_match_snapshot(table: Table, snapshot_png: SnapshotAssertion) -> None:
2422
histograms = table.plot_histograms()
2523
assert histograms == snapshot_png
2624

tests/safeds/data/tabular/containers/_table/test_plot_lineplot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import pytest
22
from safeds.data.tabular.containers import Table
33
from safeds.exceptions import UnknownColumnNameError
4+
from syrupy import SnapshotAssertion
45

56

6-
def test_should_match_snapshot(snapshot_png) -> None:
7+
def test_should_match_snapshot(snapshot_png: SnapshotAssertion) -> None:
78
table = Table({"A": [1, 2, 3], "B": [2, 4, 7]})
89
lineplot = table.plot_lineplot("A", "B")
910
assert lineplot == snapshot_png

tests/safeds/data/tabular/containers/_table/test_plot_scatterplot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import pytest
22
from safeds.data.tabular.containers import Table
33
from safeds.exceptions import UnknownColumnNameError
4+
from syrupy import SnapshotAssertion
45

56

6-
def test_should_match_snapshot(snapshot_png) -> None:
7+
def test_should_match_snapshot(snapshot_png: SnapshotAssertion) -> None:
78
table = Table({"A": [1, 2, 3], "B": [2, 4, 7]})
89
scatterplot = table.plot_scatterplot("A", "B")
910
assert scatterplot == snapshot_png

0 commit comments

Comments
 (0)