Skip to main content

Backend CLI for the Typify inference engine

Project description

typify-backend

Backend CLI for Typify, a lightweight usage-driven static analyzer for precise Python type inference. Published at the 34th IEEE/ACM International Conference on Program Comprehension (ICPC 2026), Rio de Janeiro, Brazil.

Typify infers types for variables, function parameters, and return values in unannotated Python codebases — no training data or existing annotations required.

How it works

Typify's core contribution is usage-driven inference: rather than treating each function in isolation, Typify looks at how a function is actually called across the project and propagates the concrete argument types back to the function's parameters. For example, if process(items) is called with a list[str], Typify infers that the items parameter is list[str] and carries that type into the function body to resolve further expressions.

This works through several stages run in order:

  1. Dependency graph construction — Typify scans all modules and builds a project-wide import graph, determining the order in which modules should be analyzed (topological order, with fixpoint iteration for circular imports).
  2. Usage-driven inference — The engine traverses each module statement by statement, inferring types from assignments, method calls, and operators. Types accumulate monotonically (e.g. x = []list, then x.append(1)list[int]).
  3. Propagation passes — Multiple rounds of call-site application and re-inference allow types to propagate through chains of function calls, resolving one additional level of depth per pass.
  4. Context-matching retrieval — For slots that remain unresolved after usage-driven inference (e.g. uncalled functions), Typify queries a pre-built search index of annotated code to suggest candidate types based on local context similarity.
  5. Type4Py integration — Optionally queries the Type4Py API to fill remaining gaps with deep-learning predictions.

Installation

pip install typify-backend

Usage

Inference

typify-backend infer <project_directory> <output_directory>
  • project_directory — root of the Python project to analyze. Typify recursively finds all .py files within it.
  • output_directory — where results are written. Contains:
    • types/ — one JSON file per source file with inferred types for every resolved identifier
    • index.json — maps each source path (relative to project_directory) to its output JSON file
    • config.json — created on first run with default settings; edit to tune behaviour
    • context-index/ — the downloaded retrieval index (auto-downloaded on first run if retrieval is enabled)

See schema.md for the full output format. This output is intended to be consumed by the Typify VS Code extension.

Subsequent runs on the same output directory are incremental — only files that changed since the last run are re-processed by the retrieval and Type4Py passes.

Configuration

On first run, a config.json is written to the output directory with all defaults. Edit it to tune behaviour:

{
    "context-retrieval": true,
    "context-index-download": "<gdrive-url>",
    "retrieval-top-k": 5,
    "type4py": true,
    "type4py-api-url": "https://type4py.ali-aman.ca/api/predict?tc=0",
    "augment-context": false,
    "propagation-passes": 3,
    "symbolic-depth": 3
}
Field Description
context-retrieval Enable the context-matching retrieval pass. If enabled and no index exists locally, it is downloaded automatically.
context-index-download URL to download the pre-built retrieval index from. Override this to point to your own index.
retrieval-top-k Number of candidate types retrieved per slot; the top result is used.
type4py Enable the Type4Py deep-learning pass for slots still unresolved after retrieval.
type4py-api-url Type4Py API endpoint. Can be changed to a self-hosted instance.
augment-context Experimental. When enabled, augments the retrieval query context with type annotations already present in the user's own codebase, improving retrieval for project-specific types. Under active development.
propagation-passes Number of call-site propagation rounds. More passes resolve longer call chains but take longer.
symbolic-depth Maximum recursion depth during per-callsite symbolic execution of return types.

For more details on the symbolic execution technique and how these parameters affect inference, refer to the ICPC 2026 paper.

Building a custom retrieval index

The build command lets researchers build their own retrieval index from any annotated Python dataset (e.g. ManyTypes4Py, Typilus, or a private codebase):

typify-backend build <dataset_root> <index_directory> [--workers N]
  • dataset_root — root of an annotated Python dataset (e.g. ManyTypes4Py, Typilus, or any collection of .py files with type annotations). Typify recursively walks the tree extracting all annotated type slots and their surrounding context.
  • index_directory — where the Tantivy search index is written. Point context-index-download in config.json to this path (or host it and update the URL) to use it during inference.
  • --workers N — number of parallel worker processes for indexing (default: 4).

This makes it straightforward to experiment with domain-specific or larger corpora to improve retrieval coverage in specialized settings.

Replication

The replication package for the ICPC 2026 paper is available at https://github.com/ali-aman-burki/typify. It contains everything needed to reproduce the empirical results from the paper, including scripts for batch processing large datasets (ManyTypes4Py and Typilus), the full experimental evaluation pipeline, baseline comparisons, and result analysis. Researchers looking to reproduce or extend the evaluation should refer to that repository rather than this CLI.

Project details


Download files

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

Source Distribution

typify_backend-0.1.0.tar.gz (34.2 kB view details)

Uploaded Source

Built Distribution

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

typify_backend-0.1.0-py3-none-any.whl (38.8 kB view details)

Uploaded Python 3

File details

Details for the file typify_backend-0.1.0.tar.gz.

File metadata

  • Download URL: typify_backend-0.1.0.tar.gz
  • Upload date:
  • Size: 34.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for typify_backend-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8589949427adf197716e0e0aa4b9ece48d6857ab32005393e1a4dd46daf444f2
MD5 c559f467e047f297b230ca13c429a452
BLAKE2b-256 0edba2bfef36a8d3d0d2fc1f166730ec9565bdb4f1a57ee8487829637444641e

See more details on using hashes here.

File details

Details for the file typify_backend-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: typify_backend-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 38.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for typify_backend-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dc47e6fd265a0c4161b8800126278e06e1210f824743440a4693f69f67bd0ac1
MD5 279ebca900ac2a25758e99a8f7b59849
BLAKE2b-256 d987e17bcfba75e459db4eaf6a377305341838be40e123663082c9f49c1b13b2

See more details on using hashes here.

Supported by

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