11
2+ from dataclasses import field , replace
3+
24import pytest
3- from redux .main import Store
4- from redux .basic_types import BaseAction , StoreOptions
5- from dataclasses import replace , field
65from immutable import Immutable
76
7+ from redux .basic_types import BaseAction , StoreOptions
8+ from redux .main import Store
9+
10+
811class State (Immutable ):
912 value : int
1013 nested : dict = field (default_factory = dict )
@@ -23,49 +26,48 @@ def reducer(state, action):
2326def store ():
2427 return Store (reducer , options = StoreOptions (auto_init = True ))
2528
26- def test_autorun_creation (benchmark , store ):
29+ def test_autorun_creation (benchmark , store ) -> None :
2730 """Benchmark creating autoruns."""
28-
29- def run ():
31+
32+ def run () -> None :
3033 @store .autorun (lambda s : s .value )
31- def _ (val ):
34+ def _ (val ) -> None :
3235 pass
3336
3437 benchmark (run )
3538
36- def test_autorun_reactivity (benchmark , store ):
39+ def test_autorun_reactivity (benchmark , store ) -> None :
3740 """Benchmark autorun reaction overhead."""
38-
41+
3942 @store .autorun (lambda s : s .value )
40- def _ (val ):
43+ def _ (val ) -> None :
4144 pass
42-
43- def run ():
45+
46+ def run () -> None :
4447 store .dispatch (IncrementAction ())
4548
4649 benchmark (run )
4750
48- def test_autorun_complex_selector (benchmark , store ):
51+ def test_autorun_complex_selector (benchmark , store ) -> None :
4952 """Benchmark autorun with complex selector."""
50-
53+
5154 @store .autorun (lambda s : s .value * 2 + (s .nested .get ('a' , 0 ) or 0 ))
52- def _ (val ):
55+ def _ (val ) -> None :
5356 pass
5457
55- def run ():
58+ def run () -> None :
5659 store .dispatch (IncrementAction ())
5760
5861 benchmark (run )
5962
60- def test_autorun_many_subscribers (benchmark , store ):
63+ def test_autorun_many_subscribers (benchmark , store ) -> None :
6164 """Benchmark notification of many autoruns."""
62-
6365 for _ in range (100 ):
6466 @store .autorun (lambda s : s .value )
65- def _ (val ):
67+ def _ (val ) -> None :
6668 pass
6769
68- def run ():
70+ def run () -> None :
6971 store .dispatch (IncrementAction ())
7072
7173 benchmark (run )
0 commit comments