Name | reacttrs JSON |
Version |
0.2.1
JSON |
| download |
home_page | None |
Summary | Attributes with superpowers |
upload_time | 2024-07-20 07:36:03 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | None |
keywords |
|
VCS |
![](/static/img/github-24-000000.png) |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# reacttrs
Reactive attributes, initially extracted out from [Textual](https://textual.textualize.io/guide/reactivity), now a fork of [Declare](https://github.com/willmcgugan/declare).
```py
from reacttrs import Int, Str
class Foo:
name = Str("Paul")
age = Int(34)
birth = Int(1990)
@name.watch
def _watch_name(self, old: str, new: str):
print(f"{old=}, {new=}")
@age.validate
def _validate_age(self, value: int) -> int:
return 2024 - self.birth
foo = Foo()
foo.name = "John" # old='Paul', new='John'
foo.name = "Steve" # old='John', new='Steve'
print(foo.age) # 34
foo.birth = 1991
foo.age = 34
print(foo.age) # 33
```
Raw data
{
"_id": null,
"home_page": null,
"name": "reacttrs",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "David Brochart <david.brochart@gmail.com>, Will McGugan <willmcgugan@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/90/90/33daccaa6587d18e60ccc48a70d3c36e9e2b48db2606f7829b6c687b31fa/reacttrs-0.2.1.tar.gz",
"platform": null,
"description": "# reacttrs\n\nReactive attributes, initially extracted out from [Textual](https://textual.textualize.io/guide/reactivity), now a fork of [Declare](https://github.com/willmcgugan/declare).\n\n```py\nfrom reacttrs import Int, Str\n\n\nclass Foo:\n\n name = Str(\"Paul\")\n age = Int(34)\n birth = Int(1990)\n\n @name.watch\n def _watch_name(self, old: str, new: str):\n print(f\"{old=}, {new=}\")\n\n @age.validate\n def _validate_age(self, value: int) -> int:\n return 2024 - self.birth\n\nfoo = Foo()\nfoo.name = \"John\" # old='Paul', new='John'\nfoo.name = \"Steve\" # old='John', new='Steve'\n\nprint(foo.age) # 34\nfoo.birth = 1991\nfoo.age = 34\nprint(foo.age) # 33\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Attributes with superpowers",
"version": "0.2.1",
"project_urls": {
"Homepage": "https://github.com/davidbrochart/reacttrs"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "450b888bee634da04d8fd8a7d177d48bca3888388145b8445810550e77de8b34",
"md5": "ab33dc22d89e5e693993fb2e832b28c6",
"sha256": "1425357d8d7b0d8bc89fc1dce2544410296b605429571e11b682492a3060caed"
},
"downloads": -1,
"filename": "reacttrs-0.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ab33dc22d89e5e693993fb2e832b28c6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 4398,
"upload_time": "2024-07-20T07:36:02",
"upload_time_iso_8601": "2024-07-20T07:36:02.557240Z",
"url": "https://files.pythonhosted.org/packages/45/0b/888bee634da04d8fd8a7d177d48bca3888388145b8445810550e77de8b34/reacttrs-0.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "909033daccaa6587d18e60ccc48a70d3c36e9e2b48db2606f7829b6c687b31fa",
"md5": "526c6cf1762a19308b6f11157d628c0f",
"sha256": "6a2cbf7a209deb0be056cc30e7c7c5f1ff5a744cba18c427d5418cc32bb1e53c"
},
"downloads": -1,
"filename": "reacttrs-0.2.1.tar.gz",
"has_sig": false,
"md5_digest": "526c6cf1762a19308b6f11157d628c0f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 3472,
"upload_time": "2024-07-20T07:36:03",
"upload_time_iso_8601": "2024-07-20T07:36:03.898727Z",
"url": "https://files.pythonhosted.org/packages/90/90/33daccaa6587d18e60ccc48a70d3c36e9e2b48db2606f7829b6c687b31fa/reacttrs-0.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-20 07:36:03",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "davidbrochart",
"github_project": "reacttrs",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "reacttrs"
}