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.2.0

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.2.0
File Size Uploaded
graftpy-0.2.0.tar.gz 42.2 kB Details

Built distribution (wheel)

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

Total release size: 91.1 kB

Release files / graftpy-0.2.0.tar.gz

Download URL graftpy-0.2.0.tar.gz
Size 42.2 kB
Tags Source
SHA-256 checksum
How to use checksums
eb55953873e536f21e97278c0aad2007b1a2164089a557d91c15c0faa28836f4
BLAKE2b-256 checksum
How to use checksums
2c01d0c7786d55ba5d2cce5b6c1b36c18b8fd5bc36f3182cd97cb31061c9acd7
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.2.0-py3-none-any.whl

Download URL graftpy-0.2.0-py3-none-any.whl
Size 48.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f8275f3d2926abfe3aa1a3a07245d29732ce2b8ea3cb3fb8d9c6bf49e20c1cb5
BLAKE2b-256 checksum
How to use checksums
c75d4d3808a7edc9fda4bc6dee76db0672fc9235f4f01b8a3a36d652482d109d
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

This release

0.2.0 This release

2 release files

0.1.1

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