Skip to main content

pyinc

CI PyPI version Python versions PyPI license Lint: Ruff

pyinc is a correctness-first incremental query engine for Python. Declare keyed inputs and pure queries, and it records the dependency graph while your code runs. On the next request it reuses unaffected work, recomputes affected queries, and backdates semantically equal results so downstream work stays valid.

It is pure Python, stdlib-only, and has zero runtime dependencies. Python 3.11–3.14 are tested on Linux, macOS, and Windows.

python -m pip install pyinc

Quick start

from pyinc import Database, Input, query

NAMES = Input[tuple[str, ...]]("example.names")


@query
def normalized_names(db: Database) -> tuple[str, ...]:
    return tuple(sorted({name.strip() for name in NAMES.read(db)}))


db = Database(mode="strict")
db.set(NAMES, (" Grace ", "Ada", "Ada"))
assert db.get(normalized_names) == ("Ada", "Grace")

db.set(NAMES, ("Grace", "Ada"))
assert db.get(normalized_names) == ("Ada", "Grace")
assert db.inspect(normalized_names).last_decision == "backdated"

The first request computes the result. The second input is different, so the query runs again, but its result is semantically equal. pyinc backdates that node instead of invalidating anything downstream.

For files, environment variables, and directories, use a Resource rather than reading ambient state directly inside a query. The getting-started guide walks through inputs, resources, modes, inspection, and a first declared-output action.

See it on a real workspace

Editing pytest under pyinc's watcher

pyinc-tools was pointed at a pinned checkout of pytest — nothing in it adapted for pyinc — and watched while single files were edited; the demo page has the clips.

Correctness contract

pyinc guarantees from-scratch consistency: incremental evaluation matches a fresh evaluation on the same declared inputs and resources. That guarantee holds only when all three conditions hold:

  1. Owned value boundaries. Query arguments, query results, and Input values are snapshot-safe or handled by a registered ValueAdapter.
  2. Tracked ambient reads. External state read by a query goes through a Resource; reads the guard cannot intercept are declared with db.report_untracked_read(reason).
  3. Deterministic queries. The same tracked dependencies produce a semantically equal result.

The kernel contract defines the exact value rules, intercepted operations, execution modes, durable checkpoint trust boundary, and documented limitations.

Packages

One distribution ships three top-level typed packages; the stable integration surface is a subpackage of pyinc:

Package Purpose Start here
pyinc Stable query kernel, resources, snapshots, artifact stores, and declared-output actions. Kernel contract
pyinc.integrations Stable, frozen analysis results and high-level entrypoints for Python source, configuration, dependencies, symbols, and notebooks. Integration contract
pyinc_tools pyinc-tools analyze, a polling watcher, WorkspaceSession, and a stdio LSP server built on the integration API. Tooling guide
pyinc_codegen JSON Schema to typed Python generation through the public query and action APIs. Codegen guide

Queries remain pure. Filesystem writes belong to the separate @action layer, which reconciles a complete desired output set with atomic file replacement, tamper repair, orphan cleanup, and dry-run planning. See the action contract.

Documentation

Development

git clone https://github.com/Brumbelow/pyinc.git
cd pyinc
python3 -m venv .venv
. .venv/bin/activate
python3 -m pip install -e '.[dev]'
python3 scripts/check_docs.py
pytest -q
python3 -m mypy src tests bench scripts
python3 -m ruff check src tests bench scripts

Run python -m pyinc_tools --help for the installed command-line tools. The module form and the pyinc-tools console script are equivalent.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyinc-3.1.0.tar.gz (2.4 MB view details)

Uploaded Source

Built Distribution

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

pyinc-3.1.0-py3-none-any.whl (283.4 kB view details)

Uploaded Python 3

File details

Details for the file pyinc-3.1.0.tar.gz.

File metadata

  • Download URL: pyinc-3.1.0.tar.gz
  • Upload date:
  • Size: 2.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pyinc-3.1.0.tar.gz
Algorithm Hash digest
SHA256 125b7ebff97abf020cb19654720c6b1585c2b740b0aef0ca9dbce727d55cbd90
MD5 ec93f770d3eedf079b611ad43e0ffff4
BLAKE2b-256 bf366566c08a5d08b05d352e26157fff3c87eb80e89f0997015c82eb549c0045

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyinc-3.1.0.tar.gz:

Publisher: release.yml on Brumbelow/pyinc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyinc-3.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyinc-3.1.0-py3-none-any.whl
  • Upload date:
  • Size: 283.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pyinc-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a9a92bcddee05b2b56630a37727fffe30b4182a3440c49e722841b141c0e022c
MD5 f19e6f8c4021774bb47748fb67b866fe
BLAKE2b-256 7f1a4bf055537b979ae67230b63597e7d959adc0f9e3b6beca6101a435e19e23

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyinc-3.1.0-py3-none-any.whl:

Publisher: release.yml on Brumbelow/pyinc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

3.1.0 This release

2 files

3.0.0

2 files

2.6.0

2 files

2.5.0

2 files

2.1.0

2 files

2.0.1

2 files

2.0.0

2 files

1.2.1

2 files

1.2.0

2 files

1.1.1

2 files

1.1.0

2 files

1.0.1

2 files

1.0.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page