Skip to main content

whiff

Python bindings for whiff. Point it at a file or at bytes and it returns one whiff/1 report: format, hashes, security and rights signals, content, and format-specific metadata.

Identification and extraction run in the Rust crate (1.1.0, the common feature set). Python extractors and analyzers can add fields afterwards. They do not run inside native extraction, and they do not run for embedded children.

import whiff

report = whiff.extract("invoice.pdf")
report["identification"]["format"]  # "pdf"

report = whiff.extract(data, name="invoice.pdf", hashes=["sha256"])
view = whiff.llm("contract.pdf", tokens=800)

Empty optional fields are omitted. The vendored schema is whiff.schema().

Install

Import the package as whiff. The PyPI project whiff already belongs to an unrelated library, so this distribution is named whiff-python. A GitHub release tagged with the version in pyproject.toml (an optional v prefix is fine) publishes the wheels. From a checkout, with Rust 1.89 or later:

maturin develop

That builds the common formats. A source build of every collection is:

maturin develop --features full

geo, science, data, cad, forensics, and games are the individual cargo features. Wheels are built with common only.

Extract

extract accepts a path, bytes, or a binary file object. A file object is read up to max_read_bytes and then treated as bytes. name (or filename, not both) drives extension detection for in-memory input.

Corrupt or partial files still return a report. Problems inside the file are listed in diagnostics. The call raises WhiffError when the path cannot be inspected or an option is invalid:

try:
    report = whiff.extract(path)
except whiff.NotFoundError:
    ...
except whiff.AccessError:
    ...
except whiff.InvalidOptionError as err:
    print(err.message)

NotFoundError is also a FileNotFoundError. AccessError is also a PermissionError. IO messages include the full path.

llm returns upstream Report::llm_view. Python plugins do not run for it.

results = whiff.extract_many(
    paths,
    max_concurrency=4,
    timeout=300_000,
    profile="minimal",
    hashes="none",
)

Results keep input order. With on_error="collect" (the default) each item is (path, report) or (path, error). With on_error="halt" the first error is raised and err.details["partial"] holds the pairs completed before it. timeout is per path, in milliseconds. A timeout does not stop native work that has already started.

An Engine holds native options and is safe to share across threads:

engine = whiff.Engine(profile="minimal", hashes="none")
engine.extract(path)

Native calls take a process-wide slot (default 8). A caller that waits longer than native_wait_ms (default 60000) raises OverloadedError. Change the limits with whiff.configure(native_max_concurrency=4, native_wait_ms=10_000).

stage="local" copies a regular file into a private scratch directory before taking a slot, for slow or network filesystems. The copy is removed afterwards. The report still describes the original path. Times are second precision, and fields Python does not read (birth time, allocated size, owner names, ACLs, extended attributes) are omitted, with a diagnostics.warnings entry. Files larger than scratch_max_bytes (default 1 GiB) are rejected.

Options

An option a function does not use is rejected.

Option Values Default
profile minimal, standard, full, llm standard
hashes all, none, or a list of sha256 / blake3 all
privacy strict, off strict
redaction on, off on
investigate True, False, or ["prompt_injection"] off
only / skip extractor ids or groups none
format format id to force detect
provenance record which extractor set each field False
limits dict of native limits; see below profile limits
stage never, local never
name / filename / mime strings (bytes and file objects) none
tokens 1..100000 800 (llm only)
mode fallback, augment, override fallback
extractors / analyzers plugin classes or instances none
strict plugin failure raises False
plugin_timeout_ms 1..600000 5000
override_fields dotted paths, for example ["content.title"] []
max_concurrency / on_error / timeout extract_many 4 / collect / 300000

limits keys: max_read_bytes and max_decompressed_bytes (1..4 GiB), hash_max_bytes (0..4 GiB), max_parse_bytes (0..256 MiB), max_text_bytes (0..64 MiB), max_depth (0..8), max_children (0..500), file_timeout_ms and extractor_timeout_ms (1..600000).

privacy="strict" reduces personal data in native structured fields to counts and scrubs personal data in plugin patches. redaction="on" replaces secrets with [redacted:<kind>] in the report and in plugin patches. privacy="off" keeps personal data. redaction="off" leaves secrets as found; they are still counted and still raise embedded_secret.

investigate=["prompt_injection"], or investigate=True, adds an investigation section to extract reports. The default runs no check, and the section is absent. llm() does not include it. Read status together with coverage: no_findings on a partial scan is not a clean file.

Plugins

class Trade(whiff.Extractor):
    id = "myapp.trade"
    version = 1

    def supports(self, source, report) -> bool:
        return source.extension == ".trade"

    def extract(self, source, report) -> dict:
        return {"format": {"myapp.trade": {"trade_id": "T-1001"}}}


report = whiff.extract("positions/2026-10-28.trade", extractors=[Trade])

An analyzer subclasses whiff.Analyzer and implements analyze(report, source). Analyzers run after extractors. Their patches always merge in augment mode.

