Skip to main content
Logo

Strongly-typed, scalable state container for Python.
Documentation

Simple example

# main.py

from typing import NamedTuple

import pydepot


class State(NamedTuple):
    counter: int


class AddToCounterAction(pydepot.Action):
    def __init__(self, value: int):
        self.value: int = value


class AddToCounterReducer(pydepot.Reducer[AddToCounterAction, State]):
    @property
    def action_type(self) -> type[AddToCounterAction]:
        return AddToCounterAction

    def apply(self, action: AddToCounterAction, state: State) -> State:
        return State(counter=state.counter + action.value)


class CounterSubscriber(pydepot.StoreSubscriber[State]):
    def on_state(self, state: State) -> None:
        print(f"The counter has changed to {state.counter}.")


def main() -> None:
    store = pydepot.Store(initial_state=State(counter=0))
    store.register(AddToCounterReducer())

    subscriber = CounterSubscriber()
    store.subscribe(subscriber)

    store.dispatch(AddToCounterAction(value=42))


if __name__ == "__main__":
    main()
$ python3 main.py

The counter has changed to 42!

Installation

Pydepot is available as pydepot on PyPI:

pip install pydepot

Usage

For detailed quickstart and API reference, visit the Documentation

License

GPLv3

Copyright (C) 2023 tombartk 

This program is free software: you can redistribute it and/or modify it under the terms
of the GNU Affero General Public License as published by the Free Software Foundation,
either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program.
If not, see https://www.gnu.org/licenses/.

Release files for pydepot 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pydepot 0.1.1
File Size Uploaded
pydepot-0.1.1.tar.gz 22.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pydepot 0.1.1
File Interpreter ABI Platform
pydepot-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 41.4 kB

Release files / pydepot-0.1.1.tar.gz

Download URL pydepot-0.1.1.tar.gz
Size 22.8 kB
Tags Source
SHA-256 checksum
How to use checksums
096767d6934a1065b42b1f21dc06cb7345b423b11581f06f3145a8ee99f48dfb
BLAKE2b-256 checksum
How to use checksums
4ed3a75cecdfd3ad2cfe3d958a5ecf6253036b6b38a06bd139428f15d2c3e8bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.24.1

Release files / pydepot-0.1.1-py3-none-any.whl

Download URL pydepot-0.1.1-py3-none-any.whl
Size 18.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
20dd460e7e1cc7f914aba7b413c2d0072103a7b669e008aba947ac81cf039220
BLAKE2b-256 checksum
How to use checksums
e887f758ec58dc4f78d59d78079d04d5c6d51771b320de4e7b2f95a4576a8fe4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.24.1

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page