Skip to main content

Crate depyler_knowledge

Crate depyler_knowledge 

Source
Expand description

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"));

Re-exports§

pub use error::KnowledgeError;
pub use error::Result;
pub use extractor::Extractor;
pub use harvester::HarvestResult;
pub use harvester::Harvester;

Modules§

error
Error types for the Sovereign Type Database.
extractor
Extractor: Parse .pyi stub files to extract type facts.
harvester
Harvester: Package fetching using uv pip install --target.

Structs§

TypeFact
A single type fact extracted from Python stubs.

Enums§

TypeFactKind
The kind of symbol extracted from Python stubs.