Skip to content

Commit eb445bd

Browse files
committed
refactor: remove create_store closure in favor of Store class with identical api
1 parent 8f145d8 commit eb445bd

File tree

10 files changed

+441
-288
lines changed

10 files changed

+441
-288
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## Version 0.10.0
4+
5+
- refactor: remove `create_store` closure in favor of `Store` class with identical
6+
api
7+
38
## Version 0.9.25
49

510
- feat: all subscriptions/listeners with `keep_ref`, now use `WeakMethod` for methods

demo.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@
33

44
import time
55

6+
from immutable import Immutable
7+
68
from redux import (
79
BaseAction,
810
BaseCombineReducerState,
911
CombineReducerAction,
1012
CombineReducerRegisterAction,
1113
CombineReducerUnregisterAction,
12-
Immutable,
1314
InitAction,
1415
InitializationActionError,
16+
Store,
1517
combine_reducers,
16-
create_store,
1718
)
1819
from redux.basic_types import (
1920
BaseEvent,
@@ -115,8 +116,8 @@ def inverse_reducer(
115116

116117
reducer, reducer_id = combine_reducers(
117118
state_type=StateType,
118-
action_type=ActionType,
119-
event_type=SleepEvent | PrintEvent,
119+
action_type=ActionType, # pyright: ignore [reportArgumentType]
120+
event_type=SleepEvent | PrintEvent, # pyright: ignore [reportArgumentType]
120121
straight=straight_reducer,
121122
base10=base10_reducer,
122123
)
@@ -125,7 +126,7 @@ def inverse_reducer(
125126

126127
def main() -> None:
127128
# Initialization <
128-
store = create_store(
129+
store = Store(
129130
reducer,
130131
CreateStoreOptions(auto_init=True, threads=2),
131132
)

poetry.lock

Lines changed: 27 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
11
[tool.poetry]
22
name = "python-redux"
3-
version = "0.9.24"
3+
version = "0.10.0"
44
description = "Redux implementation for Python"
55
authors = ["Sassan Haradji <sassanh@gmail.com>"]
66
license = "Apache-2.0"
77
readme = "README.md"
88
packages = [{ include = "redux" }]
99

1010
[tool.poetry.dependencies]
11-
python = "^3.9"
12-
python-immutable = "^1.0.0"
11+
python = "^3.11"
12+
python-immutable = "^1.0.2"
1313
typing-extensions = "^4.9.0"
1414

15-
16-
[tool.poetry.scripts]
17-
demo = "demo:main"
18-
todo_demo = "todo_demo:main"
19-
2015
[tool.poetry.group.dev]
2116
optional = true
2217

2318
[tool.poetry.group.dev.dependencies]
24-
poethepoet = "^0.24.3"
25-
pyright = "^1.1.349"
26-
ruff = "^0.1.9"
19+
poethepoet = "^0.24.4"
20+
pyright = "^1.1.350"
21+
ruff = "^0.2.2"
2722

2823
[build-system]
2924
requires = ["poetry-core"]
3025
build-backend = "poetry.core.masonry.api"
3126

27+
[tool.poetry.scripts]
28+
demo = "demo:main"
29+
todo_demo = "todo_demo:main"
30+
3231
[tool.poe.tasks]
33-
lint = "pyright -p pyproject.toml ."
32+
lint = "ruff . --unsafe-fixes"
33+
typecheck = "pyright -p pyproject.toml ."
34+
sanity = ["typecheck", "lint"]
3435

3536
[tool.ruff]
36-
select = ['ALL']
37-
ignore = []
37+
lint.select = ['ALL']
38+
lint.ignore = ['INP001', 'PLR0911', 'D203', 'D213']
39+
lint.fixable = ['ALL']
40+
lint.unfixable = []
3841

39-
fixable = ['ALL']
40-
unfixable = []
41-
42-
[tool.ruff.flake8-quotes]
42+
[tool.ruff.lint.flake8-quotes]
4343
docstring-quotes = "double"
4444
inline-quotes = "single"
4545
multiline-quotes = "double"
@@ -49,3 +49,6 @@ quote-style = 'single'
4949

5050
[tool.isort]
5151
profile = "black"
52+
53+
[tool.pyright]
54+
exclude = ['typings']

redux/__init__.py

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,64 @@
1-
from .basic_types import *
2-
from .main import *
3-
from .combine_reducers import *
1+
"""Redux-like state management for Python."""
2+
from .basic_types import (
3+
AutorunDecorator,
4+
AutorunOptions,
5+
AutorunReturnType,
6+
AutorunType,
7+
BaseAction,
8+
BaseEvent,
9+
CompleteReducerResult,
10+
CreateStoreOptions,
11+
Dispatch,
12+
DispatchParameters,
13+
EventSubscriber,
14+
EventSubscriptionOptions,
15+
FinishAction,
16+
FinishEvent,
17+
InitAction,
18+
InitializationActionError,
19+
ReducerResult,
20+
ReducerType,
21+
Scheduler,
22+
is_complete_reducer_result,
23+
is_state_reducer_result,
24+
)
25+
from .combine_reducers import (
26+
BaseCombineReducerState,
27+
CombineReducerAction,
28+
CombineReducerInitAction,
29+
CombineReducerRegisterAction,
30+
CombineReducerUnregisterAction,
31+
combine_reducers,
32+
)
33+
from .main import Store
34+
35+
__all__ = (
36+
'AutorunDecorator',
37+
'AutorunOptions',
38+
'AutorunReturnType',
39+
'AutorunType',
40+
'BaseAction',
41+
'BaseEvent',
42+
'CompleteReducerResult',
43+
'CreateStoreOptions',
44+
'Dispatch',
45+
'DispatchParameters',
46+
'EventSubscriber',
47+
'EventSubscriptionOptions',
48+
'FinishAction',
49+
'FinishEvent',
50+
'InitAction',
51+
'InitializationActionError',
52+
'ReducerResult',
53+
'ReducerType',
54+
'Scheduler',
55+
'is_complete_reducer_result',
56+
'is_state_reducer_result',
57+
'BaseCombineReducerState',
58+
'CombineReducerAction',
59+
'CombineReducerInitAction',
60+
'CombineReducerRegisterAction',
61+
'CombineReducerUnregisterAction',
62+
'combine_reducers',
63+
'Store',
64+
)

0 commit comments

Comments
 (0)