Skip to main content

FUNctional types for Python. (Backport to 0.2.1)

Project description

fntypes

Functional typing in Python!

See examples

See documentation

fntypes is based on the belief that raising exceptions should be avoided. Therefore, it offers a set of functional types needed to write better code. This type strategy grants your project with higher control over type system - improves control flow

Contributions are welcome

@unwrapping
def send_funds(
    sender_id: int, 
    receiver_id: int, 
    amount: decimal.Decimal,
) -> Result[TransactionID, str]:
    sender = get_user(sender_id).expect("Sender is undefined")
    receiver = get_user(receiver_id).expect("Receiver is undefined")
    if sender.get_balance().unwrap() < amount:
        return Error("Sender has not enough funds to complete transaction")
    
    return Ok(
        create_transaction(sender, receiver, amount)
        .unwrap()
        .transaction_id
    )

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

funtypes-0.2.1.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

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

funtypes-0.2.1-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file funtypes-0.2.1.tar.gz.

File metadata

  • Download URL: funtypes-0.2.1.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.3 Windows/11

File hashes

Hashes for funtypes-0.2.1.tar.gz
Algorithm Hash digest
SHA256 f1b35a355c52193c4dfd6a06b39cbbb07125be3d5331ebc0aac9c3d2b3e5c193
MD5 78a0d1862c345bd364f3a207459039f7
BLAKE2b-256 a259dc2bcf2bdacbd45b964bc8f588c87c8684f7d1828251eaaa46248b78bbc1

See more details on using hashes here.

File details

Details for the file funtypes-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: funtypes-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.3 Windows/11

File hashes

Hashes for funtypes-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 878129ec67117cad9719579897bd4cd7c35a332972bc226c860f7fc39336a658
MD5 b2c370802cb179df2a4bd22e9f377f64
BLAKE2b-256 10d42c623f3aa7336f7347d07c92a419eb9450fd517c9b20e7624637e5f7dc3b

See more details on using hashes here.

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