Skip to main content

Static analysis engine that maps Python codebases into a queryable property graph by resolving symbol definitions, inferring types, and tracing call/reference relationships.

Project description

symgraph

Static analysis engine that maps Python codebases into a queryable property graph by resolving symbol definitions, inferring types, and tracing call/reference relationships.

Features

  • Symbol Extraction: Identifies and catalogs modules, classes, functions, methods, and variables.
  • Static Type Inference: Performs a multi-pass analysis (up to 10 iterations) to resolve variable types and function return types across the project.
  • Relationship Mapping: Traces connections between symbols, specifically distinguishing between direct calls and symbol references.
  • Context-Aware Analysis: Handles self references within class scopes and resolves method calls based on inferred object types.
  • Symbol Querying: Provides a detailed lookup for any symbol, showing its definition location and a list of what it uses and what it is used by.

Installation

pip install symgraph

Usage

Once installed, you can use the symgraph command directly from your terminal.

1. Map an Entire Codebase

To generate a full JSON list of all edges (connections) in a directory or file:

symgraph /path/to/your/project

The output is a JSON array where each entry contains the source, destination, and kind of relationship (e.g., call or ref).

2. Inspect a Specific Symbol

To get a comprehensive report on a specific class, function, or variable:

symgraph /path/to/your/project SymbolName

Example Query Result:

[
  {
    "symbol": "module.ClassName.method_name",
    "kind": "method",
    "file": "path/to/file.py",
    "lines": [10, 20],
    "uses": [
      { "name": "other_module.helper_func", "kind": "function" }
    ],
    "used_by": [
      { "name": "main.run", "kind": "function", "via": "ClassName.method_name" }
    ]
  }
]

License

Apache-2.0

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

symgraph-0.0.1a0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

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

symgraph-0.0.1a0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file symgraph-0.0.1a0.tar.gz.

File metadata

  • Download URL: symgraph-0.0.1a0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for symgraph-0.0.1a0.tar.gz
Algorithm Hash digest
SHA256 dc09fb2c1d756e5d477e50c7c1cfa22ee83dbd44a46510cf9bf2332dee2705bb
MD5 2c2320709a70c9dc044b65e0823cdd42
BLAKE2b-256 36e81bbe67356194aebd735f6152eb0abc4018a86cd959bacf1cb7be658dfe6c

See more details on using hashes here.

File details

Details for the file symgraph-0.0.1a0-py3-none-any.whl.

File metadata

  • Download URL: symgraph-0.0.1a0-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for symgraph-0.0.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 120955cc045ea47b9f76c88bd0c6c12335c2397578ca608a08625721c5e17942
MD5 3a9b206b3dda99b201a7093d9b5054bd
BLAKE2b-256 0a15edab2d3c95badc85dfaaf1c9055bd73a812a8a61fe5b3a652fa94119b328

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