Skip to main content

Uma biblioteca inspirada em Rust e Kotlin para lidar com Option, println colorido e utilitários.

Project description

🇺🇸 English version: README_EN.md

🦀 Koruspy

Koruspy é uma biblioteca ultra-leve que traz a segurança do Rust e a elegância do Kotlin para o ecossistema Python.

Desenvolvida inteiramente via Termux, esta biblioteca elimina a necessidade de verificações manuais de None e blocos try/except repetitivos, utilizando o poder do Pattern Matching (Python 3.10+) e programação funcional.


🚀 Diferenciais

Zero NoneErrors: Use Option (Some ou nothing) para lidar com valores ausentes.

Result Pattern: Trate sucessos e falhas como dados, não como exceções que quebram o código.

Estilo Kotlin: Métodos encadeáveis como .map(), .Filter(), .and_then() e o operador de navegação segura .getattr().

Pipeline seguro: option_of agora trata corretamente None e nothing, preservando valores falsy como 0 e False.

Finalização clara: .finalize() encerra pipelines que já têm valor garantido.

Fallback elegante: .unwrap_or(default) e .unwrap_or_else(func) fornecem valores quando necessário.

Terminal Colorido: Substitua o print padrão pelo println com suporte a tipos e cores ANSI.


📦 Instalação

Como você está desenvolvendo no Termux ou em ambiente mobile, instale via modo editável:

pip install -e .


📝 Exemplos 2.3

from koruspy import Some, nothing, option_of, println

# option_of trata None e nothing, preservando falsy

idade = option_of(0, 18)
println(idade)  # Some(0)

idade2 = option_of(None, 18)
println(idade2)  # Some(18)

Pipeline com Filter e finalize

idade_valida = (
    option_of(idade2.get_value(), 0)
    .Filter(lambda x: x >= 18)
    .on_nothing(lambda: println("valor inválido"))
    .finalize()
)
println(idade_valida)

Fallbacks

val = option_of(None).unwrap_or(42)
println(val)  # 42

val2 = option_of(None).unwrap_or_else(lambda: 99)
println(val2)  # 99

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

koruspy-0.2.5.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

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

koruspy-0.2.5-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file koruspy-0.2.5.tar.gz.

File metadata

  • Download URL: koruspy-0.2.5.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.5

File hashes

Hashes for koruspy-0.2.5.tar.gz
Algorithm Hash digest
SHA256 21c7b7f6c7fd57eb1e244b9cb60ce6bb3ba0ec985d49ef931b9b479558dd2c49
MD5 8cb6f0b3b957b89e1ded2960806575c2
BLAKE2b-256 2f42db873751e04374e4c6456f5866e4c6c74edad43abf0de921878987c2db92

See more details on using hashes here.

File details

Details for the file koruspy-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: koruspy-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.5

File hashes

Hashes for koruspy-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 2b85493b6f588bb43e8d1e40e98b018801bf775f8d1cc81f93f806d3d76116ae
MD5 bff5de2631e3d18dcbfd9d74e2b54799
BLAKE2b-256 97a7d4b9fcf15c426e4638df43a8c2b3ab1d04bfb90fef0534362986948b9db5

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