python-hooks


Namepython-hooks JSON
Version 0.2.1 PyPI version JSON
download
home_pagehttps://github.com/amitassaraf/python-hooks
SummaryA React inspired way to code in Python
upload_time2023-08-19 20:42:17
maintainer
docs_urlNone
authorAmit Assaraf
requires_python>=3.9,<4.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python Hooks

<div align="center">

[![Build status](https://github.com/amitassaraf/python-hooks/workflows/build/badge.svg?branch=master&event=push)](https://github.com/amitassaraf/python-hooks/actions?query=workflow%3Abuild)
[![Python Version](https://img.shields.io/pypi/pyversions/python-hooks.svg)](https://pypi.org/project/python-hooks/)
[![Dependencies Status](https://img.shields.io/badge/dependencies-up%20to%20date-brightgreen.svg)](https://github.com/amitassaraf/python-hooks/pulls?utf8=%E2%9C%93&q=is%3Apr%20author%3Aapp%2Fdependabot)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Security: bandit](https://img.shields.io/badge/security-bandit-green.svg)](https://github.com/PyCQA/bandit)
[![Pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/amitassaraf/python-hooks/blob/master/.pre-commit-config.yaml)
[![Semantic Versions](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--versions-e10079.svg)](https://github.com/amitassaraf/python-hooks/releases)
[![License](https://img.shields.io/github/license/amitassaraf/python-hooks)](https://github.com/amitassaraf/python-hooks/blob/master/LICENSE)
![Coverage Report](assets/images/coverage.svg)
<a href="https://github.com/amitassaraf/python-hooks/graphs/contributors">
  <img alt="GitHub Contributors" src="https://img.shields.io/github/contributors/amitassaraf/python-hooks" />
</a>
<a href="https://github.com/amitassaraf/python-hooks/issues">
  <img alt="Issues" src="https://img.shields.io/github/issues/amitassaraf/python-hooks?color=0088ff" />
</a>
<a href="https://github.com/amitassaraf/python-hooks/pulls">
  <img alt="GitHub pull requests" src="https://img.shields.io/github/issues-pr/amitassaraf/python-hooks?color=0088ff" />
</a>
<img alt="Dev status" src="https://img.shields.io/badge/project_is_in-beta-red" />

---


### A React inspired way to code in Python.
</div>

<div align="center">
<img src="docs/images/simple_code_example.png" alt="drawing" width="500"/>
<br/>
<br/>
<a href="https://github.com/amitassaraf/python-hooks">
  <img alt="Made with love by Amit Assaraf" src="https://img.shields.io/badge/made_with_❤️_by-amitassaraf-red?color=ff1744" />
</a>
<br/>
If you like this project, consider starring it on Github ⭐⭐⭐⭐  
</div>
<br/>

* ⚡️ Written with performance in mind __(Not using inspect module)__
* 🐍 Support for familiar React like hooks such as `use_state`, `use_effect`, `use_reducer`, `use_context` and more.
* 🛠️ Built with plugins support and easy to extend.
* 🤝 Python 3.9+ compatibility
* 🪶 Lightweight to remove the need for a lot of boilerplate code.
* 📦 Support for different backend state-stores.
* 🔧 Support for hooks-state scoping.
* 🌎 Redis, Redux, and Zustand plugins out of the box. 
* 🔌 Tested mainly on CPython.

---

## Inspiration

I'll begin be prefacing that this project will not fit everyone's needs. It's a very opinionated project and it's not meant to be a replacement for any of the existing state management libraries.
Additionally, if you are trying to squeeze the most performance out of Python this is probably not the right tool for you _(Though you might also be using the wrong programming language)_.

The goal of the project is to provide a simple and familiar way to manage state in Python. It's inspired by the React hooks API and it's meant to be used in a similar way. It can be used to manage 
state in a single function or in a large project. The state can be stored in memory, in a database or in a file. It's up to you to decide and the library is easily extendable to support any backend.

One of the inspirations for this project was seeing the way junior developers struggle with state management and program structure in Python. This library is intended to provide a sense of familiarity
to developers coming from the JavaScript world and to provide a simple way to manage state in Python which will not require a lot of boilerplate code or hurt performance.

It is meant to help write better data-driven code and to help developers focus on the business logic of their code rather than on the plumbing.


[**Discord**](https://discord.gg/mayParnv) | [**Docs**](https://amitassaraf.github.io/python-hooks/) 

<img src="https://img.shields.io/badge/⚠️ Not_recommended_for_production_use_just_yet-ff9966" />

Note: This project is still in beta and is not recommended for production use just yet. We are working on adding more tests and improving the documentation. If you are interested in contributing, please reach out to me on [Discord](https://discord.gg/mayParnv).

---

## Let's see one API example

As Python is commonly used to create APIs, I wanted to provide one real-world example of using hooks for state management in Flask. Note, that this is just one example and the library can be used in many other ways. See [examples](https://github.com/amitassaraf/python-hooks/tree/master/examples)
 for more examples.

<img src="docs/images/flask_example.png" alt="drawing" width="500"/>

### Pretty neat, right?


## 🚀 Installation

```bash
pip install python-hooks
```

## 🎯 What's next

Well, that's up to you 💪🏻. We are looking for contributors to help us build this project and make it better. If you are interested in contributing, please reach out to me on [Discord](https://discord.gg/mayParnv) or open an issue. 
In addition we are looking for plugin developers to help us build more plugins for different state stores.

## 📈 Releases

You can see the list of available releases on the [GitHub Releases](https://github.com/amitassaraf/python-hooks/releases) page.

We follow [Semantic Versions](https://semver.org/) specification.

We use [`Release Drafter`](https://github.com/marketplace/actions/release-drafter). As pull requests are merged, a draft release is kept up-to-date listing the changes, ready to publish when you’re ready. With the categories option, you can categorize pull requests in release notes using labels.

### List of labels and corresponding titles

|               **Label**               |  **Title in Releases**  |
| :-----------------------------------: | :---------------------: |
|       `enhancement`, `feature`        |       🚀 Features       |
| `bug`, `refactoring`, `bugfix`, `fix` | 🔧 Fixes & Refactoring  |
|       `build`, `ci`, `testing`        | 📦 Build System & CI/CD |
|              `breaking`               |   💥 Breaking Changes   |
|            `documentation`            |    📝 Documentation     |
|            `dependencies`             | ⬆️ Dependencies updates |


GitHub creates the `bug`, `enhancement`, and `documentation` labels for you. Dependabot creates the `dependencies` label. Create the remaining labels on the Issues tab of your GitHub repository, when you need them.


## 📋 Roadmap

- [x] Finish documentation
- [x] Improve frame identifier without hurting performance
- [ ] Develop state-debugger plugin
- [x] Add redux plugin
- [x] Async support ⚡
- [ ] Additional hooks
    - [ ] use_ref 
- [ ] Test and adapt to PyPy, Jython, IronPython
- [ ] Support for more hook backends
    - [ ] MongoDB
    - [ ] Postgres
    - [ ] MySQL
    - [ ] SQLite
    - [ ] File
- [ ] More tests

See the [open issues](https://github.com/amitassaraf/python-hooks/issues) for a full list of proposed features (and known issues).

## 🛡 License

[![License](https://img.shields.io/github/license/amitassaraf/python-hooks)](https://github.com/amitassaraf/python-hooks/blob/master/LICENSE)

This project is licensed under the terms of the `MIT` license. See [LICENSE](https://github.com/amitassaraf/python-hooks/blob/master/LICENSE) for more details.

## 📃 Citation

```bibtex
@misc{python-hooks,
  author = {Amit Assaraf},
  title = {A React inspired way to code in Python},
  year = {2023},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/amitassaraf/python-hooks}}
}
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/amitassaraf/python-hooks",
    "name": "python-hooks",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Amit Assaraf",
    "author_email": "amit.assaraf@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/fe/0d/aa3ab8a7c4924b0a09819ce7434d8859945df6149bce2d95ba212e15149b/python_hooks-0.2.1.tar.gz",
    "platform": null,
    "description": "# Python Hooks\n\n<div align=\"center\">\n\n[![Build status](https://github.com/amitassaraf/python-hooks/workflows/build/badge.svg?branch=master&event=push)](https://github.com/amitassaraf/python-hooks/actions?query=workflow%3Abuild)\n[![Python Version](https://img.shields.io/pypi/pyversions/python-hooks.svg)](https://pypi.org/project/python-hooks/)\n[![Dependencies Status](https://img.shields.io/badge/dependencies-up%20to%20date-brightgreen.svg)](https://github.com/amitassaraf/python-hooks/pulls?utf8=%E2%9C%93&q=is%3Apr%20author%3Aapp%2Fdependabot)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Security: bandit](https://img.shields.io/badge/security-bandit-green.svg)](https://github.com/PyCQA/bandit)\n[![Pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/amitassaraf/python-hooks/blob/master/.pre-commit-config.yaml)\n[![Semantic Versions](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--versions-e10079.svg)](https://github.com/amitassaraf/python-hooks/releases)\n[![License](https://img.shields.io/github/license/amitassaraf/python-hooks)](https://github.com/amitassaraf/python-hooks/blob/master/LICENSE)\n![Coverage Report](assets/images/coverage.svg)\n<a href=\"https://github.com/amitassaraf/python-hooks/graphs/contributors\">\n  <img alt=\"GitHub Contributors\" src=\"https://img.shields.io/github/contributors/amitassaraf/python-hooks\" />\n</a>\n<a href=\"https://github.com/amitassaraf/python-hooks/issues\">\n  <img alt=\"Issues\" src=\"https://img.shields.io/github/issues/amitassaraf/python-hooks?color=0088ff\" />\n</a>\n<a href=\"https://github.com/amitassaraf/python-hooks/pulls\">\n  <img alt=\"GitHub pull requests\" src=\"https://img.shields.io/github/issues-pr/amitassaraf/python-hooks?color=0088ff\" />\n</a>\n<img alt=\"Dev status\" src=\"https://img.shields.io/badge/project_is_in-beta-red\" />\n\n---\n\n\n### A React inspired way to code in Python.\n</div>\n\n<div align=\"center\">\n<img src=\"docs/images/simple_code_example.png\" alt=\"drawing\" width=\"500\"/>\n<br/>\n<br/>\n<a href=\"https://github.com/amitassaraf/python-hooks\">\n  <img alt=\"Made with love by Amit Assaraf\" src=\"https://img.shields.io/badge/made_with_\u2764\ufe0f_by-amitassaraf-red?color=ff1744\" />\n</a>\n<br/>\nIf you like this project, consider starring it on Github \u2b50\u2b50\u2b50\u2b50  \n</div>\n<br/>\n\n* \u26a1\ufe0f Written with performance in mind __(Not using inspect module)__\n* \ud83d\udc0d Support for familiar React like hooks such as `use_state`, `use_effect`, `use_reducer`, `use_context` and more.\n* \ud83d\udee0\ufe0f Built with plugins support and easy to extend.\n* \ud83e\udd1d Python 3.9+ compatibility\n* \ud83e\udeb6 Lightweight to remove the need for a lot of boilerplate code.\n* \ud83d\udce6 Support for different backend state-stores.\n* \ud83d\udd27 Support for hooks-state scoping.\n* \ud83c\udf0e Redis, Redux, and Zustand plugins out of the box. \n* \ud83d\udd0c Tested mainly on CPython.\n\n---\n\n## Inspiration\n\nI'll begin be prefacing that this project will not fit everyone's needs. It's a very opinionated project and it's not meant to be a replacement for any of the existing state management libraries.\nAdditionally, if you are trying to squeeze the most performance out of Python this is probably not the right tool for you _(Though you might also be using the wrong programming language)_.\n\nThe goal of the project is to provide a simple and familiar way to manage state in Python. It's inspired by the React hooks API and it's meant to be used in a similar way. It can be used to manage \nstate in a single function or in a large project. The state can be stored in memory, in a database or in a file. It's up to you to decide and the library is easily extendable to support any backend.\n\nOne of the inspirations for this project was seeing the way junior developers struggle with state management and program structure in Python. This library is intended to provide a sense of familiarity\nto developers coming from the JavaScript world and to provide a simple way to manage state in Python which will not require a lot of boilerplate code or hurt performance.\n\nIt is meant to help write better data-driven code and to help developers focus on the business logic of their code rather than on the plumbing.\n\n\n[**Discord**](https://discord.gg/mayParnv) | [**Docs**](https://amitassaraf.github.io/python-hooks/) \n\n<img src=\"https://img.shields.io/badge/\u26a0\ufe0f Not_recommended_for_production_use_just_yet-ff9966\" />\n\nNote: This project is still in beta and is not recommended for production use just yet. We are working on adding more tests and improving the documentation. If you are interested in contributing, please reach out to me on [Discord](https://discord.gg/mayParnv).\n\n---\n\n## Let's see one API example\n\nAs Python is commonly used to create APIs, I wanted to provide one real-world example of using hooks for state management in Flask. Note, that this is just one example and the library can be used in many other ways. See [examples](https://github.com/amitassaraf/python-hooks/tree/master/examples)\n for more examples.\n\n<img src=\"docs/images/flask_example.png\" alt=\"drawing\" width=\"500\"/>\n\n### Pretty neat, right?\n\n\n## \ud83d\ude80 Installation\n\n```bash\npip install python-hooks\n```\n\n## \ud83c\udfaf What's next\n\nWell, that's up to you \ud83d\udcaa\ud83c\udffb. We are looking for contributors to help us build this project and make it better. If you are interested in contributing, please reach out to me on [Discord](https://discord.gg/mayParnv) or open an issue. \nIn addition we are looking for plugin developers to help us build more plugins for different state stores.\n\n## \ud83d\udcc8 Releases\n\nYou can see the list of available releases on the [GitHub Releases](https://github.com/amitassaraf/python-hooks/releases) page.\n\nWe follow [Semantic Versions](https://semver.org/) specification.\n\nWe use [`Release Drafter`](https://github.com/marketplace/actions/release-drafter). As pull requests are merged, a draft release is kept up-to-date listing the changes, ready to publish when you\u2019re ready. With the categories option, you can categorize pull requests in release notes using labels.\n\n### List of labels and corresponding titles\n\n|               **Label**               |  **Title in Releases**  |\n| :-----------------------------------: | :---------------------: |\n|       `enhancement`, `feature`        |       \ud83d\ude80 Features       |\n| `bug`, `refactoring`, `bugfix`, `fix` | \ud83d\udd27 Fixes & Refactoring  |\n|       `build`, `ci`, `testing`        | \ud83d\udce6 Build System & CI/CD |\n|              `breaking`               |   \ud83d\udca5 Breaking Changes   |\n|            `documentation`            |    \ud83d\udcdd Documentation     |\n|            `dependencies`             | \u2b06\ufe0f Dependencies updates |\n\n\nGitHub creates the `bug`, `enhancement`, and `documentation` labels for you. Dependabot creates the `dependencies` label. Create the remaining labels on the Issues tab of your GitHub repository, when you need them.\n\n\n## \ud83d\udccb Roadmap\n\n- [x] Finish documentation\n- [x] Improve frame identifier without hurting performance\n- [ ] Develop state-debugger plugin\n- [x] Add redux plugin\n- [x] Async support \u26a1\n- [ ] Additional hooks\n    - [ ] use_ref \n- [ ] Test and adapt to PyPy, Jython, IronPython\n- [ ] Support for more hook backends\n    - [ ] MongoDB\n    - [ ] Postgres\n    - [ ] MySQL\n    - [ ] SQLite\n    - [ ] File\n- [ ] More tests\n\nSee the [open issues](https://github.com/amitassaraf/python-hooks/issues) for a full list of proposed features (and known issues).\n\n## \ud83d\udee1 License\n\n[![License](https://img.shields.io/github/license/amitassaraf/python-hooks)](https://github.com/amitassaraf/python-hooks/blob/master/LICENSE)\n\nThis project is licensed under the terms of the `MIT` license. See [LICENSE](https://github.com/amitassaraf/python-hooks/blob/master/LICENSE) for more details.\n\n## \ud83d\udcc3 Citation\n\n```bibtex\n@misc{python-hooks,\n  author = {Amit Assaraf},\n  title = {A React inspired way to code in Python},\n  year = {2023},\n  publisher = {GitHub},\n  journal = {GitHub repository},\n  howpublished = {\\url{https://github.com/amitassaraf/python-hooks}}\n}\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A React inspired way to code in Python",
    "version": "0.2.1",
    "project_urls": {
        "Homepage": "https://github.com/amitassaraf/python-hooks",
        "Repository": "https://github.com/amitassaraf/python-hooks"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6ff51f485c9a2a1331e026ad07f7d3928ffa5c1c8121663239395fa48dab3106",
                "md5": "69525c9c111f46c84dfeae02e7388117",
                "sha256": "359e2207ab3850d0bcbd6f0f131238e01aac2e2ce6d2f9b7bbc783f16917a1d0"
            },
            "downloads": -1,
            "filename": "python_hooks-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "69525c9c111f46c84dfeae02e7388117",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<4.0",
            "size": 20865,
            "upload_time": "2023-08-19T20:42:15",
            "upload_time_iso_8601": "2023-08-19T20:42:15.783110Z",
            "url": "https://files.pythonhosted.org/packages/6f/f5/1f485c9a2a1331e026ad07f7d3928ffa5c1c8121663239395fa48dab3106/python_hooks-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fe0daa3ab8a7c4924b0a09819ce7434d8859945df6149bce2d95ba212e15149b",
                "md5": "b6ab51140c0249afb803f23addaf054b",
                "sha256": "de16420134bc6b1a44598caf5e096a79dc40f59193fb527e7ede4772bcf78a7c"
            },
            "downloads": -1,
            "filename": "python_hooks-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "b6ab51140c0249afb803f23addaf054b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 18798,
            "upload_time": "2023-08-19T20:42:17",
            "upload_time_iso_8601": "2023-08-19T20:42:17.528371Z",
            "url": "https://files.pythonhosted.org/packages/fe/0d/aa3ab8a7c4924b0a09819ce7434d8859945df6149bce2d95ba212e15149b/python_hooks-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-19 20:42:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "amitassaraf",
    "github_project": "python-hooks",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "python-hooks"
}
        
Elapsed time: 0.14528s