Skip to main content

graftpy

CI PyPI Python License: MIT

Graftable Python — functions you can pip install or lift into any project.

Your code has two readers now: the humans on your team and the AI writing alongside them. graftpy is built to be legible — and liftable — by both. (read the manifesto)

pip install graftpy                          # use it as a dependency...
python -m graftpy show retry_with_backoff    # ...or graft one self-contained file

Most "utility" libraries make you choose: install the whole package and accept its web of internal imports, or copy a snippet off Stack Overflow with no types, no tests, and no idea if it's right. graftpy refuses the trade-off.

Every function here lives in its own file, depends only on the standard library (plus, at most, one clearly-declared third-party package), and never imports a sibling. So you can use it however you — or your AI coding agent — like:

# 1) install it
pip install graftpy
from graftpy.decorators import retry_with_backoff
# 2) ...or graft a single, self-contained file straight into your project
python -m graftpy show retry_with_backoff > myproject/retry.py

Both give you the exact same code: fully typed, documented, and covered by a runnable example.

Why "graftable"? The one principle

We optimize for lift, not DRY.

If two functions need the same little helper, each carries its own copy. We trade a bit of duplication for a hard guarantee: any function is one Ctrl-C away from living in your codebase, with nothing to untangle. That guarantee isn't a promise — it's enforced in CI (tools/check_liftability.py), so it can't silently rot.

Built for humans and AI, on purpose

Coding is increasingly a conversation with an AI. A library that agents can read, find, and reuse reliably is worth ten that they can't. So graftpy is designed to be legible to both:

  • One job per file, descriptive names → grep-able and embedding-searchable.
  • Full type hints + Google-style docstrings + a runnable example → an agent can understand and call any function correctly from its signature alone.
  • A machine-readable catalog (catalog.json) and an agent guide (AGENTS.md / llms.txt) → an agent can discover the right function without reading the whole repo.
  • python -m graftpy show <name> → an agent (or you) can fetch one function's verbatim source with zero install.

Quickstart

from graftpy.iterables import chunked
for batch in chunked(range(7), 3):
    print(batch)          # [0, 1, 2] / [3, 4, 5] / [6]

from graftpy.decorators import retry_with_backoff

@retry_with_backoff(retries=5, base_delay=0.2)
def fetch(url): ...

The CLI

python -m graftpy list                    # every graftable function + one-liner
python -m graftpy search retry            # find by name / summary / tag
python -m graftpy show chunked            # print the standalone source to lift

How it's organized

src/graftpy/<category>/<function>.py   # one public function per file

Browse the full, auto-generated list in INDEX.md. Categories (e.g. iterables, decorators) are shallow on purpose — deep nesting hurts both humans and retrieval.

Contributing

New functions are welcome — but they have to clear the bar that makes graftpy what it is. See CONTRIBUTING.md: self-contained, fully typed, docstring with a runnable example, one function per file. CI checks all of it.

License

MIT — lift freely.

Metadata

Release files for graftpy 0.1.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 graftpy 0.1.1
File Size Uploaded
graftpy-0.1.1.tar.gz 26.9 kB Details

Built distribution (wheel)

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

Total release size: 53.0 kB

Release files / graftpy-0.1.1.tar.gz

Download URL graftpy-0.1.1.tar.gz
Size 26.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6175b7553ad2f259c5ead92d33abb91a87bd7b6d26ac64bc036b698fcb03a310
BLAKE2b-256 checksum
How to use checksums
e9300e3d3ebb9b8477842dac9f186ff385217611a78638dd893da64940acfec8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.

Transparency log

Release files / graftpy-0.1.1-py3-none-any.whl

Download URL graftpy-0.1.1-py3-none-any.whl
Size 26.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
92107b226a7ca200460bdbb5b34ea5b0e9c58ccb937448d5e91ba61304a671f1
BLAKE2b-256 checksum
How to use checksums
ee41e37e314782a4752af9ea877910e167d258a9a413f142651286984e5aa9a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.0

2 release files

This release

0.1.1 This release

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