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)
- Harvester: Uses
uv pip install --targetfor deterministic package fetching - Extractor: Uses
rustpython_parserfor.pyistub parsing - Database: Uses Apache Parquet via
arrowcrate 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§
- Type
Fact - A single type fact extracted from Python stubs.
Enums§
- Type
Fact Kind - The kind of symbol extracted from Python stubs.