Skip to content

Commit

Permalink
refactor: remove create_store closure in favor of Store class wit…
Browse files Browse the repository at this point in the history
…h identical api
  • Loading branch information
sassanh committed Feb 18, 2024
1 parent 8f145d8 commit eb445bd
Show file tree
Hide file tree
Showing 10 changed files with 441 additions and 288 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Version 0.10.0

- refactor: remove `create_store` closure in favor of `Store` class with identical
api

## Version 0.9.25

- feat: all subscriptions/listeners with `keep_ref`, now use `WeakMethod` for methods
Expand Down
11 changes: 6 additions & 5 deletions demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@

import time

from immutable import Immutable

from redux import (
BaseAction,
BaseCombineReducerState,
CombineReducerAction,
CombineReducerRegisterAction,
CombineReducerUnregisterAction,
Immutable,
InitAction,
InitializationActionError,
Store,
combine_reducers,
create_store,
)
from redux.basic_types import (
BaseEvent,
Expand Down Expand Up @@ -115,8 +116,8 @@ def inverse_reducer(

reducer, reducer_id = combine_reducers(
state_type=StateType,
action_type=ActionType,
event_type=SleepEvent | PrintEvent,
action_type=ActionType, # pyright: ignore [reportArgumentType]
event_type=SleepEvent | PrintEvent, # pyright: ignore [reportArgumentType]
straight=straight_reducer,
base10=base10_reducer,
)
Expand All @@ -125,7 +126,7 @@ def inverse_reducer(

def main() -> None:
# Initialization <
store = create_store(
store = Store(
reducer,
CreateStoreOptions(auto_init=True, threads=2),
)
Expand Down
54 changes: 27 additions & 27 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 21 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
[tool.poetry]
name = "python-redux"
version = "0.9.24"
version = "0.10.0"
description = "Redux implementation for Python"
authors = ["Sassan Haradji <[email protected]>"]
license = "Apache-2.0"
readme = "README.md"
packages = [{ include = "redux" }]

[tool.poetry.dependencies]
python = "^3.9"
python-immutable = "^1.0.0"
python = "^3.11"
python-immutable = "^1.0.2"
typing-extensions = "^4.9.0"


[tool.poetry.scripts]
demo = "demo:main"
todo_demo = "todo_demo:main"

[tool.poetry.group.dev]
optional = true

[tool.poetry.group.dev.dependencies]
poethepoet = "^0.24.3"
pyright = "^1.1.349"
ruff = "^0.1.9"
poethepoet = "^0.24.4"
pyright = "^1.1.350"
ruff = "^0.2.2"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.scripts]
demo = "demo:main"
todo_demo = "todo_demo:main"

[tool.poe.tasks]
lint = "pyright -p pyproject.toml ."
lint = "ruff . --unsafe-fixes"
typecheck = "pyright -p pyproject.toml ."
sanity = ["typecheck", "lint"]

[tool.ruff]
select = ['ALL']
ignore = []
lint.select = ['ALL']
lint.ignore = ['INP001', 'PLR0911', 'D203', 'D213']
lint.fixable = ['ALL']
lint.unfixable = []

fixable = ['ALL']
unfixable = []

[tool.ruff.flake8-quotes]
[tool.ruff.lint.flake8-quotes]
docstring-quotes = "double"
inline-quotes = "single"
multiline-quotes = "double"
Expand All @@ -49,3 +49,6 @@ quote-style = 'single'

[tool.isort]
profile = "black"

[tool.pyright]
exclude = ['typings']
67 changes: 64 additions & 3 deletions redux/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,64 @@
from .basic_types import *
from .main import *
from .combine_reducers import *
"""Redux-like state management for Python."""
from .basic_types import (
AutorunDecorator,
AutorunOptions,
AutorunReturnType,
AutorunType,
BaseAction,
BaseEvent,
CompleteReducerResult,
CreateStoreOptions,
Dispatch,
DispatchParameters,
EventSubscriber,
EventSubscriptionOptions,
FinishAction,
FinishEvent,
InitAction,
InitializationActionError,
ReducerResult,
ReducerType,
Scheduler,
is_complete_reducer_result,
is_state_reducer_result,
)
from .combine_reducers import (
BaseCombineReducerState,
CombineReducerAction,
CombineReducerInitAction,
CombineReducerRegisterAction,
CombineReducerUnregisterAction,
combine_reducers,
)
from .main import Store

__all__ = (
'AutorunDecorator',
'AutorunOptions',
'AutorunReturnType',
'AutorunType',
'BaseAction',
'BaseEvent',
'CompleteReducerResult',
'CreateStoreOptions',
'Dispatch',
'DispatchParameters',
'EventSubscriber',
'EventSubscriptionOptions',
'FinishAction',
'FinishEvent',
'InitAction',
'InitializationActionError',
'ReducerResult',
'ReducerType',
'Scheduler',
'is_complete_reducer_result',
'is_state_reducer_result',
'BaseCombineReducerState',
'CombineReducerAction',
'CombineReducerInitAction',
'CombineReducerRegisterAction',
'CombineReducerUnregisterAction',
'combine_reducers',
'Store',
)
Loading

0 comments on commit eb445bd

Please sign in to comment.