Skip to main content

reacttrs

Reactive attributes, initially extracted out from Textual, now a fork of Declare.

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

Release files for reacttrs 0.2.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 reacttrs 0.2.1
File Size Uploaded
reacttrs-0.2.1.tar.gz 3.5 kB Details

Built distribution (wheel)

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

Total release size:7.9 kB

Release files / reacttrs-0.2.1.tar.gz

Download URL reacttrs-0.2.1.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6a2cbf7a209deb0be056cc30e7c7c5f1ff5a744cba18c427d5418cc32bb1e53c
BLAKE2b-256 checksum
How to use checksums
909033daccaa6587d18e60ccc48a70d3c36e9e2b48db2606f7829b6c687b31fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / reacttrs-0.2.1-py3-none-any.whl

Download URL reacttrs-0.2.1-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1425357d8d7b0d8bc89fc1dce2544410296b605429571e11b682492a3060caed
BLAKE2b-256 checksum
How to use checksums
450b888bee634da04d8fd8a7d177d48bca3888388145b8445810550e77de8b34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.4

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

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