Skip to main content

NoFuture: explicit Maybe and Result types. No futures. No exceptions.

Project description

NoFuture

NoFuture

pipeline status

No futures. No exceptions. Just explicit values.

MayBe et Result pour Python, built en Rust (PyO3 + maturin).

from nofut import MayBe, Result

Installation

pip install nofuture

Dev mode: maturin develop

MayBe

Valeur optionnelle: Just(value) ou Nothing.

MayBe.just(42)      # Just(42)
MayBe.nothing()     # Nothing

# API
.is_just() / .is_nothing()
.unwrap()           # raise si Nothing
.or_else(default)   # valeur ou default
.map(fn)            # Just(fn(x)) ou Nothing
.flat_map(fn)       # fn doit retourner MayBe
>> fn               # flat_map
| default           # or_else

Result

Succès ou erreur: Ok(value) ou Err(message, code?, details?). La vie en binaire, avec du contexte.

Result.ok(42)
Result.err("not found", code="NOT_FOUND")
Result.err("validation", code="INVALID", details={"field": "name"})

# API
.is_ok() / .is_err()
.unwrap()           # raise si Err
.unwrap_or(default) # valeur ou default
.unwrap_err()       # (msg, code, details) ou raise
.map(fn)            # Ok(fn(x)) ou Err passthrough
.map_err(fn)        # fn(msg, code, details) -> (msg, code, details)
.flat_map(fn)       # fn doit retourner Result
.and_then(fn)       # alias flat_map
.to_dict()          # {"ok": True, "value": ...} ou {"ok": False, "error": ...}
>> fn               # flat_map
| default           # unwrap_or

Exemples

Exemples progressifs (basics -> objets -> pipeline Result).

python3 examples/base.py
python3 examples/abc.py
python3 examples/result.py

Tests

python3 -m unittest discover -s tests -p 'test_*.py'

Licence

GPLv3 - voir LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nofuture-1.0.1.tar.gz (30.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

nofuture-1.0.1-cp312-cp312-win_amd64.whl (149.6 kB view details)

Uploaded CPython 3.12Windows x86-64

nofuture-1.0.1-cp312-cp312-macosx_11_0_arm64.whl (259.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

nofuture-1.0.1-cp312-cp312-macosx_10_12_x86_64.whl (264.0 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

nofuture-1.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (297.2 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

Details for the file nofuture-1.0.1.tar.gz.

File metadata

  • Download URL: nofuture-1.0.1.tar.gz
  • Upload date:
  • Size: 30.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nofuture-1.0.1.tar.gz
Algorithm Hash digest
SHA256 70213607ea9405a6c0ea7e5adcb55f944ce3a1d9d4b329d5adc7c9c2d34f944a
MD5 9fcb9583ad72bf84af4b840b34e8ea84
BLAKE2b-256 79b412630bb71c6bd759b08f58f21447135985fa24a823aa75ea570512d6bdd9

See more details on using hashes here.

Provenance

The following attestation bundles were made for nofuture-1.0.1.tar.gz:

Publisher: publish.yml on aristofor/nofuture

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nofuture-1.0.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: nofuture-1.0.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 149.6 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nofuture-1.0.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 507a9d3368c583abb71c3a2d053ae43d83846005d74213423432e015d3bcf53a
MD5 8a6aacf635d0e8eb9994fffc6c10436f
BLAKE2b-256 7626ad70997593c02aeb8e4ae39bf774ae4b2f166adb131b143a42d8818e902c

See more details on using hashes here.

Provenance

The following attestation bundles were made for nofuture-1.0.1-cp312-cp312-win_amd64.whl:

Publisher: publish.yml on aristofor/nofuture

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nofuture-1.0.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nofuture-1.0.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5d9fd4fc20c1358e8679aacd388d5eaf153e0887908bc884a753b20ed073a0cd
MD5 2d461a0593c367350356015301098e9a
BLAKE2b-256 29d9fae244958cc1986aa8e49e1303c4a73911e0456e49c24f295d88d97f25fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for nofuture-1.0.1-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: publish.yml on aristofor/nofuture

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nofuture-1.0.1-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for nofuture-1.0.1-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9ae0cf62f015c70cf4207ff3dadcd09dc2219ee8ff90284d6d75d4dae3d6ed73
MD5 1b367a91b18f12a38e660cde6ed40d88
BLAKE2b-256 c2da4769060f4b2a588663dd8395b3ddc80d6adc3558745da3a8217661ada1a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for nofuture-1.0.1-cp312-cp312-macosx_10_12_x86_64.whl:

Publisher: publish.yml on aristofor/nofuture

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nofuture-1.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for nofuture-1.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7c18afb6168a017b1e8d2055276bde1b99f016c7315548b08d67bc27418234b2
MD5 7a061ff29ea7b4055ee343f72c3ebd05
BLAKE2b-256 2029bf9cddab19fce178c54a939e71e99a764f8a08227a4083c74b6b97f6b7da

See more details on using hashes here.

Provenance

The following attestation bundles were made for nofuture-1.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on aristofor/nofuture

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page