depyler-knowledge 4.1.1

Sovereign Type Database for Python library type extraction
Documentation

Sovereign Type Database for Python Library Type Extraction

This crate provides a "Type Truth Database" for Python libraries, enabling the Depyler transpiler to know types instead of guessing them.

Architecture (The Sovereign Stack)

  1. Harvester: Uses uv pip install --target for deterministic package fetching
  2. Extractor: Uses rustpython_parser for .pyi stub parsing
  3. Database: Uses Apache Parquet via arrow crate for efficient queries

Peer-Reviewed Foundation

  • PEP 484 (van Rossum, Lehtosalo, 2014): Type Hints
  • PEP 561 (Smith, 2017): Stub Distribution (.pyi format)
  • PEP 585 (Langa, 2019): Generic Syntax
  • Apache Parquet Spec (2013): Columnar storage format

Example

use depyler_knowledge::{Harvester, Extractor, TypeDatabase};

// Harvest the requests package
let harvest = Harvester::new("/tmp/harvest")?.fetch("requests")?;

// Extract type facts from .pyi stubs
let facts = Extractor::new().extract_all(&harvest)?;

// Store in Parquet database
let db = TypeDatabase::new("types.parquet")?;
db.write(&facts)?;

// Query: Get signature for requests.get
let sig = db.find_signature("requests", "get");
assert!(sig.unwrap().contains("url: str"));