Mode When an extractor runs Existing native values
fallback native extraction did not cover a readable file kept, except content.*
augment supports returns true kept
override supports returns true replaced for paths in override_fields

whiff, integrity, and embedded cannot be patched. diagnostics accepts only extra warnings. security.risks are appended with source set to python:<id>. metadata and format keys are namespaces. One plugin cannot replace a value another plugin wrote unless that path is declared.

A failed plugin is recorded in diagnostics.extractors with status error, and the call still returns the report. With strict=True the call raises. Plugins run on a worker thread. They are not a security boundary.

whiff.merge applies the same rules to a patch dict.

Development

cargo test
cargo clippy --all-targets -- -D warnings
maturin develop
ruff check src tests
pytest

Golden reports are compared with probes/rust_extract, which links the same whiff 1.1.0 crate. Design notes: docs/adr/0001-baseline.md.

Limitations

  • extract of bytes copies the buffer once into native memory.
  • There is no streaming reader. A file object is read up to the read cap.
  • Python callbacks do not run for embedded children, and llm does not run them.
  • stage="local" copies the whole file first.
  • A native file_timeout can leave a Rust worker running after the call returns.
  • IO error messages include the full path.

License

MIT. Upstream whiff is also MIT.

Metadata

Release files for whiff-python 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 whiff-python 0.2.0
File Size Uploaded Provenance Actions
whiff_python-0.2.0.tar.gz 54.9 kB With provenance Details for whiff_python-0.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for whiff-python 0.2.0
File Actions
whiff_python-0.2.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for whiff_python-0.2.0-cp311-abi3-win_amd64.whl
whiff_python-0.2.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.11 abi3 Linux glibc 2.17+ x86-64 Details for whiff_python-0.2.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
whiff_python-0.2.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details for whiff_python-0.2.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
whiff_python-0.2.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for whiff_python-0.2.0-cp311-abi3-macosx_11_0_arm64.whl
whiff_python-0.2.0-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details for whiff_python-0.2.0-cp311-abi3-macosx_10_12_x86_64.whl

Total release size: 53.6 MB

Release files / whiff_python-0.2.0.tar.gz

Download URL whiff_python-0.2.0.tar.gz
Size 54.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7bdaf4c04e8cc3af4fe92c561a9ec2d93446d77d9586174bc0c708cde8030b19
BLAKE2b-256 checksum
How to use checksums
45fdfae608b2b4f134616859dd2d38cbf837481b8cc9d4e91f9f2675eaaefb79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 4, 2026.

Transparency log

Release files / whiff_python-0.2.0-cp311-abi3-win_amd64.whl

Download URL whiff_python-0.2.0-cp311-abi3-win_amd64.whl
Size 10.4 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
027b94199cf0a5195834bf9e7e005e6c2b068352953a0a5d838d9703b92571d5
BLAKE2b-256 checksum
How to use checksums
8dc39b9eea02b3c58335e655ae3f40aecda72c2b982f8211d620bf30716b0873
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 4, 2026.

Transparency log

Release files / whiff_python-0.2.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL whiff_python-0.2.0-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 11.3 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
af8be2df1d2cadece623e2455e2e281c24b2af2ccdbf7a5522f2835631ab094e
BLAKE2b-256 checksum
How to use checksums
0223a06d21462a0dda09345a487e7fad1dbace782bcc91a21997f2c245561ed8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 4, 2026.

Transparency log

Release files / whiff_python-0.2.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL whiff_python-0.2.0-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 11.2 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
e63fae512fa3592317b3d46b534d41f74b0cd6d2f4f898f97ae7127e60f3f24b
BLAKE2b-256 checksum
How to use checksums
191d4b78ee74364cb36f35851666f2118d7a1857e45e1fa17e08857fda73ab0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 4, 2026.

Transparency log

Release files / whiff_python-0.2.0-cp311-abi3-macosx_11_0_arm64.whl

Download URL whiff_python-0.2.0-cp311-abi3-macosx_11_0_arm64.whl
Size 10.1 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4a11da2b7bc66933b1c15b6387a30a4e6ef8b09f0dfc36b8a357a5c99a35f2ee
BLAKE2b-256 checksum
How to use checksums
9271eda99b62003010a9c635c728bcbf4ab45aabc86dc4f2ed0248c1f47a1c2c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 4, 2026.

Transparency log

Release files / whiff_python-0.2.0-cp311-abi3-macosx_10_12_x86_64.whl

Download URL whiff_python-0.2.0-cp311-abi3-macosx_10_12_x86_64.whl
Size 10.6 MB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
458bb3f012cac939b44232668bdeaa1b882f20aa3b531b18fa5b837f3e02962d
BLAKE2b-256 checksum
How to use checksums
162a6bbe23789027b56e4c2bee8c36c3aeb09827110db20d24c6eca30b4fa79f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 4, 2026.

Transparency log

Security for whiff-python 0.2.0

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.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for whiff_python-0.2.0.tar.gz

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 Dec 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

6 release files Full provenance

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