Skip to main content

A collection of tiny, reusable Python utilities.

Project description

tuttifrutti

preview

A collection of tiny, lightweight, and highly optimized Python utilities to make your everyday coding sweet and crisp. Fully typed, zero external dependencies, and built with lazy-loading for maximum performance.


Utilities

1. OptionalChain

Tired of guarding deeply nested dictionaries or object lookups with defensive if configurations? OptionalChain brings clean, safe JavaScript-style optional chaining (?.) directly to Python.

from dataclasses import dataclass
from datetime import date
from typing import Any, Literal

from tuttifrutti import OptionalChain


@dataclass
class Course:
    name: str
    level: Literal["Basic", "Intermediate", "Advance"]
    price: int | None


@dataclass
class AppUser:
    name: str | None
    username: str | None
    age: int | None
    courses: list[Course] | None
    meta: dict[str, Any]


@dataclass
class AppResponse:
    data: OptionalChain[AppUser]
    status: int


course1 = Course(name="Python", level="Basic", price=2000)
course2 = Course(name="JS/TS", level="Intermediate", price=3400)
course3 = Course(name="Go", level="Advance", price=None)

app_user = AppUser(
    name="Kunal",
    username=None,
    age=10,
    courses=[course1, course2, course3],
    meta={
        "purchase_day": str(date.today()),
        "coupon": True,
    },
)
app_response = AppResponse(
    data=OptionalChain(app_user),
    status=200,
)

ans: int | None = app_response.data.courses[0].price.map(lambda x: x // 12).get()
print(ans)  # Output: 166


def append_at_sign(username: str) -> str:
    return f"{'@'}{username}"


result = app_response.data.username.map(append_at_sign).get()
print(result)  # Output: None

More tiny utilities are actively cooking and coming soon!

📦 Features

  • ⚡ Ultra Lightweight & Lazy-Loaded: Submodules are only loaded into memory when explicitly called—keeping your application startup lightning fast.
  • 🛡️ Fully Type-Safe: Ships with explicit PEP 561 typing configurations (py.typed) to ensure strict compatibility with tools like mypy and modern IDE autocomplete structures.
  • 🪶 Zero Dependencies: Pure, clean standard-library enhancements.

🚀 Installation

Install tuttifrutti using your favorite Python package manager:

# Using pip
pip install tuttifrutti

# Using uv
uv add tuttifrutti

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

tuttifrutti-0.1.3.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

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

tuttifrutti-0.1.3-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file tuttifrutti-0.1.3.tar.gz.

File metadata

  • Download URL: tuttifrutti-0.1.3.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tuttifrutti-0.1.3.tar.gz
Algorithm Hash digest
SHA256 a54fd652ab032c963a2a081e1bf2dd01f2a1a1494cfb879ca78119d580e16ea2
MD5 ac3359b6b1a80b80c128064afcd8a010
BLAKE2b-256 9eaa43a64976c990bfaadab8eba21ae940f1ec8dac6bd326a3c28e128acf23e1

See more details on using hashes here.

File details

Details for the file tuttifrutti-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: tuttifrutti-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tuttifrutti-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 25d0f252483c39f7d6f91e8ed176477c94f9d3216651ef090fea852dd22397df
MD5 807d0afcd2d199c45de65a4d70198ff7
BLAKE2b-256 06b2a4d057e25dfa7ae37014bce59db989391bdb0549568de674438843a5122d

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