jsonstate
Manage global App state in a JSON (Python dictionary).
Installation
pip install jsonstate
Usage
from jsonstate import State
state = State({
"title": "State Example",
"profile": {
"name": "Foo",
},
"products": [
{"name": "Foo", "description": "Foo spam"},
{"name": "Bar", "description": "Bar spam"},
]
})
print_event = lambda **kwargs: print("Event", kwargs)
state.callbacks(key="title").append(print_event)
state['profile'].callbacks(key="name").append(print_event)
state['products'].callbacks().append(print_event)
# This statement updates the state and also invokes on_change callback:
state["title"] = "Eggs"
# Event {'new_value': 'Eggs', 'old_value': 'State Example', 'action': 'update'}
state["profile"]["name"] = "Spam"
# Event {'new_value': 'Spam', 'old_value': 'Foo', 'action': 'update'}
# This statement also updates the state and invokes on_change callback:
state["products"].append({"name": "Eggs", "description": "Eggs spam"})
# Event {'new_value': {'name': 'Eggs', 'description': 'Eggs spam'}, 'action': 'add'}
Development
Commonly used commands for package development:
make check- run unit tests and linters.make fix- format code and fix detected fixable issues.make publish- publishes current package version to pypi.org.make compile- bump and freeze dependency versions in requirements*.txt filesmake sync- upgrade installed dependencies in Virtual Environment (executed aftermake compile)
Toolset
This package uses these cutting edge tools:
- ruff - for linting and code formatting
- mypy - for type checking
- pip-audit - for known vulnerability detection in dependencies
- deadcode - for unused code detection
- pytest - for collecting and running unit tests
- coverage - for code coverage by unit tests
- hatch - for publishing package to pypi.org
- uv - for Python virtual environment and dependency management
- pyproject.toml - configuration file for all tools
- Makefile - aliases for commonly used command line commands
Metadata
Release files for jsonstate 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jsonstate-0.0.6.tar.gz | 5.5 kB | Without provenance | Details for jsonstate-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jsonstate-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for jsonstate-0.0.6-py3-none-any.whl |
Total release size: 9.5 kB
Release files / jsonstate-0.0.6.tar.gz
| Download URL | jsonstate-0.0.6.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e7f5259946cc9d240d7e17681ae1add8b9161a041f3327736c9b76aa7f0507e2
|
|
BLAKE2b-256 checksum How to use checksums |
71d0063885192c6e1aebe29e6da093f215052df1564c9e72771b9578f879a629
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.28.1
|
Release files / jsonstate-0.0.6-py3-none-any.whl
| Download URL | jsonstate-0.0.6-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
204fee0feb786fddab20e12387328d20b9fcb3f217f10a4c0b01d6ae6d4f65f3
|
|
BLAKE2b-256 checksum How to use checksums |
34979f621886021cf61e602409838098a5802ee3691650ded7496e6a5d0016f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.28.1
|
Security for jsonstate 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.